Update auto-generated bindings to latest upstream
[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.99.2", strlen("v0.0.99.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_1NoneErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1033         return ((LDKCResult_NoneErrorZ*)arg)->result_ok;
1034 }
1035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1036         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1037         CHECK(val->result_ok);
1038         return *val->contents.result;
1039 }
1040 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1041         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1042         CHECK(!val->result_ok);
1043         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1044         return err_conv;
1045 }
1046 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1047         return ((LDKCResult_RouteHopDecodeErrorZ*)arg)->result_ok;
1048 }
1049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1050         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1051         CHECK(val->result_ok);
1052         LDKRouteHop res_var = (*val->contents.result);
1053         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1054         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1055         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1056         return res_ref;
1057 }
1058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1059         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1060         CHECK(!val->result_ok);
1061         LDKDecodeError err_var = (*val->contents.err);
1062         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1063         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1064         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1065         return err_ref;
1066 }
1067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHopZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1068         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
1069         ret->datalen = (*env)->GetArrayLength(env, elems);
1070         if (ret->datalen == 0) {
1071                 ret->data = NULL;
1072         } else {
1073                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
1074                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1075                 for (size_t i = 0; i < ret->datalen; i++) {
1076                         int64_t arr_elem = java_elems[i];
1077                         LDKRouteHop arr_elem_conv;
1078                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1079                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1080                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
1081                         ret->data[i] = arr_elem_conv;
1082                 }
1083                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1084         }
1085         return (uint64_t)ret;
1086 }
1087 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1088         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1089         for (size_t i = 0; i < ret.datalen; i++) {
1090                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1091         }
1092         return ret;
1093 }
1094 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1095         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1096         for (size_t i = 0; i < ret.datalen; i++) {
1097                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1098         }
1099         return ret;
1100 }
1101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1102         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
1103 }
1104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1105         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1106         CHECK(val->result_ok);
1107         LDKRoute res_var = (*val->contents.result);
1108         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1109         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1110         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1111         return res_ref;
1112 }
1113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1114         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1115         CHECK(!val->result_ok);
1116         LDKDecodeError err_var = (*val->contents.err);
1117         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1118         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1119         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1120         return err_ref;
1121 }
1122 static jclass LDKCOption_u64Z_Some_class = NULL;
1123 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1124 static jclass LDKCOption_u64Z_None_class = NULL;
1125 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1127         LDKCOption_u64Z_Some_class =
1128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1129         CHECK(LDKCOption_u64Z_Some_class != NULL);
1130         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1131         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1132         LDKCOption_u64Z_None_class =
1133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1134         CHECK(LDKCOption_u64Z_None_class != NULL);
1135         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1136         CHECK(LDKCOption_u64Z_None_meth != NULL);
1137 }
1138 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1139         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1140         switch(obj->tag) {
1141                 case LDKCOption_u64Z_Some: {
1142                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1143                 }
1144                 case LDKCOption_u64Z_None: {
1145                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1146                 }
1147                 default: abort();
1148         }
1149 }
1150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelDetailsZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1151         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1152         ret->datalen = (*env)->GetArrayLength(env, elems);
1153         if (ret->datalen == 0) {
1154                 ret->data = NULL;
1155         } else {
1156                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1157                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1158                 for (size_t i = 0; i < ret->datalen; i++) {
1159                         int64_t arr_elem = java_elems[i];
1160                         LDKChannelDetails arr_elem_conv;
1161                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1162                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1163                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1164                         ret->data[i] = arr_elem_conv;
1165                 }
1166                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1167         }
1168         return (uint64_t)ret;
1169 }
1170 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1171         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1172         for (size_t i = 0; i < ret.datalen; i++) {
1173                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1174         }
1175         return ret;
1176 }
1177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1RouteHintZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1178         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
1179         ret->datalen = (*env)->GetArrayLength(env, elems);
1180         if (ret->datalen == 0) {
1181                 ret->data = NULL;
1182         } else {
1183                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
1184                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1185                 for (size_t i = 0; i < ret->datalen; i++) {
1186                         int64_t arr_elem = java_elems[i];
1187                         LDKRouteHint arr_elem_conv;
1188                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1189                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1190                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
1191                         ret->data[i] = arr_elem_conv;
1192                 }
1193                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1194         }
1195         return (uint64_t)ret;
1196 }
1197 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1198         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1199         for (size_t i = 0; i < ret.datalen; i++) {
1200                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1201         }
1202         return ret;
1203 }
1204 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1205         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
1206 }
1207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1208         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1209         CHECK(val->result_ok);
1210         LDKRoute res_var = (*val->contents.result);
1211         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1212         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1213         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1214         return res_ref;
1215 }
1216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1217         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1218         CHECK(!val->result_ok);
1219         LDKLightningError err_var = (*val->contents.err);
1220         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1221         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1222         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1223         return err_ref;
1224 }
1225 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1226         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1227 }
1228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1229         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1230         CHECK(val->result_ok);
1231         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1232         return (uint64_t)res_ref;
1233 }
1234 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1235         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1236         CHECK(!val->result_ok);
1237         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1238         return err_conv;
1239 }
1240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
1241         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1242         ret->a = a;
1243         LDKTransaction b_ref;
1244         b_ref.datalen = (*env)->GetArrayLength(env, b);
1245         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
1246         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
1247         b_ref.data_is_owned = false;
1248         ret->b = b_ref;
1249         return (uint64_t)ret;
1250 }
1251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
1252         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1253         return tuple->a;
1254 }
1255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
1256         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
1257         LDKTransaction b_var = tuple->b;
1258         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
1259         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
1260         return b_arr;
1261 }
1262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1263         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
1264         ret->datalen = (*env)->GetArrayLength(env, elems);
1265         if (ret->datalen == 0) {
1266                 ret->data = NULL;
1267         } else {
1268                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
1269                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1270                 for (size_t i = 0; i < ret->datalen; i++) {
1271                         int64_t arr_elem = java_elems[i];
1272                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
1273                         arr_elem_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1));
1274                         ret->data[i] = arr_elem_conv;
1275                 }
1276                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1277         }
1278         return (uint64_t)ret;
1279 }
1280 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1281         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1282         for (size_t i = 0; i < ret.datalen; i++) {
1283                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1284         }
1285         return ret;
1286 }
1287 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1288         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1289         for (size_t i = 0; i < ret.datalen; i++) {
1290                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1291         }
1292         return ret;
1293 }
1294 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1295         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
1296 }
1297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1298         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1299         CHECK(val->result_ok);
1300         return *val->contents.result;
1301 }
1302 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1303         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1304         CHECK(!val->result_ok);
1305         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1306         return err_conv;
1307 }
1308 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1309 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1310 static jclass LDKMonitorEvent_CommitmentTxBroadcasted_class = NULL;
1311 static jmethodID LDKMonitorEvent_CommitmentTxBroadcasted_meth = NULL;
1312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1313         LDKMonitorEvent_HTLCEvent_class =
1314                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1315         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1316         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1317         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1318         LDKMonitorEvent_CommitmentTxBroadcasted_class =
1319                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxBroadcasted;"));
1320         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_class != NULL);
1321         LDKMonitorEvent_CommitmentTxBroadcasted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, "<init>", "(J)V");
1322         CHECK(LDKMonitorEvent_CommitmentTxBroadcasted_meth != NULL);
1323 }
1324 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1325         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1326         switch(obj->tag) {
1327                 case LDKMonitorEvent_HTLCEvent: {
1328                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1329                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1330                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1331                         uint64_t htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1332                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1333                 }
1334                 case LDKMonitorEvent_CommitmentTxBroadcasted: {
1335                         LDKOutPoint commitment_tx_broadcasted_var = obj->commitment_tx_broadcasted;
1336                         CHECK((((uint64_t)commitment_tx_broadcasted_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1337                         CHECK((((uint64_t)&commitment_tx_broadcasted_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1338                         uint64_t commitment_tx_broadcasted_ref = (uint64_t)commitment_tx_broadcasted_var.inner & ~1;
1339                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxBroadcasted_class, LDKMonitorEvent_CommitmentTxBroadcasted_meth, commitment_tx_broadcasted_ref);
1340                 }
1341                 default: abort();
1342         }
1343 }
1344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MonitorEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1345         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
1346         ret->datalen = (*env)->GetArrayLength(env, elems);
1347         if (ret->datalen == 0) {
1348                 ret->data = NULL;
1349         } else {
1350                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
1351                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1352                 for (size_t i = 0; i < ret->datalen; i++) {
1353                         int64_t arr_elem = java_elems[i];
1354                         LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
1355                         arr_elem_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1));
1356                         ret->data[i] = arr_elem_conv;
1357                 }
1358                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1359         }
1360         return (uint64_t)ret;
1361 }
1362 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1363         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1364         for (size_t i = 0; i < ret.datalen; i++) {
1365                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1366         }
1367         return ret;
1368 }
1369 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1370 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1371 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1372 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1374         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1375                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1376         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1377         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1378         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1379         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1380                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1381         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1382         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1383         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1384 }
1385 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1386         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1387         switch(obj->tag) {
1388                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1389                         uint64_t some_ref = (uint64_t)(&obj->some) | 1;
1390                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, some_ref);
1391                 }
1392                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1393                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1394                 }
1395                 default: abort();
1396         }
1397 }
1398 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1399 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1400 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1401 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1402 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1403 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1405         LDKSpendableOutputDescriptor_StaticOutput_class =
1406                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1407         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1408         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1409         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1410         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1411                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1412         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1413         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1414         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1415         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1416                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1417         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1418         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1419         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1420 }
1421 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1422         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1423         switch(obj->tag) {
1424                 case LDKSpendableOutputDescriptor_StaticOutput: {
1425                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1426                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1427                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1428                         uint64_t outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1429                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1430                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1431                 }
1432                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1433                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1434                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1435                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1436                         uint64_t delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1437                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1438                 }
1439                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1440                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1441                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1442                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1443                         uint64_t static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1444                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1445                 }
1446                 default: abort();
1447         }
1448 }
1449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1SpendableOutputDescriptorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1450         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
1451         ret->datalen = (*env)->GetArrayLength(env, elems);
1452         if (ret->datalen == 0) {
1453                 ret->data = NULL;
1454         } else {
1455                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
1456                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1457                 for (size_t i = 0; i < ret->datalen; i++) {
1458                         int64_t arr_elem = java_elems[i];
1459                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
1460                         arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
1461                         ret->data[i] = arr_elem_conv;
1462                 }
1463                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1464         }
1465         return (uint64_t)ret;
1466 }
1467 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1468         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1469         for (size_t i = 0; i < ret.datalen; i++) {
1470                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1471         }
1472         return ret;
1473 }
1474 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1475 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1476 static jclass LDKErrorAction_IgnoreError_class = NULL;
1477 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1478 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
1479 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
1480 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1481 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1483         LDKErrorAction_DisconnectPeer_class =
1484                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
1485         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
1486         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
1487         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
1488         LDKErrorAction_IgnoreError_class =
1489                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
1490         CHECK(LDKErrorAction_IgnoreError_class != NULL);
1491         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
1492         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
1493         LDKErrorAction_IgnoreAndLog_class =
1494                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;"));
1495         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
1496         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
1497         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
1498         LDKErrorAction_SendErrorMessage_class =
1499                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
1500         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
1501         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
1502         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
1503 }
1504 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1505         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1506         switch(obj->tag) {
1507                 case LDKErrorAction_DisconnectPeer: {
1508                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1509                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1510                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1511                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1512                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
1513                 }
1514                 case LDKErrorAction_IgnoreError: {
1515                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
1516                 }
1517                 case LDKErrorAction_IgnoreAndLog: {
1518                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
1519                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
1520                 }
1521                 case LDKErrorAction_SendErrorMessage: {
1522                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1523                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1524                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1525                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1526                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
1527                 }
1528                 default: abort();
1529         }
1530 }
1531 static jclass LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class = NULL;
1532 static jmethodID LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = NULL;
1533 static jclass LDKHTLCFailChannelUpdate_ChannelClosed_class = NULL;
1534 static jmethodID LDKHTLCFailChannelUpdate_ChannelClosed_meth = NULL;
1535 static jclass LDKHTLCFailChannelUpdate_NodeFailure_class = NULL;
1536 static jmethodID LDKHTLCFailChannelUpdate_NodeFailure_meth = NULL;
1537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCFailChannelUpdate_init (JNIEnv *env, jclass clz) {
1538         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class =
1539                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelUpdateMessage;"));
1540         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class != NULL);
1541         LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1542         CHECK(LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth != NULL);
1543         LDKHTLCFailChannelUpdate_ChannelClosed_class =
1544                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$ChannelClosed;"));
1545         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_class != NULL);
1546         LDKHTLCFailChannelUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1547         CHECK(LDKHTLCFailChannelUpdate_ChannelClosed_meth != NULL);
1548         LDKHTLCFailChannelUpdate_NodeFailure_class =
1549                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKHTLCFailChannelUpdate$NodeFailure;"));
1550         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_class != NULL);
1551         LDKHTLCFailChannelUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKHTLCFailChannelUpdate_NodeFailure_class, "<init>", "([BZ)V");
1552         CHECK(LDKHTLCFailChannelUpdate_NodeFailure_meth != NULL);
1553 }
1554 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCFailChannelUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1555         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)(ptr & ~1);
1556         switch(obj->tag) {
1557                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
1558                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1559                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1560                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1561                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1562                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_class, LDKHTLCFailChannelUpdate_ChannelUpdateMessage_meth, msg_ref);
1563                 }
1564                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
1565                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_ChannelClosed_class, LDKHTLCFailChannelUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1566                 }
1567                 case LDKHTLCFailChannelUpdate_NodeFailure: {
1568                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1569                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1570                         return (*env)->NewObject(env, LDKHTLCFailChannelUpdate_NodeFailure_class, LDKHTLCFailChannelUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1571                 }
1572                 default: abort();
1573         }
1574 }
1575 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
1576 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
1577 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
1578 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
1579 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
1580 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
1581 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
1582 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
1583 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
1584 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
1585 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
1586 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
1587 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
1588 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
1589 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
1590 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
1591 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
1592 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
1593 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
1594 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
1595 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
1596 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
1597 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
1598 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
1599 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
1600 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
1601 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
1602 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
1603 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
1604 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
1605 static jclass LDKMessageSendEvent_HandleError_class = NULL;
1606 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
1607 static jclass LDKMessageSendEvent_PaymentFailureNetworkUpdate_class = NULL;
1608 static jmethodID LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = NULL;
1609 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
1610 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
1611 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
1612 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
1613 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
1614 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
1615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
1616         LDKMessageSendEvent_SendAcceptChannel_class =
1617                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
1618         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
1619         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
1620         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
1621         LDKMessageSendEvent_SendOpenChannel_class =
1622                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
1623         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
1624         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
1625         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
1626         LDKMessageSendEvent_SendFundingCreated_class =
1627                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
1628         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
1629         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
1630         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
1631         LDKMessageSendEvent_SendFundingSigned_class =
1632                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
1633         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
1634         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
1635         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
1636         LDKMessageSendEvent_SendFundingLocked_class =
1637                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
1638         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
1639         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
1640         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
1641         LDKMessageSendEvent_SendAnnouncementSignatures_class =
1642                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
1643         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
1644         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
1645         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
1646         LDKMessageSendEvent_UpdateHTLCs_class =
1647                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
1648         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
1649         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
1650         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
1651         LDKMessageSendEvent_SendRevokeAndACK_class =
1652                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
1653         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
1654         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
1655         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
1656         LDKMessageSendEvent_SendClosingSigned_class =
1657                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
1658         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
1659         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
1660         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
1661         LDKMessageSendEvent_SendShutdown_class =
1662                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
1663         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
1664         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
1665         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
1666         LDKMessageSendEvent_SendChannelReestablish_class =
1667                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
1668         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
1669         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
1670         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
1671         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
1672                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
1673         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
1674         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
1675         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
1676         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
1677                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
1678         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
1679         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
1680         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
1681         LDKMessageSendEvent_BroadcastChannelUpdate_class =
1682                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
1683         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
1684         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
1685         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
1686         LDKMessageSendEvent_SendChannelUpdate_class =
1687                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;"));
1688         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
1689         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
1690         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
1691         LDKMessageSendEvent_HandleError_class =
1692                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
1693         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
1694         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
1695         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
1696         LDKMessageSendEvent_PaymentFailureNetworkUpdate_class =
1697                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$PaymentFailureNetworkUpdate;"));
1698         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_class != NULL);
1699         LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, "<init>", "(J)V");
1700         CHECK(LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth != NULL);
1701         LDKMessageSendEvent_SendChannelRangeQuery_class =
1702                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
1703         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
1704         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
1705         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
1706         LDKMessageSendEvent_SendShortIdsQuery_class =
1707                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
1708         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
1709         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
1710         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
1711         LDKMessageSendEvent_SendReplyChannelRange_class =
1712                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
1713         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
1714         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
1715         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
1716 }
1717 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1718         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1719         switch(obj->tag) {
1720                 case LDKMessageSendEvent_SendAcceptChannel: {
1721                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1722                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
1723                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1724                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1725                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1726                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1727                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
1728                 }
1729                 case LDKMessageSendEvent_SendOpenChannel: {
1730                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1731                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
1732                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1733                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1734                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1735                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1736                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
1737                 }
1738                 case LDKMessageSendEvent_SendFundingCreated: {
1739                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1740                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
1741                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1742                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1743                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1744                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1745                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
1746                 }
1747                 case LDKMessageSendEvent_SendFundingSigned: {
1748                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1749                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
1750                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1751                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1752                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1753                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1754                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
1755                 }
1756                 case LDKMessageSendEvent_SendFundingLocked: {
1757                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1758                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
1759                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1760                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1761                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1762                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1763                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
1764                 }
1765                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1766                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1767                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
1768                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1769                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1770                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1771                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1772                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
1773                 }
1774                 case LDKMessageSendEvent_UpdateHTLCs: {
1775                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1776                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
1777                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1778                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1779                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1780                         uint64_t updates_ref = (uint64_t)updates_var.inner & ~1;
1781                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
1782                 }
1783                 case LDKMessageSendEvent_SendRevokeAndACK: {
1784                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1785                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
1786                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1787                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1788                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1789                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1790                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
1791                 }
1792                 case LDKMessageSendEvent_SendClosingSigned: {
1793                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1794                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
1795                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1796                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1797                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1798                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1799                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
1800                 }
1801                 case LDKMessageSendEvent_SendShutdown: {
1802                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1803                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
1804                         LDKShutdown msg_var = obj->send_shutdown.msg;
1805                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1806                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1807                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1808                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
1809                 }
1810                 case LDKMessageSendEvent_SendChannelReestablish: {
1811                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1812                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
1813                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1814                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1815                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1816                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1817                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
1818                 }
1819                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1820                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1821                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1822                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1823                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1824                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1825                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1826                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1827                         uint64_t update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1828                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
1829                 }
1830                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1831                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1832                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1833                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1834                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1835                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
1836                 }
1837                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1838                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1839                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1840                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1841                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1842                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
1843                 }
1844                 case LDKMessageSendEvent_SendChannelUpdate: {
1845                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1846                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
1847                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1848                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1849                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1850                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1851                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
1852                 }
1853                 case LDKMessageSendEvent_HandleError: {
1854                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1855                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
1856                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1857                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
1858                 }
1859                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
1860                         uint64_t update_ref = ((uint64_t)&obj->payment_failure_network_update.update) | 1;
1861                         return (*env)->NewObject(env, LDKMessageSendEvent_PaymentFailureNetworkUpdate_class, LDKMessageSendEvent_PaymentFailureNetworkUpdate_meth, update_ref);
1862                 }
1863                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1864                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1865                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
1866                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1867                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1868                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1869                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1870                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
1871                 }
1872                 case LDKMessageSendEvent_SendShortIdsQuery: {
1873                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1874                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
1875                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1876                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1877                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1878                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1879                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
1880                 }
1881                 case LDKMessageSendEvent_SendReplyChannelRange: {
1882                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1883                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
1884                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1885                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1886                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1887                         uint64_t msg_ref = (uint64_t)msg_var.inner & ~1;
1888                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
1889                 }
1890                 default: abort();
1891         }
1892 }
1893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1MessageSendEventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
1894         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
1895         ret->datalen = (*env)->GetArrayLength(env, elems);
1896         if (ret->datalen == 0) {
1897                 ret->data = NULL;
1898         } else {
1899                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
1900                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
1901                 for (size_t i = 0; i < ret->datalen; i++) {
1902                         int64_t arr_elem = java_elems[i];
1903                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
1904                         arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
1905                         ret->data[i] = arr_elem_conv;
1906                 }
1907                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
1908         }
1909         return (uint64_t)ret;
1910 }
1911 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1912         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1913         for (size_t i = 0; i < ret.datalen; i++) {
1914                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1915         }
1916         return ret;
1917 }
1918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1919         return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
1920 }
1921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1922         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1923         CHECK(val->result_ok);
1924         LDKInitFeatures res_var = (*val->contents.result);
1925         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1926         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1927         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1928         return res_ref;
1929 }
1930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1931         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1932         CHECK(!val->result_ok);
1933         LDKDecodeError err_var = (*val->contents.err);
1934         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1935         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1936         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1937         return err_ref;
1938 }
1939 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1940         return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
1941 }
1942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1943         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1944         CHECK(val->result_ok);
1945         LDKNodeFeatures res_var = (*val->contents.result);
1946         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1947         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1948         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
1949         return res_ref;
1950 }
1951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1952         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1953         CHECK(!val->result_ok);
1954         LDKDecodeError err_var = (*val->contents.err);
1955         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1956         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1957         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
1958         return err_ref;
1959 }
1960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1961         return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
1962 }
1963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1964         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1965         CHECK(val->result_ok);
1966         LDKChannelFeatures 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_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1973         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(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_1InvoiceFeaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1982         return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
1983 }
1984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1985         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1986         CHECK(val->result_ok);
1987         LDKInvoiceFeatures 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_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1994         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(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_1DelayedPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2003         return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2004 }
2005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2006         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2007         CHECK(val->result_ok);
2008         LDKDelayedPaymentOutputDescriptor 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_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2015         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(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_1StaticPaymentOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2024         return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2025 }
2026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2027         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2028         CHECK(val->result_ok);
2029         LDKStaticPaymentOutputDescriptor 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_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2036         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(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_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2045         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
2046 }
2047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2048         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2049         CHECK(val->result_ok);
2050         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2051         return res_ref;
2052 }
2053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2054         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2055         CHECK(!val->result_ok);
2056         LDKDecodeError err_var = (*val->contents.err);
2057         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2058         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2059         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2060         return err_ref;
2061 }
2062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
2063         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2064         LDKSignature a_ref;
2065         CHECK((*env)->GetArrayLength(env, a) == 64);
2066         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
2067         ret->a = a_ref;
2068         LDKCVec_SignatureZ b_constr;
2069         b_constr.datalen = (*env)->GetArrayLength(env, b);
2070         if (b_constr.datalen > 0)
2071                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
2072         else
2073                 b_constr.data = NULL;
2074         for (size_t i = 0; i < b_constr.datalen; i++) {
2075                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
2076                 LDKSignature b_conv_8_ref;
2077                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
2078                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
2079                 b_constr.data[i] = b_conv_8_ref;
2080         }
2081         ret->b = b_constr;
2082         return (uint64_t)ret;
2083 }
2084 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2085         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2086         int8_tArray a_arr = (*env)->NewByteArray(env, 64);
2087         (*env)->SetByteArrayRegion(env, a_arr, 0, 64, tuple->a.compact_form);
2088         return a_arr;
2089 }
2090 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2091         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
2092         LDKCVec_SignatureZ b_var = tuple->b;
2093         jobjectArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
2094         ;
2095         for (size_t i = 0; i < b_var.datalen; i++) {
2096                 int8_tArray b_conv_8_arr = (*env)->NewByteArray(env, 64);
2097                 (*env)->SetByteArrayRegion(env, b_conv_8_arr, 0, 64, b_var.data[i].compact_form);
2098                 (*env)->SetObjectArrayElement(env, b_arr, i, b_conv_8_arr);
2099         }
2100         return b_arr;
2101 }
2102 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2103         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
2104 }
2105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2106         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2107         CHECK(val->result_ok);
2108         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
2109         return res_ref;
2110 }
2111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2112         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2113         CHECK(!val->result_ok);
2114         return *val->contents.err;
2115 }
2116 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2117         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
2118 }
2119 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2120         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2121         CHECK(val->result_ok);
2122         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2123         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2124         return res_arr;
2125 }
2126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2127         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2128         CHECK(!val->result_ok);
2129         return *val->contents.err;
2130 }
2131 typedef struct LDKBaseSign_JCalls {
2132         atomic_size_t refcnt;
2133         JavaVM *vm;
2134         jweak o;
2135         jmethodID get_per_commitment_point_meth;
2136         jmethodID release_commitment_secret_meth;
2137         jmethodID channel_keys_id_meth;
2138         jmethodID sign_counterparty_commitment_meth;
2139         jmethodID sign_holder_commitment_and_htlcs_meth;
2140         jmethodID sign_justice_revoked_output_meth;
2141         jmethodID sign_justice_revoked_htlc_meth;
2142         jmethodID sign_counterparty_htlc_transaction_meth;
2143         jmethodID sign_closing_transaction_meth;
2144         jmethodID sign_channel_announcement_meth;
2145         jmethodID ready_channel_meth;
2146 } LDKBaseSign_JCalls;
2147 static void LDKBaseSign_JCalls_free(void* this_arg) {
2148         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2149         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2150                 JNIEnv *env;
2151                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2152                 if (get_jenv_res == JNI_EDETACHED) {
2153                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2154                 } else {
2155                         DO_ASSERT(get_jenv_res == JNI_OK);
2156                 }
2157                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2158                 if (get_jenv_res == JNI_EDETACHED) {
2159                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2160                 }
2161                 FREE(j_calls);
2162         }
2163 }
2164 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2165         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2166         JNIEnv *env;
2167         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2168         if (get_jenv_res == JNI_EDETACHED) {
2169                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2170         } else {
2171                 DO_ASSERT(get_jenv_res == JNI_OK);
2172         }
2173         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2174         CHECK(obj != NULL);
2175         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2176         if ((*env)->ExceptionCheck(env)) {
2177                 (*env)->ExceptionDescribe(env);
2178                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2179         }
2180         LDKPublicKey ret_ref;
2181         CHECK((*env)->GetArrayLength(env, ret) == 33);
2182         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2183         if (get_jenv_res == JNI_EDETACHED) {
2184                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2185         }
2186         return ret_ref;
2187 }
2188 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2189         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2190         JNIEnv *env;
2191         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2192         if (get_jenv_res == JNI_EDETACHED) {
2193                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2194         } else {
2195                 DO_ASSERT(get_jenv_res == JNI_OK);
2196         }
2197         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2198         CHECK(obj != NULL);
2199         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2200         if ((*env)->ExceptionCheck(env)) {
2201                 (*env)->ExceptionDescribe(env);
2202                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2203         }
2204         LDKThirtyTwoBytes ret_ref;
2205         CHECK((*env)->GetArrayLength(env, ret) == 32);
2206         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2207         if (get_jenv_res == JNI_EDETACHED) {
2208                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2209         }
2210         return ret_ref;
2211 }
2212 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2213         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2214         JNIEnv *env;
2215         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2216         if (get_jenv_res == JNI_EDETACHED) {
2217                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2218         } else {
2219                 DO_ASSERT(get_jenv_res == JNI_OK);
2220         }
2221         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2222         CHECK(obj != NULL);
2223         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2224         if ((*env)->ExceptionCheck(env)) {
2225                 (*env)->ExceptionDescribe(env);
2226                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2227         }
2228         LDKThirtyTwoBytes ret_ref;
2229         CHECK((*env)->GetArrayLength(env, ret) == 32);
2230         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2231         if (get_jenv_res == JNI_EDETACHED) {
2232                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2233         }
2234         return ret_ref;
2235 }
2236 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2237         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2238         JNIEnv *env;
2239         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2240         if (get_jenv_res == JNI_EDETACHED) {
2241                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2242         } else {
2243                 DO_ASSERT(get_jenv_res == JNI_OK);
2244         }
2245         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2246         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2247         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2248         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2249         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2250         if (commitment_tx_var.is_owned) {
2251                 commitment_tx_ref |= 1;
2252         }
2253         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2254         CHECK(obj != NULL);
2255         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2256         if ((*env)->ExceptionCheck(env)) {
2257                 (*env)->ExceptionDescribe(env);
2258                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
2259         }
2260         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2261         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2262         if (get_jenv_res == JNI_EDETACHED) {
2263                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2264         }
2265         return ret_conv;
2266 }
2267 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2268         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2269         JNIEnv *env;
2270         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2271         if (get_jenv_res == JNI_EDETACHED) {
2272                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2273         } else {
2274                 DO_ASSERT(get_jenv_res == JNI_OK);
2275         }
2276         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2277         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2278         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2279         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2280         uint64_t commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2281         if (commitment_tx_var.is_owned) {
2282                 commitment_tx_ref |= 1;
2283         }
2284         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2285         CHECK(obj != NULL);
2286         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2287         if ((*env)->ExceptionCheck(env)) {
2288                 (*env)->ExceptionDescribe(env);
2289                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
2290         }
2291         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
2292         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
2293         if (get_jenv_res == JNI_EDETACHED) {
2294                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2295         }
2296         return ret_conv;
2297 }
2298 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]) {
2299         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2300         JNIEnv *env;
2301         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2302         if (get_jenv_res == JNI_EDETACHED) {
2303                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2304         } else {
2305                 DO_ASSERT(get_jenv_res == JNI_OK);
2306         }
2307         LDKTransaction justice_tx_var = justice_tx;
2308         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2309         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2310         Transaction_free(justice_tx_var);
2311         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2312         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2313         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2314         CHECK(obj != NULL);
2315         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
2316         if ((*env)->ExceptionCheck(env)) {
2317                 (*env)->ExceptionDescribe(env);
2318                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
2319         }
2320         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2321         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2322         if (get_jenv_res == JNI_EDETACHED) {
2323                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2324         }
2325         return ret_conv;
2326 }
2327 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) {
2328         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2329         JNIEnv *env;
2330         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2331         if (get_jenv_res == JNI_EDETACHED) {
2332                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2333         } else {
2334                 DO_ASSERT(get_jenv_res == JNI_OK);
2335         }
2336         LDKTransaction justice_tx_var = justice_tx;
2337         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2338         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2339         Transaction_free(justice_tx_var);
2340         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2341         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2342         LDKHTLCOutputInCommitment htlc_var = *htlc;
2343         htlc_var = HTLCOutputInCommitment_clone(htlc);
2344         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2345         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2346         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2347         if (htlc_var.is_owned) {
2348                 htlc_ref |= 1;
2349         }
2350         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2351         CHECK(obj != NULL);
2352         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2353         if ((*env)->ExceptionCheck(env)) {
2354                 (*env)->ExceptionDescribe(env);
2355                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
2356         }
2357         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2358         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2359         if (get_jenv_res == JNI_EDETACHED) {
2360                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2361         }
2362         return ret_conv;
2363 }
2364 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) {
2365         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2366         JNIEnv *env;
2367         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2368         if (get_jenv_res == JNI_EDETACHED) {
2369                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2370         } else {
2371                 DO_ASSERT(get_jenv_res == JNI_OK);
2372         }
2373         LDKTransaction htlc_tx_var = htlc_tx;
2374         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2375         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2376         Transaction_free(htlc_tx_var);
2377         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2378         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2379         LDKHTLCOutputInCommitment htlc_var = *htlc;
2380         htlc_var = HTLCOutputInCommitment_clone(htlc);
2381         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2382         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2383         uint64_t htlc_ref = (uint64_t)htlc_var.inner;
2384         if (htlc_var.is_owned) {
2385                 htlc_ref |= 1;
2386         }
2387         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2388         CHECK(obj != NULL);
2389         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
2390         if ((*env)->ExceptionCheck(env)) {
2391                 (*env)->ExceptionDescribe(env);
2392                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
2393         }
2394         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2395         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2396         if (get_jenv_res == JNI_EDETACHED) {
2397                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2398         }
2399         return ret_conv;
2400 }
2401 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction closing_tx) {
2402         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2403         JNIEnv *env;
2404         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2405         if (get_jenv_res == JNI_EDETACHED) {
2406                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2407         } else {
2408                 DO_ASSERT(get_jenv_res == JNI_OK);
2409         }
2410         LDKTransaction closing_tx_var = closing_tx;
2411         int8_tArray closing_tx_arr = (*env)->NewByteArray(env, closing_tx_var.datalen);
2412         (*env)->SetByteArrayRegion(env, closing_tx_arr, 0, closing_tx_var.datalen, closing_tx_var.data);
2413         Transaction_free(closing_tx_var);
2414         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2415         CHECK(obj != NULL);
2416         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_arr);
2417         if ((*env)->ExceptionCheck(env)) {
2418                 (*env)->ExceptionDescribe(env);
2419                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
2420         }
2421         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2422         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2423         if (get_jenv_res == JNI_EDETACHED) {
2424                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2425         }
2426         return ret_conv;
2427 }
2428 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2429         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2430         JNIEnv *env;
2431         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2432         if (get_jenv_res == JNI_EDETACHED) {
2433                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2434         } else {
2435                 DO_ASSERT(get_jenv_res == JNI_OK);
2436         }
2437         LDKUnsignedChannelAnnouncement msg_var = *msg;
2438         msg_var = UnsignedChannelAnnouncement_clone(msg);
2439         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2440         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2441         uint64_t msg_ref = (uint64_t)msg_var.inner;
2442         if (msg_var.is_owned) {
2443                 msg_ref |= 1;
2444         }
2445         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2446         CHECK(obj != NULL);
2447         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
2448         if ((*env)->ExceptionCheck(env)) {
2449                 (*env)->ExceptionDescribe(env);
2450                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
2451         }
2452         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
2453         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
2454         if (get_jenv_res == JNI_EDETACHED) {
2455                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2456         }
2457         return ret_conv;
2458 }
2459 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2460         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2461         JNIEnv *env;
2462         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2463         if (get_jenv_res == JNI_EDETACHED) {
2464                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2465         } else {
2466                 DO_ASSERT(get_jenv_res == JNI_OK);
2467         }
2468         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2469         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2470         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2471         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2472         uint64_t channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2473         if (channel_parameters_var.is_owned) {
2474                 channel_parameters_ref |= 1;
2475         }
2476         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2477         CHECK(obj != NULL);
2478         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
2479         if ((*env)->ExceptionCheck(env)) {
2480                 (*env)->ExceptionDescribe(env);
2481                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
2482         }
2483         if (get_jenv_res == JNI_EDETACHED) {
2484                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2485         }
2486 }
2487 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2488         jclass c = (*env)->GetObjectClass(env, o);
2489         CHECK(c != NULL);
2490         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2491         atomic_init(&calls->refcnt, 1);
2492         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2493         calls->o = (*env)->NewWeakGlobalRef(env, o);
2494         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
2495         CHECK(calls->get_per_commitment_point_meth != NULL);
2496         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
2497         CHECK(calls->release_commitment_secret_meth != NULL);
2498         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
2499         CHECK(calls->channel_keys_id_meth != NULL);
2500         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
2501         CHECK(calls->sign_counterparty_commitment_meth != NULL);
2502         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
2503         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
2504         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
2505         CHECK(calls->sign_justice_revoked_output_meth != NULL);
2506         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
2507         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
2508         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
2509         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
2510         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
2511         CHECK(calls->sign_closing_transaction_meth != NULL);
2512         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
2513         CHECK(calls->sign_channel_announcement_meth != NULL);
2514         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
2515         CHECK(calls->ready_channel_meth != NULL);
2516
2517         LDKChannelPublicKeys pubkeys_conv;
2518         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2519         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2520         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2521
2522         LDKBaseSign ret = {
2523                 .this_arg = (void*) calls,
2524                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2525                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2526                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2527                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2528                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2529                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2530                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2531                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2532                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2533                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2534                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2535                 .free = LDKBaseSign_JCalls_free,
2536                 .pubkeys = pubkeys_conv,
2537                 .set_pubkeys = NULL,
2538         };
2539         return ret;
2540 }
2541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
2542         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2543         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
2544         return (uint64_t)res_ptr;
2545 }
2546 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) {
2547         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2548         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
2549         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
2550         return ret_arr;
2551 }
2552
2553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
2554         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2555         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2556         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
2557         return ret_arr;
2558 }
2559
2560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
2561         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2562         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
2563         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
2564         return ret_arr;
2565 }
2566
2567 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) {
2568         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2569         LDKCommitmentTransaction commitment_tx_conv;
2570         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2571         commitment_tx_conv.is_owned = false;
2572         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2573         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2574         return (uint64_t)ret_conv;
2575 }
2576
2577 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) {
2578         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2579         LDKHolderCommitmentTransaction commitment_tx_conv;
2580         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2581         commitment_tx_conv.is_owned = false;
2582         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2583         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2584         return (uint64_t)ret_conv;
2585 }
2586
2587 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) {
2588         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2589         LDKTransaction justice_tx_ref;
2590         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2591         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2592         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2593         justice_tx_ref.data_is_owned = true;
2594         unsigned char per_commitment_key_arr[32];
2595         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2596         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2597         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2598         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2599         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2600         return (uint64_t)ret_conv;
2601 }
2602
2603 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) {
2604         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2605         LDKTransaction justice_tx_ref;
2606         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
2607         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2608         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
2609         justice_tx_ref.data_is_owned = true;
2610         unsigned char per_commitment_key_arr[32];
2611         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
2612         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
2613         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2614         LDKHTLCOutputInCommitment htlc_conv;
2615         htlc_conv.inner = (void*)(htlc & (~1));
2616         htlc_conv.is_owned = false;
2617         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2618         *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);
2619         return (uint64_t)ret_conv;
2620 }
2621
2622 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) {
2623         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2624         LDKTransaction htlc_tx_ref;
2625         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
2626         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2627         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
2628         htlc_tx_ref.data_is_owned = true;
2629         LDKPublicKey per_commitment_point_ref;
2630         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
2631         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
2632         LDKHTLCOutputInCommitment htlc_conv;
2633         htlc_conv.inner = (void*)(htlc & (~1));
2634         htlc_conv.is_owned = false;
2635         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2636         *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);
2637         return (uint64_t)ret_conv;
2638 }
2639
2640 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) {
2641         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2642         LDKTransaction closing_tx_ref;
2643         closing_tx_ref.datalen = (*env)->GetArrayLength(env, closing_tx);
2644         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
2645         (*env)->GetByteArrayRegion(env, closing_tx, 0, closing_tx_ref.datalen, closing_tx_ref.data);
2646         closing_tx_ref.data_is_owned = true;
2647         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2648         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
2649         return (uint64_t)ret_conv;
2650 }
2651
2652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
2653         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2654         LDKUnsignedChannelAnnouncement msg_conv;
2655         msg_conv.inner = (void*)(msg & (~1));
2656         msg_conv.is_owned = false;
2657         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2658         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2659         return (uint64_t)ret_conv;
2660 }
2661
2662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
2663         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2664         LDKChannelTransactionParameters channel_parameters_conv;
2665         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2666         channel_parameters_conv.is_owned = false;
2667         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2668 }
2669
2670 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2671         if (this_arg->set_pubkeys != NULL)
2672                 this_arg->set_pubkeys(this_arg);
2673         return this_arg->pubkeys;
2674 }
2675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
2676         LDKBaseSign* this_arg_conv = (LDKBaseSign*)(((uint64_t)this_arg) & ~1);
2677         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2678         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2679         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2680         uint64_t ret_ref = (uint64_t)ret_var.inner;
2681         if (ret_var.is_owned) {
2682                 ret_ref |= 1;
2683         }
2684         return ret_ref;
2685 }
2686
2687 typedef struct LDKSign_JCalls {
2688         atomic_size_t refcnt;
2689         JavaVM *vm;
2690         jweak o;
2691         LDKBaseSign_JCalls* BaseSign;
2692         jmethodID write_meth;
2693 } LDKSign_JCalls;
2694 static void LDKSign_JCalls_free(void* this_arg) {
2695         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2696         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2697                 JNIEnv *env;
2698                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2699                 if (get_jenv_res == JNI_EDETACHED) {
2700                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2701                 } else {
2702                         DO_ASSERT(get_jenv_res == JNI_OK);
2703                 }
2704                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2705                 if (get_jenv_res == JNI_EDETACHED) {
2706                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2707                 }
2708                 FREE(j_calls);
2709         }
2710 }
2711 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2712         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2713         JNIEnv *env;
2714         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2715         if (get_jenv_res == JNI_EDETACHED) {
2716                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2717         } else {
2718                 DO_ASSERT(get_jenv_res == JNI_OK);
2719         }
2720         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2721         CHECK(obj != NULL);
2722         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2723         if ((*env)->ExceptionCheck(env)) {
2724                 (*env)->ExceptionDescribe(env);
2725                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
2726         }
2727         LDKCVec_u8Z ret_ref;
2728         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2729         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2730         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2731         if (get_jenv_res == JNI_EDETACHED) {
2732                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2733         }
2734         return ret_ref;
2735 }
2736 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2737         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2738         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2739         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2740 }
2741 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2742         jclass c = (*env)->GetObjectClass(env, o);
2743         CHECK(c != NULL);
2744         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2745         atomic_init(&calls->refcnt, 1);
2746         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2747         calls->o = (*env)->NewWeakGlobalRef(env, o);
2748         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2749         CHECK(calls->write_meth != NULL);
2750
2751         LDKChannelPublicKeys pubkeys_conv;
2752         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2753         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2754         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
2755
2756         LDKSign ret = {
2757                 .this_arg = (void*) calls,
2758                 .write = write_LDKSign_jcall,
2759                 .cloned = LDKSign_JCalls_cloned,
2760                 .free = LDKSign_JCalls_free,
2761                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
2762         };
2763         calls->BaseSign = ret.BaseSign.this_arg;
2764         return ret;
2765 }
2766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
2767         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2768         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
2769         return (uint64_t)res_ptr;
2770 }
2771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
2772         LDKSign *inp = (LDKSign *)(arg & ~1);
2773         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
2774         DO_ASSERT((res_ptr & 1) == 0);
2775         return (int64_t)(res_ptr | 1);
2776 }
2777 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2778         LDKSign* this_arg_conv = (LDKSign*)(((uint64_t)this_arg) & ~1);
2779         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2780         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2781         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2782         CVec_u8Z_free(ret_var);
2783         return ret_arr;
2784 }
2785
2786 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2787         return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
2788 }
2789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2790         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2791         CHECK(val->result_ok);
2792         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
2793         *ret = Sign_clone(&(*val->contents.result));
2794         return (uint64_t)ret;
2795 }
2796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2797         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2798         CHECK(!val->result_ok);
2799         LDKDecodeError err_var = (*val->contents.err);
2800         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2801         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2802         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2803         return err_ref;
2804 }
2805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2806         return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
2807 }
2808 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2809         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2810         CHECK(val->result_ok);
2811         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
2812         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
2813         return es_arr;
2814 }
2815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2816         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2817         CHECK(!val->result_ok);
2818         return *val->contents.err;
2819 }
2820 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2821         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2822         for (size_t i = 0; i < ret.datalen; i++) {
2823                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2824         }
2825         return ret;
2826 }
2827 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2828         return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
2829 }
2830 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2831         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2832         CHECK(val->result_ok);
2833         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2834         jobjectArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
2835         ;
2836         for (size_t i = 0; i < res_var.datalen; i++) {
2837                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
2838                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
2839                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
2840                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
2841         }
2842         return res_arr;
2843 }
2844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2845         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2846         CHECK(!val->result_ok);
2847         return *val->contents.err;
2848 }
2849 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2850         return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
2851 }
2852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2853         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2854         CHECK(val->result_ok);
2855         LDKInMemorySigner res_var = (*val->contents.result);
2856         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2857         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2858         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
2859         return res_ref;
2860 }
2861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2862         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2863         CHECK(!val->result_ok);
2864         LDKDecodeError err_var = (*val->contents.err);
2865         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2866         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2867         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
2868         return err_ref;
2869 }
2870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1TxOutZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2871         LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
2872         ret->datalen = (*env)->GetArrayLength(env, elems);
2873         if (ret->datalen == 0) {
2874                 ret->data = NULL;
2875         } else {
2876                 ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
2877                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2878                 for (size_t i = 0; i < ret->datalen; i++) {
2879                         int64_t arr_elem = java_elems[i];
2880                         LDKTxOut arr_elem_conv = *(LDKTxOut*)(((uint64_t)arr_elem) & ~1);
2881                         arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
2882                         ret->data[i] = arr_elem_conv;
2883                 }
2884                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2885         }
2886         return (uint64_t)ret;
2887 }
2888 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2889         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2890         for (size_t i = 0; i < ret.datalen; i++) {
2891                 ret.data[i] = TxOut_clone(&orig->data[i]);
2892         }
2893         return ret;
2894 }
2895 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2896         return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
2897 }
2898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2899         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2900         CHECK(val->result_ok);
2901         LDKTransaction res_var = (*val->contents.result);
2902         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
2903         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
2904         return res_arr;
2905 }
2906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2907         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2908         CHECK(!val->result_ok);
2909         return *val->contents.err;
2910 }
2911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
2912         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2913         LDKThirtyTwoBytes a_ref;
2914         CHECK((*env)->GetArrayLength(env, a) == 32);
2915         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
2916         ret->a = a_ref;
2917         LDKChannelMonitor b_conv;
2918         b_conv.inner = (void*)(b & (~1));
2919         b_conv.is_owned = (b & 1) || (b == 0);
2920         b_conv = ChannelMonitor_clone(&b_conv);
2921         ret->b = b_conv;
2922         return (uint64_t)ret;
2923 }
2924 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
2925         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2926         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
2927         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
2928         return a_arr;
2929 }
2930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
2931         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
2932         LDKChannelMonitor b_var = tuple->b;
2933         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2934         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2935         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
2936         return b_ref;
2937 }
2938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1BlockHashChannelMonitorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
2939         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
2940         ret->datalen = (*env)->GetArrayLength(env, elems);
2941         if (ret->datalen == 0) {
2942                 ret->data = NULL;
2943         } else {
2944                 ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
2945                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
2946                 for (size_t i = 0; i < ret->datalen; i++) {
2947                         int64_t arr_elem = java_elems[i];
2948                         LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1);
2949                         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
2950                         ret->data[i] = arr_elem_conv;
2951                 }
2952                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
2953         }
2954         return (uint64_t)ret;
2955 }
2956 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2957         return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
2958 }
2959 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2960         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2961         CHECK(val->result_ok);
2962         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2963         int64_tArray res_arr = (*env)->NewLongArray(env, res_var.datalen);
2964         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
2965         for (size_t i = 0; i < res_var.datalen; i++) {
2966                 uint64_t res_conv_34_ref = (uint64_t)(&res_var.data[i]) | 1;
2967                 res_arr_ptr[i] = res_conv_34_ref;
2968         }
2969         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
2970         return res_arr;
2971 }
2972 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2973         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2974         CHECK(!val->result_ok);
2975         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
2976         return err_conv;
2977 }
2978 static jclass LDKCOption_u16Z_Some_class = NULL;
2979 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
2980 static jclass LDKCOption_u16Z_None_class = NULL;
2981 static jmethodID LDKCOption_u16Z_None_meth = NULL;
2982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
2983         LDKCOption_u16Z_Some_class =
2984                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
2985         CHECK(LDKCOption_u16Z_Some_class != NULL);
2986         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
2987         CHECK(LDKCOption_u16Z_Some_meth != NULL);
2988         LDKCOption_u16Z_None_class =
2989                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
2990         CHECK(LDKCOption_u16Z_None_class != NULL);
2991         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
2992         CHECK(LDKCOption_u16Z_None_meth != NULL);
2993 }
2994 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2995         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
2996         switch(obj->tag) {
2997                 case LDKCOption_u16Z_Some: {
2998                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
2999                 }
3000                 case LDKCOption_u16Z_None: {
3001                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
3002                 }
3003                 default: abort();
3004         }
3005 }
3006 static jclass LDKAPIError_APIMisuseError_class = NULL;
3007 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
3008 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
3009 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
3010 static jclass LDKAPIError_RouteError_class = NULL;
3011 static jmethodID LDKAPIError_RouteError_meth = NULL;
3012 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3013 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3014 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3015 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3017         LDKAPIError_APIMisuseError_class =
3018                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3019         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3020         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3021         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3022         LDKAPIError_FeeRateTooHigh_class =
3023                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3024         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3025         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3026         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3027         LDKAPIError_RouteError_class =
3028                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3029         CHECK(LDKAPIError_RouteError_class != NULL);
3030         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3031         CHECK(LDKAPIError_RouteError_meth != NULL);
3032         LDKAPIError_ChannelUnavailable_class =
3033                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3034         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3035         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3036         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3037         LDKAPIError_MonitorUpdateFailed_class =
3038                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3039         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3040         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3041         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3042 }
3043 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3044         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3045         switch(obj->tag) {
3046                 case LDKAPIError_APIMisuseError: {
3047                         LDKStr err_str = obj->api_misuse_error.err;
3048                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3049                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3050                 }
3051                 case LDKAPIError_FeeRateTooHigh: {
3052                         LDKStr err_str = obj->fee_rate_too_high.err;
3053                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3054                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3055                 }
3056                 case LDKAPIError_RouteError: {
3057                         LDKStr err_str = obj->route_error.err;
3058                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3059                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3060                 }
3061                 case LDKAPIError_ChannelUnavailable: {
3062                         LDKStr err_str = obj->channel_unavailable.err;
3063                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3064                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3065                 }
3066                 case LDKAPIError_MonitorUpdateFailed: {
3067                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3068                 }
3069                 default: abort();
3070         }
3071 }
3072 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3073         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
3074 }
3075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3076         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3077         CHECK(val->result_ok);
3078         return *val->contents.result;
3079 }
3080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3081         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3082         CHECK(!val->result_ok);
3083         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3084         return err_ref;
3085 }
3086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1CResult_1NoneAPIErrorZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3087         LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
3088         ret->datalen = (*env)->GetArrayLength(env, elems);
3089         if (ret->datalen == 0) {
3090                 ret->data = NULL;
3091         } else {
3092                 ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
3093                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3094                 for (size_t i = 0; i < ret->datalen; i++) {
3095                         int64_t arr_elem = java_elems[i];
3096                         LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1);
3097                         arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
3098                         ret->data[i] = arr_elem_conv;
3099                 }
3100                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3101         }
3102         return (uint64_t)ret;
3103 }
3104 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3105         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3106         for (size_t i = 0; i < ret.datalen; i++) {
3107                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3108         }
3109         return ret;
3110 }
3111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1APIErrorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3112         LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
3113         ret->datalen = (*env)->GetArrayLength(env, elems);
3114         if (ret->datalen == 0) {
3115                 ret->data = NULL;
3116         } else {
3117                 ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
3118                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3119                 for (size_t i = 0; i < ret->datalen; i++) {
3120                         int64_t arr_elem = java_elems[i];
3121                         LDKAPIError arr_elem_conv = *(LDKAPIError*)(((uint64_t)arr_elem) & ~1);
3122                         arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
3123                         ret->data[i] = arr_elem_conv;
3124                 }
3125                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3126         }
3127         return (uint64_t)ret;
3128 }
3129 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3130         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3131         for (size_t i = 0; i < ret.datalen; i++) {
3132                 ret.data[i] = APIError_clone(&orig->data[i]);
3133         }
3134         return ret;
3135 }
3136 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3137 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3138 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3139 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3140 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3141 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3142 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3143 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3145         LDKPaymentSendFailure_ParameterError_class =
3146                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3147         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3148         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3149         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3150         LDKPaymentSendFailure_PathParameterError_class =
3151                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3152         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3153         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3154         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3155         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3156                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3157         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3158         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3159         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3160         LDKPaymentSendFailure_PartialFailure_class =
3161                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3162         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3163         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([J)V");
3164         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3165 }
3166 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3167         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3168         switch(obj->tag) {
3169                 case LDKPaymentSendFailure_ParameterError: {
3170                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3171                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3172                 }
3173                 case LDKPaymentSendFailure_PathParameterError: {
3174                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3175                         int64_tArray path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3176                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3177                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3178                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3179                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3180                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3181                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3182                         }
3183                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3184                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3185                 }
3186                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3187                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3188                         int64_tArray all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3189                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3190                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3191                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3192                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3193                         }
3194                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3195                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3196                 }
3197                 case LDKPaymentSendFailure_PartialFailure: {
3198                         LDKCVec_CResult_NoneAPIErrorZZ partial_failure_var = obj->partial_failure;
3199                         int64_tArray partial_failure_arr = (*env)->NewLongArray(env, partial_failure_var.datalen);
3200                         int64_t *partial_failure_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, partial_failure_arr, NULL);
3201                         for (size_t w = 0; w < partial_failure_var.datalen; w++) {
3202                                 LDKCResult_NoneAPIErrorZ* partial_failure_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3203                                 *partial_failure_conv_22_conv = partial_failure_var.data[w];
3204                                 *partial_failure_conv_22_conv = CResult_NoneAPIErrorZ_clone(partial_failure_conv_22_conv);
3205                                 partial_failure_arr_ptr[w] = (uint64_t)partial_failure_conv_22_conv;
3206                         }
3207                         (*env)->ReleasePrimitiveArrayCritical(env, partial_failure_arr, partial_failure_arr_ptr, 0);
3208                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, partial_failure_arr);
3209                 }
3210                 default: abort();
3211         }
3212 }
3213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3214         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
3215 }
3216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3217         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3218         CHECK(val->result_ok);
3219         return *val->contents.result;
3220 }
3221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3222         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3223         CHECK(!val->result_ok);
3224         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3225         return err_ref;
3226 }
3227 static jclass LDKNetAddress_IPv4_class = NULL;
3228 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3229 static jclass LDKNetAddress_IPv6_class = NULL;
3230 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3231 static jclass LDKNetAddress_OnionV2_class = NULL;
3232 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3233 static jclass LDKNetAddress_OnionV3_class = NULL;
3234 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3236         LDKNetAddress_IPv4_class =
3237                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3238         CHECK(LDKNetAddress_IPv4_class != NULL);
3239         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3240         CHECK(LDKNetAddress_IPv4_meth != NULL);
3241         LDKNetAddress_IPv6_class =
3242                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3243         CHECK(LDKNetAddress_IPv6_class != NULL);
3244         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3245         CHECK(LDKNetAddress_IPv6_meth != NULL);
3246         LDKNetAddress_OnionV2_class =
3247                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3248         CHECK(LDKNetAddress_OnionV2_class != NULL);
3249         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3250         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3251         LDKNetAddress_OnionV3_class =
3252                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3253         CHECK(LDKNetAddress_OnionV3_class != NULL);
3254         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3255         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3256 }
3257 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3258         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3259         switch(obj->tag) {
3260                 case LDKNetAddress_IPv4: {
3261                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3262                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3263                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3264                 }
3265                 case LDKNetAddress_IPv6: {
3266                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3267                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3268                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3269                 }
3270                 case LDKNetAddress_OnionV2: {
3271                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3272                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3273                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3274                 }
3275                 case LDKNetAddress_OnionV3: {
3276                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3277                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3278                         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);
3279                 }
3280                 default: abort();
3281         }
3282 }
3283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NetAddressZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3284         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
3285         ret->datalen = (*env)->GetArrayLength(env, elems);
3286         if (ret->datalen == 0) {
3287                 ret->data = NULL;
3288         } else {
3289                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
3290                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3291                 for (size_t i = 0; i < ret->datalen; i++) {
3292                         int64_t arr_elem = java_elems[i];
3293                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
3294                         arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
3295                         ret->data[i] = arr_elem_conv;
3296                 }
3297                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3298         }
3299         return (uint64_t)ret;
3300 }
3301 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3302         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3303         for (size_t i = 0; i < ret.datalen; i++) {
3304                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3305         }
3306         return ret;
3307 }
3308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
3309         LDKC2Tuple_PaymentHashPaymentSecretZ* ret = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
3310         LDKThirtyTwoBytes a_ref;
3311         CHECK((*env)->GetArrayLength(env, a) == 32);
3312         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
3313         ret->a = a_ref;
3314         LDKThirtyTwoBytes b_ref;
3315         CHECK((*env)->GetArrayLength(env, b) == 32);
3316         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
3317         ret->b = b_ref;
3318         return (uint64_t)ret;
3319 }
3320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
3321         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3322         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
3323         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
3324         return a_arr;
3325 }
3326 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
3327         LDKC2Tuple_PaymentHashPaymentSecretZ *tuple = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(ptr & ~1);
3328         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
3329         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
3330         return b_arr;
3331 }
3332 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3333         return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
3334 }
3335 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3336         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3337         CHECK(val->result_ok);
3338         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3339         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3340         return res_arr;
3341 }
3342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3343         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
3344         CHECK(!val->result_ok);
3345         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3346         return err_ref;
3347 }
3348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1ChannelMonitorZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
3349         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
3350         ret->datalen = (*env)->GetArrayLength(env, elems);
3351         if (ret->datalen == 0) {
3352                 ret->data = NULL;
3353         } else {
3354                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
3355                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
3356                 for (size_t i = 0; i < ret->datalen; i++) {
3357                         int64_t arr_elem = java_elems[i];
3358                         LDKChannelMonitor arr_elem_conv;
3359                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
3360                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
3361                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
3362                         ret->data[i] = arr_elem_conv;
3363                 }
3364                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
3365         }
3366         return (uint64_t)ret;
3367 }
3368 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
3369         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
3370         for (size_t i = 0; i < ret.datalen; i++) {
3371                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
3372         }
3373         return ret;
3374 }
3375 typedef struct LDKWatch_JCalls {
3376         atomic_size_t refcnt;
3377         JavaVM *vm;
3378         jweak o;
3379         jmethodID watch_channel_meth;
3380         jmethodID update_channel_meth;
3381         jmethodID release_pending_monitor_events_meth;
3382 } LDKWatch_JCalls;
3383 static void LDKWatch_JCalls_free(void* this_arg) {
3384         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3385         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3386                 JNIEnv *env;
3387                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3388                 if (get_jenv_res == JNI_EDETACHED) {
3389                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3390                 } else {
3391                         DO_ASSERT(get_jenv_res == JNI_OK);
3392                 }
3393                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3394                 if (get_jenv_res == JNI_EDETACHED) {
3395                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3396                 }
3397                 FREE(j_calls);
3398         }
3399 }
3400 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
3401         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3402         JNIEnv *env;
3403         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3404         if (get_jenv_res == JNI_EDETACHED) {
3405                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3406         } else {
3407                 DO_ASSERT(get_jenv_res == JNI_OK);
3408         }
3409         LDKOutPoint funding_txo_var = funding_txo;
3410         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3411         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3412         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3413         if (funding_txo_var.is_owned) {
3414                 funding_txo_ref |= 1;
3415         }
3416         LDKChannelMonitor monitor_var = monitor;
3417         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3418         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3419         uint64_t monitor_ref = (uint64_t)monitor_var.inner;
3420         if (monitor_var.is_owned) {
3421                 monitor_ref |= 1;
3422         }
3423         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3424         CHECK(obj != NULL);
3425         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
3426         if ((*env)->ExceptionCheck(env)) {
3427                 (*env)->ExceptionDescribe(env);
3428                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
3429         }
3430         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3431         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3432         if (get_jenv_res == JNI_EDETACHED) {
3433                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3434         }
3435         return ret_conv;
3436 }
3437 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
3438         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3439         JNIEnv *env;
3440         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3441         if (get_jenv_res == JNI_EDETACHED) {
3442                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3443         } else {
3444                 DO_ASSERT(get_jenv_res == JNI_OK);
3445         }
3446         LDKOutPoint funding_txo_var = funding_txo;
3447         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3448         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3449         uint64_t funding_txo_ref = (uint64_t)funding_txo_var.inner;
3450         if (funding_txo_var.is_owned) {
3451                 funding_txo_ref |= 1;
3452         }
3453         LDKChannelMonitorUpdate update_var = update;
3454         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3455         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3456         uint64_t update_ref = (uint64_t)update_var.inner;
3457         if (update_var.is_owned) {
3458                 update_ref |= 1;
3459         }
3460         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3461         CHECK(obj != NULL);
3462         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
3463         if ((*env)->ExceptionCheck(env)) {
3464                 (*env)->ExceptionDescribe(env);
3465                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
3466         }
3467         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3468         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
3469         if (get_jenv_res == JNI_EDETACHED) {
3470                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3471         }
3472         return ret_conv;
3473 }
3474 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
3475         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
3476         JNIEnv *env;
3477         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3478         if (get_jenv_res == JNI_EDETACHED) {
3479                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3480         } else {
3481                 DO_ASSERT(get_jenv_res == JNI_OK);
3482         }
3483         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3484         CHECK(obj != NULL);
3485         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
3486         if ((*env)->ExceptionCheck(env)) {
3487                 (*env)->ExceptionDescribe(env);
3488                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
3489         }
3490         LDKCVec_MonitorEventZ ret_constr;
3491         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
3492         if (ret_constr.datalen > 0)
3493                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3494         else
3495                 ret_constr.data = NULL;
3496         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
3497         for (size_t o = 0; o < ret_constr.datalen; o++) {
3498                 int64_t ret_conv_14 = ret_vals[o];
3499                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1);
3500                 ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
3501                 ret_constr.data[o] = ret_conv_14_conv;
3502         }
3503         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
3504         if (get_jenv_res == JNI_EDETACHED) {
3505                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3506         }
3507         return ret_constr;
3508 }
3509 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
3510         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
3511         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3512 }
3513 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
3514         jclass c = (*env)->GetObjectClass(env, o);
3515         CHECK(c != NULL);
3516         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
3517         atomic_init(&calls->refcnt, 1);
3518         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3519         calls->o = (*env)->NewWeakGlobalRef(env, o);
3520         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
3521         CHECK(calls->watch_channel_meth != NULL);
3522         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
3523         CHECK(calls->update_channel_meth != NULL);
3524         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
3525         CHECK(calls->release_pending_monitor_events_meth != NULL);
3526
3527         LDKWatch ret = {
3528                 .this_arg = (void*) calls,
3529                 .watch_channel = watch_channel_LDKWatch_jcall,
3530                 .update_channel = update_channel_LDKWatch_jcall,
3531                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
3532                 .free = LDKWatch_JCalls_free,
3533         };
3534         return ret;
3535 }
3536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
3537         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
3538         *res_ptr = LDKWatch_init(env, clz, o);
3539         return (uint64_t)res_ptr;
3540 }
3541 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) {
3542         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3543         LDKOutPoint funding_txo_conv;
3544         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3545         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3546         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3547         LDKChannelMonitor monitor_conv;
3548         monitor_conv.inner = (void*)(monitor & (~1));
3549         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3550         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3551         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3552         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3553         return (uint64_t)ret_conv;
3554 }
3555
3556 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) {
3557         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3558         LDKOutPoint funding_txo_conv;
3559         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3560         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3561         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3562         LDKChannelMonitorUpdate update_conv;
3563         update_conv.inner = (void*)(update & (~1));
3564         update_conv.is_owned = (update & 1) || (update == 0);
3565         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3566         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3567         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3568         return (uint64_t)ret_conv;
3569 }
3570
3571 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
3572         LDKWatch* this_arg_conv = (LDKWatch*)(((uint64_t)this_arg) & ~1);
3573         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3574         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3575         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3576         for (size_t o = 0; o < ret_var.datalen; o++) {
3577                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3578                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
3579                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3580                 ret_arr_ptr[o] = ret_conv_14_ref;
3581         }
3582         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3583         FREE(ret_var.data);
3584         return ret_arr;
3585 }
3586
3587 typedef struct LDKBroadcasterInterface_JCalls {
3588         atomic_size_t refcnt;
3589         JavaVM *vm;
3590         jweak o;
3591         jmethodID broadcast_transaction_meth;
3592 } LDKBroadcasterInterface_JCalls;
3593 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3594         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3595         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3596                 JNIEnv *env;
3597                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3598                 if (get_jenv_res == JNI_EDETACHED) {
3599                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3600                 } else {
3601                         DO_ASSERT(get_jenv_res == JNI_OK);
3602                 }
3603                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3604                 if (get_jenv_res == JNI_EDETACHED) {
3605                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3606                 }
3607                 FREE(j_calls);
3608         }
3609 }
3610 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3611         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3612         JNIEnv *env;
3613         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3614         if (get_jenv_res == JNI_EDETACHED) {
3615                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3616         } else {
3617                 DO_ASSERT(get_jenv_res == JNI_OK);
3618         }
3619         LDKTransaction tx_var = tx;
3620         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
3621         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
3622         Transaction_free(tx_var);
3623         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3624         CHECK(obj != NULL);
3625         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
3626         if ((*env)->ExceptionCheck(env)) {
3627                 (*env)->ExceptionDescribe(env);
3628                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
3629         }
3630         if (get_jenv_res == JNI_EDETACHED) {
3631                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3632         }
3633 }
3634 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
3635         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
3636         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3637 }
3638 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
3639         jclass c = (*env)->GetObjectClass(env, o);
3640         CHECK(c != NULL);
3641         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3642         atomic_init(&calls->refcnt, 1);
3643         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3644         calls->o = (*env)->NewWeakGlobalRef(env, o);
3645         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
3646         CHECK(calls->broadcast_transaction_meth != NULL);
3647
3648         LDKBroadcasterInterface ret = {
3649                 .this_arg = (void*) calls,
3650                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3651                 .free = LDKBroadcasterInterface_JCalls_free,
3652         };
3653         return ret;
3654 }
3655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3656         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3657         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
3658         return (uint64_t)res_ptr;
3659 }
3660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
3661         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)(((uint64_t)this_arg) & ~1);
3662         LDKTransaction tx_ref;
3663         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
3664         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3665         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
3666         tx_ref.data_is_owned = true;
3667         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3668 }
3669
3670 typedef struct LDKKeysInterface_JCalls {
3671         atomic_size_t refcnt;
3672         JavaVM *vm;
3673         jweak o;
3674         jmethodID get_node_secret_meth;
3675         jmethodID get_destination_script_meth;
3676         jmethodID get_shutdown_pubkey_meth;
3677         jmethodID get_channel_signer_meth;
3678         jmethodID get_secure_random_bytes_meth;
3679         jmethodID read_chan_signer_meth;
3680         jmethodID sign_invoice_meth;
3681 } LDKKeysInterface_JCalls;
3682 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3683         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3684         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3685                 JNIEnv *env;
3686                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3687                 if (get_jenv_res == JNI_EDETACHED) {
3688                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3689                 } else {
3690                         DO_ASSERT(get_jenv_res == JNI_OK);
3691                 }
3692                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3693                 if (get_jenv_res == JNI_EDETACHED) {
3694                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3695                 }
3696                 FREE(j_calls);
3697         }
3698 }
3699 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3700         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3701         JNIEnv *env;
3702         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3703         if (get_jenv_res == JNI_EDETACHED) {
3704                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3705         } else {
3706                 DO_ASSERT(get_jenv_res == JNI_OK);
3707         }
3708         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3709         CHECK(obj != NULL);
3710         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
3711         if ((*env)->ExceptionCheck(env)) {
3712                 (*env)->ExceptionDescribe(env);
3713                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
3714         }
3715         LDKSecretKey ret_ref;
3716         CHECK((*env)->GetArrayLength(env, ret) == 32);
3717         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
3718         if (get_jenv_res == JNI_EDETACHED) {
3719                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3720         }
3721         return ret_ref;
3722 }
3723 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3724         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3725         JNIEnv *env;
3726         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3727         if (get_jenv_res == JNI_EDETACHED) {
3728                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3729         } else {
3730                 DO_ASSERT(get_jenv_res == JNI_OK);
3731         }
3732         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3733         CHECK(obj != NULL);
3734         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
3735         if ((*env)->ExceptionCheck(env)) {
3736                 (*env)->ExceptionDescribe(env);
3737                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
3738         }
3739         LDKCVec_u8Z ret_ref;
3740         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3741         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3742         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3743         if (get_jenv_res == JNI_EDETACHED) {
3744                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3745         }
3746         return ret_ref;
3747 }
3748 LDKPublicKey get_shutdown_pubkey_LDKKeysInterface_jcall(const void* this_arg) {
3749         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3750         JNIEnv *env;
3751         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3752         if (get_jenv_res == JNI_EDETACHED) {
3753                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3754         } else {
3755                 DO_ASSERT(get_jenv_res == JNI_OK);
3756         }
3757         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3758         CHECK(obj != NULL);
3759         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_shutdown_pubkey_meth);
3760         if ((*env)->ExceptionCheck(env)) {
3761                 (*env)->ExceptionDescribe(env);
3762                 (*env)->FatalError(env, "A call to get_shutdown_pubkey in LDKKeysInterface from rust threw an exception.");
3763         }
3764         LDKPublicKey ret_ref;
3765         CHECK((*env)->GetArrayLength(env, ret) == 33);
3766         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3767         if (get_jenv_res == JNI_EDETACHED) {
3768                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3769         }
3770         return ret_ref;
3771 }
3772 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3773         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3774         JNIEnv *env;
3775         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3776         if (get_jenv_res == JNI_EDETACHED) {
3777                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3778         } else {
3779                 DO_ASSERT(get_jenv_res == JNI_OK);
3780         }
3781         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3782         CHECK(obj != NULL);
3783         LDKSign* ret = (LDKSign*)(*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3784         if ((*env)->ExceptionCheck(env)) {
3785                 (*env)->ExceptionDescribe(env);
3786                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
3787         }
3788         LDKSign ret_conv = *(LDKSign*)(((uint64_t)ret) & ~1);
3789         ret_conv = Sign_clone(ret);
3790         if (get_jenv_res == JNI_EDETACHED) {
3791                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3792         }
3793         return ret_conv;
3794 }
3795 LDKThirtyTwoBytes get_secure_random_bytes_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_secure_random_bytes_meth);
3807         if ((*env)->ExceptionCheck(env)) {
3808                 (*env)->ExceptionDescribe(env);
3809                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
3810         }
3811         LDKThirtyTwoBytes ret_ref;
3812         CHECK((*env)->GetArrayLength(env, ret) == 32);
3813         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3814         if (get_jenv_res == JNI_EDETACHED) {
3815                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3816         }
3817         return ret_ref;
3818 }
3819 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3820         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3821         JNIEnv *env;
3822         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3823         if (get_jenv_res == JNI_EDETACHED) {
3824                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3825         } else {
3826                 DO_ASSERT(get_jenv_res == JNI_OK);
3827         }
3828         LDKu8slice reader_var = reader;
3829         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
3830         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
3831         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3832         CHECK(obj != NULL);
3833         LDKCResult_SignDecodeErrorZ* ret = (LDKCResult_SignDecodeErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
3834         if ((*env)->ExceptionCheck(env)) {
3835                 (*env)->ExceptionDescribe(env);
3836                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
3837         }
3838         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1);
3839         ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
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 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
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         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3855         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
3856         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
3857         CVec_u8Z_free(invoice_preimage_var);
3858         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3859         CHECK(obj != NULL);
3860         LDKCResult_RecoverableSignatureNoneZ* ret = (LDKCResult_RecoverableSignatureNoneZ*)(*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
3861         if ((*env)->ExceptionCheck(env)) {
3862                 (*env)->ExceptionDescribe(env);
3863                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
3864         }
3865         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1);
3866         ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
3867         if (get_jenv_res == JNI_EDETACHED) {
3868                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3869         }
3870         return ret_conv;
3871 }
3872 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
3873         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
3874         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3875 }
3876 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
3877         jclass c = (*env)->GetObjectClass(env, o);
3878         CHECK(c != NULL);
3879         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3880         atomic_init(&calls->refcnt, 1);
3881         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3882         calls->o = (*env)->NewWeakGlobalRef(env, o);
3883         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
3884         CHECK(calls->get_node_secret_meth != NULL);
3885         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
3886         CHECK(calls->get_destination_script_meth != NULL);
3887         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
3888         CHECK(calls->get_shutdown_pubkey_meth != NULL);
3889         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
3890         CHECK(calls->get_channel_signer_meth != NULL);
3891         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
3892         CHECK(calls->get_secure_random_bytes_meth != NULL);
3893         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
3894         CHECK(calls->read_chan_signer_meth != NULL);
3895         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
3896         CHECK(calls->sign_invoice_meth != NULL);
3897
3898         LDKKeysInterface ret = {
3899                 .this_arg = (void*) calls,
3900                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3901                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3902                 .get_shutdown_pubkey = get_shutdown_pubkey_LDKKeysInterface_jcall,
3903                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3904                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3905                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3906                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
3907                 .free = LDKKeysInterface_JCalls_free,
3908         };
3909         return ret;
3910 }
3911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
3912         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3913         *res_ptr = LDKKeysInterface_init(env, clz, o);
3914         return (uint64_t)res_ptr;
3915 }
3916 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
3917         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3918         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3919         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
3920         return ret_arr;
3921 }
3922
3923 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
3924         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3925         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3926         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3927         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3928         CVec_u8Z_free(ret_var);
3929         return ret_arr;
3930 }
3931
3932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
3933         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3934         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3935         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form);
3936         return ret_arr;
3937 }
3938
3939 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) {
3940         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3941         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
3942         *ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3943         return (uint64_t)ret;
3944 }
3945
3946 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
3947         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3948         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3949         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
3950         return ret_arr;
3951 }
3952
3953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
3954         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3955         LDKu8slice reader_ref;
3956         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
3957         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
3958         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3959         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3960         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
3961         return (uint64_t)ret_conv;
3962 }
3963
3964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
3965         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)(((uint64_t)this_arg) & ~1);
3966         LDKCVec_u8Z invoice_preimage_ref;
3967         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
3968         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
3969         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
3970         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
3971         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
3972         return (uint64_t)ret_conv;
3973 }
3974
3975 typedef struct LDKFeeEstimator_JCalls {
3976         atomic_size_t refcnt;
3977         JavaVM *vm;
3978         jweak o;
3979         jmethodID get_est_sat_per_1000_weight_meth;
3980 } LDKFeeEstimator_JCalls;
3981 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3982         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3983         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3984                 JNIEnv *env;
3985                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3986                 if (get_jenv_res == JNI_EDETACHED) {
3987                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3988                 } else {
3989                         DO_ASSERT(get_jenv_res == JNI_OK);
3990                 }
3991                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3992                 if (get_jenv_res == JNI_EDETACHED) {
3993                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3994                 }
3995                 FREE(j_calls);
3996         }
3997 }
3998 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3999         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4000         JNIEnv *env;
4001         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4002         if (get_jenv_res == JNI_EDETACHED) {
4003                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4004         } else {
4005                 DO_ASSERT(get_jenv_res == JNI_OK);
4006         }
4007         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4008         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4009         CHECK(obj != NULL);
4010         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4011         if ((*env)->ExceptionCheck(env)) {
4012                 (*env)->ExceptionDescribe(env);
4013                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4014         }
4015         if (get_jenv_res == JNI_EDETACHED) {
4016                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4017         }
4018         return ret;
4019 }
4020 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4021         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4022         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4023 }
4024 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4025         jclass c = (*env)->GetObjectClass(env, o);
4026         CHECK(c != NULL);
4027         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4028         atomic_init(&calls->refcnt, 1);
4029         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4030         calls->o = (*env)->NewWeakGlobalRef(env, o);
4031         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4032         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4033
4034         LDKFeeEstimator ret = {
4035                 .this_arg = (void*) calls,
4036                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4037                 .free = LDKFeeEstimator_JCalls_free,
4038         };
4039         return ret;
4040 }
4041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4042         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4043         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4044         return (uint64_t)res_ptr;
4045 }
4046 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) {
4047         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)(((uint64_t)this_arg) & ~1);
4048         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4049         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4050         return ret_val;
4051 }
4052
4053 typedef struct LDKLogger_JCalls {
4054         atomic_size_t refcnt;
4055         JavaVM *vm;
4056         jweak o;
4057         jmethodID log_meth;
4058 } LDKLogger_JCalls;
4059 static void LDKLogger_JCalls_free(void* this_arg) {
4060         LDKLogger_JCalls *j_calls = (LDKLogger_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 void log_LDKLogger_jcall(const void* this_arg, const char* record) {
4077         LDKLogger_JCalls *j_calls = (LDKLogger_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         const char* record_str = record;
4086         jstring record_conv = str_ref_to_java(env, record_str, strlen(record_str));
4087         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4088         CHECK(obj != NULL);
4089         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_conv);
4090         if ((*env)->ExceptionCheck(env)) {
4091                 (*env)->ExceptionDescribe(env);
4092                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4093         }
4094         if (get_jenv_res == JNI_EDETACHED) {
4095                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4096         }
4097 }
4098 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4099         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4100         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4101 }
4102 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4103         jclass c = (*env)->GetObjectClass(env, o);
4104         CHECK(c != NULL);
4105         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_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->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
4110         CHECK(calls->log_meth != NULL);
4111
4112         LDKLogger ret = {
4113                 .this_arg = (void*) calls,
4114                 .log = log_LDKLogger_jcall,
4115                 .free = LDKLogger_JCalls_free,
4116         };
4117         return ret;
4118 }
4119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4120         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4121         *res_ptr = LDKLogger_init(env, clz, o);
4122         return (uint64_t)res_ptr;
4123 }
4124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
4125         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4126         LDKThirtyTwoBytes a_ref;
4127         CHECK((*env)->GetArrayLength(env, a) == 32);
4128         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4129         ret->a = a_ref;
4130         LDKChannelManager b_conv;
4131         b_conv.inner = (void*)(b & (~1));
4132         b_conv.is_owned = (b & 1) || (b == 0);
4133         // Warning: we need a move here but no clone is available for LDKChannelManager
4134         ret->b = b_conv;
4135         return (uint64_t)ret;
4136 }
4137 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4138         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4139         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4140         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4141         return a_arr;
4142 }
4143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4144         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
4145         LDKChannelManager b_var = tuple->b;
4146         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4147         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4148         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4149         return b_ref;
4150 }
4151 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4152         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
4153 }
4154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4155         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4156         CHECK(val->result_ok);
4157         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4158         return res_ref;
4159 }
4160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4161         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4162         CHECK(!val->result_ok);
4163         LDKDecodeError err_var = (*val->contents.err);
4164         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4165         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4166         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4167         return err_ref;
4168 }
4169 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4170         return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
4171 }
4172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4173         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4174         CHECK(val->result_ok);
4175         LDKChannelConfig res_var = (*val->contents.result);
4176         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4177         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4178         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4179         return res_ref;
4180 }
4181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4182         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4183         CHECK(!val->result_ok);
4184         LDKDecodeError err_var = (*val->contents.err);
4185         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4186         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4187         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4188         return err_ref;
4189 }
4190 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4191         return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
4192 }
4193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4194         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4195         CHECK(val->result_ok);
4196         LDKOutPoint res_var = (*val->contents.result);
4197         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4198         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4199         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4200         return res_ref;
4201 }
4202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4203         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4204         CHECK(!val->result_ok);
4205         LDKDecodeError err_var = (*val->contents.err);
4206         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4207         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4208         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4209         return err_ref;
4210 }
4211 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4212         return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
4213 }
4214 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4215         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4216         CHECK(val->result_ok);
4217         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
4218         return res_conv;
4219 }
4220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4221         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
4222         CHECK(!val->result_ok);
4223         return *val->contents.err;
4224 }
4225 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4226         return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
4227 }
4228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4229         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4230         CHECK(val->result_ok);
4231         LDKInvoice res_var = (*val->contents.result);
4232         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4233         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4234         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4235         return res_ref;
4236 }
4237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4238         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
4239         CHECK(!val->result_ok);
4240         return *val->contents.err;
4241 }
4242 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4243         return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
4244 }
4245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4246         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4247         CHECK(val->result_ok);
4248         LDKSignedRawInvoice res_var = (*val->contents.result);
4249         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4250         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4251         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4252         return res_ref;
4253 }
4254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4255         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
4256         CHECK(!val->result_ok);
4257         return *val->contents.err;
4258 }
4259 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) {
4260         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
4261         LDKRawInvoice a_conv;
4262         a_conv.inner = (void*)(a & (~1));
4263         a_conv.is_owned = (a & 1) || (a == 0);
4264         a_conv = RawInvoice_clone(&a_conv);
4265         ret->a = a_conv;
4266         LDKThirtyTwoBytes b_ref;
4267         CHECK((*env)->GetArrayLength(env, b) == 32);
4268         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
4269         ret->b = b_ref;
4270         LDKInvoiceSignature c_conv;
4271         c_conv.inner = (void*)(c & (~1));
4272         c_conv.is_owned = (c & 1) || (c == 0);
4273         c_conv = InvoiceSignature_clone(&c_conv);
4274         ret->c = c_conv;
4275         return (uint64_t)ret;
4276 }
4277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4278         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4279         LDKRawInvoice a_var = tuple->a;
4280         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4281         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4282         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4283         return a_ref;
4284 }
4285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4286         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4287         int8_tArray b_arr = (*env)->NewByteArray(env, 32);
4288         (*env)->SetByteArrayRegion(env, b_arr, 0, 32, tuple->b.data);
4289         return b_arr;
4290 }
4291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4292         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *tuple = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(ptr & ~1);
4293         LDKInvoiceSignature c_var = tuple->c;
4294         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4295         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4296         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4297         return c_ref;
4298 }
4299 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4300         return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
4301 }
4302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4303         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4304         CHECK(val->result_ok);
4305         LDKPayeePubKey res_var = (*val->contents.result);
4306         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4307         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4308         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4309         return res_ref;
4310 }
4311 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4312         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
4313         CHECK(!val->result_ok);
4314         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4315         return err_conv;
4316 }
4317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1PrivateRouteZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4318         LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
4319         ret->datalen = (*env)->GetArrayLength(env, elems);
4320         if (ret->datalen == 0) {
4321                 ret->data = NULL;
4322         } else {
4323                 ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
4324                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4325                 for (size_t i = 0; i < ret->datalen; i++) {
4326                         int64_t arr_elem = java_elems[i];
4327                         LDKPrivateRoute arr_elem_conv;
4328                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
4329                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
4330                         arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
4331                         ret->data[i] = arr_elem_conv;
4332                 }
4333                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4334         }
4335         return (uint64_t)ret;
4336 }
4337 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
4338         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
4339         for (size_t i = 0; i < ret.datalen; i++) {
4340                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
4341         }
4342         return ret;
4343 }
4344 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4345         return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
4346 }
4347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4348         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4349         CHECK(val->result_ok);
4350         LDKPositiveTimestamp res_var = (*val->contents.result);
4351         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4352         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4353         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4354         return res_ref;
4355 }
4356 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4357         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
4358         CHECK(!val->result_ok);
4359         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4360         return err_conv;
4361 }
4362 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4363         return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
4364 }
4365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4366         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4367         CHECK(val->result_ok);
4368         return *val->contents.result;
4369 }
4370 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4371         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
4372         CHECK(!val->result_ok);
4373         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4374         return err_conv;
4375 }
4376 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4377         return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
4378 }
4379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4380         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4381         CHECK(val->result_ok);
4382         LDKInvoice res_var = (*val->contents.result);
4383         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4384         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4385         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4386         return res_ref;
4387 }
4388 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4389         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
4390         CHECK(!val->result_ok);
4391         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
4392         return err_conv;
4393 }
4394 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4395         return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
4396 }
4397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4398         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4399         CHECK(val->result_ok);
4400         LDKDescription res_var = (*val->contents.result);
4401         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4402         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4403         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4404         return res_ref;
4405 }
4406 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4407         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
4408         CHECK(!val->result_ok);
4409         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4410         return err_conv;
4411 }
4412 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4413         return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
4414 }
4415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4416         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4417         CHECK(val->result_ok);
4418         LDKExpiryTime res_var = (*val->contents.result);
4419         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4420         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4421         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4422         return res_ref;
4423 }
4424 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4425         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
4426         CHECK(!val->result_ok);
4427         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4428         return err_conv;
4429 }
4430 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4431         return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
4432 }
4433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4434         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4435         CHECK(val->result_ok);
4436         LDKPrivateRoute res_var = (*val->contents.result);
4437         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4438         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4439         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4440         return res_ref;
4441 }
4442 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4443         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
4444         CHECK(!val->result_ok);
4445         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
4446         return err_conv;
4447 }
4448 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4449         return ((LDKCResult_StringErrorZ*)arg)->result_ok;
4450 }
4451 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4452         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4453         CHECK(val->result_ok);
4454         LDKStr res_str = (*val->contents.result);
4455         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
4456         return res_conv;
4457 }
4458 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4459         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
4460         CHECK(!val->result_ok);
4461         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
4462         return err_conv;
4463 }
4464 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4465         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
4466 }
4467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4468         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4469         CHECK(val->result_ok);
4470         LDKChannelMonitorUpdate res_var = (*val->contents.result);
4471         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4472         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4473         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4474         return res_ref;
4475 }
4476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4477         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
4478         CHECK(!val->result_ok);
4479         LDKDecodeError err_var = (*val->contents.err);
4480         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4481         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4482         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4483         return err_ref;
4484 }
4485 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4486         return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
4487 }
4488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4489         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4490         CHECK(val->result_ok);
4491         LDKHTLCUpdate res_var = (*val->contents.result);
4492         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4493         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4494         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
4495         return res_ref;
4496 }
4497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4498         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
4499         CHECK(!val->result_ok);
4500         LDKDecodeError err_var = (*val->contents.err);
4501         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4502         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4503         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4504         return err_ref;
4505 }
4506 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4507         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
4508 }
4509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4510         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4511         CHECK(val->result_ok);
4512         return *val->contents.result;
4513 }
4514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4515         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
4516         CHECK(!val->result_ok);
4517         LDKMonitorUpdateError err_var = (*val->contents.err);
4518         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4519         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4520         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4521         return err_ref;
4522 }
4523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
4524         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4525         LDKOutPoint a_conv;
4526         a_conv.inner = (void*)(a & (~1));
4527         a_conv.is_owned = (a & 1) || (a == 0);
4528         a_conv = OutPoint_clone(&a_conv);
4529         ret->a = a_conv;
4530         LDKCVec_u8Z b_ref;
4531         b_ref.datalen = (*env)->GetArrayLength(env, b);
4532         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4533         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4534         ret->b = b_ref;
4535         return (uint64_t)ret;
4536 }
4537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4538         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4539         LDKOutPoint a_var = tuple->a;
4540         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4541         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4542         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4543         return a_ref;
4544 }
4545 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4546         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
4547         LDKCVec_u8Z b_var = tuple->b;
4548         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4549         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4550         return b_arr;
4551 }
4552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
4553         LDKC2Tuple_u32ScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
4554         ret->a = a;
4555         LDKCVec_u8Z b_ref;
4556         b_ref.datalen = (*env)->GetArrayLength(env, b);
4557         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4558         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
4559         ret->b = b_ref;
4560         return (uint64_t)ret;
4561 }
4562 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4563         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4564         return tuple->a;
4565 }
4566 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4567         LDKC2Tuple_u32ScriptZ *tuple = (LDKC2Tuple_u32ScriptZ*)(ptr & ~1);
4568         LDKCVec_u8Z b_var = tuple->b;
4569         int8_tArray b_arr = (*env)->NewByteArray(env, b_var.datalen);
4570         (*env)->SetByteArrayRegion(env, b_arr, 0, b_var.datalen, b_var.data);
4571         return b_arr;
4572 }
4573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32ScriptZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4574         LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
4575         ret->datalen = (*env)->GetArrayLength(env, elems);
4576         if (ret->datalen == 0) {
4577                 ret->data = NULL;
4578         } else {
4579                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
4580                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4581                 for (size_t i = 0; i < ret->datalen; i++) {
4582                         int64_t arr_elem = java_elems[i];
4583                         LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1);
4584                         arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
4585                         ret->data[i] = arr_elem_conv;
4586                 }
4587                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4588         }
4589         return (uint64_t)ret;
4590 }
4591 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
4592         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
4593         for (size_t i = 0; i < ret.datalen; i++) {
4594                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
4595         }
4596         return ret;
4597 }
4598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4599         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
4600         LDKThirtyTwoBytes a_ref;
4601         CHECK((*env)->GetArrayLength(env, a) == 32);
4602         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4603         ret->a = a_ref;
4604         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
4605         b_constr.datalen = (*env)->GetArrayLength(env, b);
4606         if (b_constr.datalen > 0)
4607                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
4608         else
4609                 b_constr.data = NULL;
4610         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4611         for (size_t b = 0; b < b_constr.datalen; b++) {
4612                 int64_t b_conv_27 = b_vals[b];
4613                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
4614                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
4615                 b_constr.data[b] = b_conv_27_conv;
4616         }
4617         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4618         ret->b = b_constr;
4619         return (uint64_t)ret;
4620 }
4621 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4622         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4623         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4624         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4625         return a_arr;
4626 }
4627 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4628         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(ptr & ~1);
4629         LDKCVec_C2Tuple_u32ScriptZZ b_var = tuple->b;
4630         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4631         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4632         for (size_t b = 0; b < b_var.datalen; b++) {
4633                 uint64_t b_conv_27_ref = (uint64_t)(&b_var.data[b]) | 1;
4634                 b_arr_ptr[b] = b_conv_27_ref;
4635         }
4636         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4637         return b_arr;
4638 }
4639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4640         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
4641         ret->datalen = (*env)->GetArrayLength(env, elems);
4642         if (ret->datalen == 0) {
4643                 ret->data = NULL;
4644         } else {
4645                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
4646                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4647                 for (size_t i = 0; i < ret->datalen; i++) {
4648                         int64_t arr_elem = java_elems[i];
4649                         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1);
4650                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
4651                         ret->data[i] = arr_elem_conv;
4652                 }
4653                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4654         }
4655         return (uint64_t)ret;
4656 }
4657 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
4658         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 };
4659         for (size_t i = 0; i < ret.datalen; i++) {
4660                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
4661         }
4662         return ret;
4663 }
4664 static jclass LDKEvent_FundingGenerationReady_class = NULL;
4665 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
4666 static jclass LDKEvent_PaymentReceived_class = NULL;
4667 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
4668 static jclass LDKEvent_PaymentSent_class = NULL;
4669 static jmethodID LDKEvent_PaymentSent_meth = NULL;
4670 static jclass LDKEvent_PaymentFailed_class = NULL;
4671 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
4672 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
4673 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
4674 static jclass LDKEvent_SpendableOutputs_class = NULL;
4675 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
4676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
4677         LDKEvent_FundingGenerationReady_class =
4678                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
4679         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
4680         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
4681         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
4682         LDKEvent_PaymentReceived_class =
4683                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
4684         CHECK(LDKEvent_PaymentReceived_class != NULL);
4685         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([B[B[BJJ)V");
4686         CHECK(LDKEvent_PaymentReceived_meth != NULL);
4687         LDKEvent_PaymentSent_class =
4688                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
4689         CHECK(LDKEvent_PaymentSent_class != NULL);
4690         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B)V");
4691         CHECK(LDKEvent_PaymentSent_meth != NULL);
4692         LDKEvent_PaymentFailed_class =
4693                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentFailed;"));
4694         CHECK(LDKEvent_PaymentFailed_class != NULL);
4695         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([BZ)V");
4696         CHECK(LDKEvent_PaymentFailed_meth != NULL);
4697         LDKEvent_PendingHTLCsForwardable_class =
4698                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
4699         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
4700         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
4701         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
4702         LDKEvent_SpendableOutputs_class =
4703                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
4704         CHECK(LDKEvent_SpendableOutputs_class != NULL);
4705         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
4706         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
4707 }
4708 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4709         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
4710         switch(obj->tag) {
4711                 case LDKEvent_FundingGenerationReady: {
4712                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
4713                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
4714                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
4715                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
4716                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
4717                         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);
4718                 }
4719                 case LDKEvent_PaymentReceived: {
4720                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4721                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
4722                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4723                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_received.payment_preimage.data);
4724                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
4725                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->payment_received.payment_secret.data);
4726                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, payment_preimage_arr, payment_secret_arr, obj->payment_received.amt, obj->payment_received.user_payment_id);
4727                 }
4728                 case LDKEvent_PaymentSent: {
4729                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
4730                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
4731                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_preimage_arr);
4732                 }
4733                 case LDKEvent_PaymentFailed: {
4734                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
4735                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
4736                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_hash_arr, obj->payment_failed.rejected_by_dest);
4737                 }
4738                 case LDKEvent_PendingHTLCsForwardable: {
4739                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
4740                 }
4741                 case LDKEvent_SpendableOutputs: {
4742                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
4743                         int64_tArray outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
4744                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
4745                         for (size_t b = 0; b < outputs_var.datalen; b++) {
4746                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
4747                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
4748                         }
4749                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
4750                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
4751                 }
4752                 default: abort();
4753         }
4754 }
4755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1EventZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4756         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
4757         ret->datalen = (*env)->GetArrayLength(env, elems);
4758         if (ret->datalen == 0) {
4759                 ret->data = NULL;
4760         } else {
4761                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
4762                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4763                 for (size_t i = 0; i < ret->datalen; i++) {
4764                         int64_t arr_elem = java_elems[i];
4765                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
4766                         arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
4767                         ret->data[i] = arr_elem_conv;
4768                 }
4769                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4770         }
4771         return (uint64_t)ret;
4772 }
4773 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
4774         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
4775         for (size_t i = 0; i < ret.datalen; i++) {
4776                 ret.data[i] = Event_clone(&orig->data[i]);
4777         }
4778         return ret;
4779 }
4780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
4781         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4782         ret->a = a;
4783         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
4784         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
4785         ret->b = b_conv;
4786         return (uint64_t)ret;
4787 }
4788 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4789         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4790         return tuple->a;
4791 }
4792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4793         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
4794         uint64_t b_ref = ((uint64_t)&tuple->b) | 1;
4795         return (uint64_t)b_ref;
4796 }
4797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1u32TxOutZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4798         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
4799         ret->datalen = (*env)->GetArrayLength(env, elems);
4800         if (ret->datalen == 0) {
4801                 ret->data = NULL;
4802         } else {
4803                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
4804                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4805                 for (size_t i = 0; i < ret->datalen; i++) {
4806                         int64_t arr_elem = java_elems[i];
4807                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
4808                         arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
4809                         ret->data[i] = arr_elem_conv;
4810                 }
4811                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4812         }
4813         return (uint64_t)ret;
4814 }
4815 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
4816         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
4817         for (size_t i = 0; i < ret.datalen; i++) {
4818                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
4819         }
4820         return ret;
4821 }
4822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
4823         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4824         LDKThirtyTwoBytes a_ref;
4825         CHECK((*env)->GetArrayLength(env, a) == 32);
4826         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
4827         ret->a = a_ref;
4828         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4829         b_constr.datalen = (*env)->GetArrayLength(env, b);
4830         if (b_constr.datalen > 0)
4831                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4832         else
4833                 b_constr.data = NULL;
4834         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
4835         for (size_t a = 0; a < b_constr.datalen; a++) {
4836                 int64_t b_conv_26 = b_vals[a];
4837                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
4838                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
4839                 b_constr.data[a] = b_conv_26_conv;
4840         }
4841         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
4842         ret->b = b_constr;
4843         return (uint64_t)ret;
4844 }
4845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4846         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4847         int8_tArray a_arr = (*env)->NewByteArray(env, 32);
4848         (*env)->SetByteArrayRegion(env, a_arr, 0, 32, tuple->a.data);
4849         return a_arr;
4850 }
4851 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4852         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
4853         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
4854         int64_tArray b_arr = (*env)->NewLongArray(env, b_var.datalen);
4855         int64_t *b_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, b_arr, NULL);
4856         for (size_t a = 0; a < b_var.datalen; a++) {
4857                 uint64_t b_conv_26_ref = (uint64_t)(&b_var.data[a]) | 1;
4858                 b_arr_ptr[a] = b_conv_26_ref;
4859         }
4860         (*env)->ReleasePrimitiveArrayCritical(env, b_arr, b_arr_ptr, 0);
4861         return b_arr;
4862 }
4863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4864         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
4865         ret->datalen = (*env)->GetArrayLength(env, elems);
4866         if (ret->datalen == 0) {
4867                 ret->data = NULL;
4868         } else {
4869                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
4870                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4871                 for (size_t i = 0; i < ret->datalen; i++) {
4872                         int64_t arr_elem = java_elems[i];
4873                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
4874                         arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
4875                         ret->data[i] = arr_elem_conv;
4876                 }
4877                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4878         }
4879         return (uint64_t)ret;
4880 }
4881 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
4882         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 };
4883         for (size_t i = 0; i < ret.datalen; i++) {
4884                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
4885         }
4886         return ret;
4887 }
4888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4889         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
4890 }
4891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4892         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4893         CHECK(val->result_ok);
4894         uint64_t res_ref = (uint64_t)(&(*val->contents.result)) | 1;
4895         return res_ref;
4896 }
4897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4898         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4899         CHECK(!val->result_ok);
4900         LDKDecodeError err_var = (*val->contents.err);
4901         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4902         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4903         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4904         return err_ref;
4905 }
4906 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4907         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
4908 }
4909 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4910         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4911         CHECK(val->result_ok);
4912         return *val->contents.result;
4913 }
4914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4915         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4916         CHECK(!val->result_ok);
4917         LDKLightningError err_var = (*val->contents.err);
4918         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4919         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4920         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
4921         return err_ref;
4922 }
4923 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) {
4924         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4925         LDKChannelAnnouncement a_conv;
4926         a_conv.inner = (void*)(a & (~1));
4927         a_conv.is_owned = (a & 1) || (a == 0);
4928         a_conv = ChannelAnnouncement_clone(&a_conv);
4929         ret->a = a_conv;
4930         LDKChannelUpdate b_conv;
4931         b_conv.inner = (void*)(b & (~1));
4932         b_conv.is_owned = (b & 1) || (b == 0);
4933         b_conv = ChannelUpdate_clone(&b_conv);
4934         ret->b = b_conv;
4935         LDKChannelUpdate c_conv;
4936         c_conv.inner = (void*)(c & (~1));
4937         c_conv.is_owned = (c & 1) || (c == 0);
4938         c_conv = ChannelUpdate_clone(&c_conv);
4939         ret->c = c_conv;
4940         return (uint64_t)ret;
4941 }
4942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t ptr) {
4943         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4944         LDKChannelAnnouncement a_var = tuple->a;
4945         CHECK((((uint64_t)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4946         CHECK((((uint64_t)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4947         uint64_t a_ref = (uint64_t)a_var.inner & ~1;
4948         return a_ref;
4949 }
4950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t ptr) {
4951         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4952         LDKChannelUpdate b_var = tuple->b;
4953         CHECK((((uint64_t)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4954         CHECK((((uint64_t)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4955         uint64_t b_ref = (uint64_t)b_var.inner & ~1;
4956         return b_ref;
4957 }
4958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t ptr) {
4959         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
4960         LDKChannelUpdate c_var = tuple->c;
4961         CHECK((((uint64_t)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4962         CHECK((((uint64_t)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4963         uint64_t c_ref = (uint64_t)c_var.inner & ~1;
4964         return c_ref;
4965 }
4966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4967         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
4968         ret->datalen = (*env)->GetArrayLength(env, elems);
4969         if (ret->datalen == 0) {
4970                 ret->data = NULL;
4971         } else {
4972                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
4973                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4974                 for (size_t i = 0; i < ret->datalen; i++) {
4975                         int64_t arr_elem = java_elems[i];
4976                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
4977                         arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
4978                         ret->data[i] = arr_elem_conv;
4979                 }
4980                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
4981         }
4982         return (uint64_t)ret;
4983 }
4984 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4985         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4986         for (size_t i = 0; i < ret.datalen; i++) {
4987                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4988         }
4989         return ret;
4990 }
4991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1NodeAnnouncementZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
4992         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
4993         ret->datalen = (*env)->GetArrayLength(env, elems);
4994         if (ret->datalen == 0) {
4995                 ret->data = NULL;
4996         } else {
4997                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
4998                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
4999                 for (size_t i = 0; i < ret->datalen; i++) {
5000                         int64_t arr_elem = java_elems[i];
5001                         LDKNodeAnnouncement arr_elem_conv;
5002                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5003                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5004                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
5005                         ret->data[i] = arr_elem_conv;
5006                 }
5007                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5008         }
5009         return (uint64_t)ret;
5010 }
5011 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5012         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5013         for (size_t i = 0; i < ret.datalen; i++) {
5014                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5015         }
5016         return ret;
5017 }
5018 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5019         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
5020 }
5021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5022         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5023         CHECK(val->result_ok);
5024         return *val->contents.result;
5025 }
5026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5027         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5028         CHECK(!val->result_ok);
5029         LDKLightningError err_var = (*val->contents.err);
5030         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5031         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5032         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5033         return err_ref;
5034 }
5035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5036         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
5037 }
5038 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5039         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5040         CHECK(val->result_ok);
5041         LDKCVec_u8Z res_var = (*val->contents.result);
5042         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
5043         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
5044         return res_arr;
5045 }
5046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5047         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5048         CHECK(!val->result_ok);
5049         LDKPeerHandleError err_var = (*val->contents.err);
5050         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5051         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5052         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5053         return err_ref;
5054 }
5055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5056         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
5057 }
5058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5059         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5060         CHECK(val->result_ok);
5061         return *val->contents.result;
5062 }
5063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5064         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5065         CHECK(!val->result_ok);
5066         LDKPeerHandleError err_var = (*val->contents.err);
5067         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5068         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5069         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5070         return err_ref;
5071 }
5072 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5073         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
5074 }
5075 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5076         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5077         CHECK(val->result_ok);
5078         return *val->contents.result;
5079 }
5080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5081         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5082         CHECK(!val->result_ok);
5083         LDKPeerHandleError err_var = (*val->contents.err);
5084         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5085         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5086         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5087         return err_ref;
5088 }
5089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5090         return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
5091 }
5092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5093         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5094         CHECK(val->result_ok);
5095         LDKDirectionalChannelInfo res_var = (*val->contents.result);
5096         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5097         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5098         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5099         return res_ref;
5100 }
5101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5102         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
5103         CHECK(!val->result_ok);
5104         LDKDecodeError err_var = (*val->contents.err);
5105         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5106         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5107         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5108         return err_ref;
5109 }
5110 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5111         return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
5112 }
5113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5114         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5115         CHECK(val->result_ok);
5116         LDKChannelInfo res_var = (*val->contents.result);
5117         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5118         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5119         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5120         return res_ref;
5121 }
5122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5123         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
5124         CHECK(!val->result_ok);
5125         LDKDecodeError err_var = (*val->contents.err);
5126         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5127         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5128         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5129         return err_ref;
5130 }
5131 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5132         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
5133 }
5134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5135         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5136         CHECK(val->result_ok);
5137         LDKRoutingFees res_var = (*val->contents.result);
5138         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5139         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5140         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5141         return res_ref;
5142 }
5143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5144         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
5145         CHECK(!val->result_ok);
5146         LDKDecodeError err_var = (*val->contents.err);
5147         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5148         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5149         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5150         return err_ref;
5151 }
5152 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5153         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
5154 }
5155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5156         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5157         CHECK(val->result_ok);
5158         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
5159         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5160         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5161         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5162         return res_ref;
5163 }
5164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5165         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
5166         CHECK(!val->result_ok);
5167         LDKDecodeError err_var = (*val->contents.err);
5168         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5169         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5170         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5171         return err_ref;
5172 }
5173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1u64Z_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5174         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
5175         ret->datalen = (*env)->GetArrayLength(env, elems);
5176         if (ret->datalen == 0) {
5177                 ret->data = NULL;
5178         } else {
5179                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
5180                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5181                 for (size_t i = 0; i < ret->datalen; i++) {
5182                         ret->data[i] = java_elems[i];
5183                 }
5184                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5185         }
5186         return (uint64_t)ret;
5187 }
5188 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
5189         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
5190         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
5191         return ret;
5192 }
5193 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5194         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
5195 }
5196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5197         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5198         CHECK(val->result_ok);
5199         LDKNodeInfo res_var = (*val->contents.result);
5200         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5201         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5202         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5203         return res_ref;
5204 }
5205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5206         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
5207         CHECK(!val->result_ok);
5208         LDKDecodeError err_var = (*val->contents.err);
5209         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5210         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5211         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5212         return err_ref;
5213 }
5214 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5215         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
5216 }
5217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5218         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5219         CHECK(val->result_ok);
5220         LDKNetworkGraph res_var = (*val->contents.result);
5221         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5222         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5223         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5224         return res_ref;
5225 }
5226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5227         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
5228         CHECK(!val->result_ok);
5229         LDKDecodeError err_var = (*val->contents.err);
5230         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5231         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5232         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5233         return err_ref;
5234 }
5235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5236         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
5237 }
5238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5239         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5240         CHECK(val->result_ok);
5241         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5242         return res_ref;
5243 }
5244 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressu8Z_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5245         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
5246         CHECK(!val->result_ok);
5247         return *val->contents.err;
5248 }
5249 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5250         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
5251 }
5252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5253         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5254         CHECK(val->result_ok);
5255         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5256         *res_conv = (*val->contents.result);
5257         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
5258         return (uint64_t)res_conv;
5259 }
5260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5261         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
5262         CHECK(!val->result_ok);
5263         LDKDecodeError err_var = (*val->contents.err);
5264         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5265         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5266         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5267         return err_ref;
5268 }
5269 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5270         return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
5271 }
5272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5273         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5274         CHECK(val->result_ok);
5275         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5276         return res_ref;
5277 }
5278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5279         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
5280         CHECK(!val->result_ok);
5281         LDKDecodeError err_var = (*val->contents.err);
5282         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5283         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5284         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5285         return err_ref;
5286 }
5287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateAddHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5288         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
5289         ret->datalen = (*env)->GetArrayLength(env, elems);
5290         if (ret->datalen == 0) {
5291                 ret->data = NULL;
5292         } else {
5293                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
5294                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5295                 for (size_t i = 0; i < ret->datalen; i++) {
5296                         int64_t arr_elem = java_elems[i];
5297                         LDKUpdateAddHTLC arr_elem_conv;
5298                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5299                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5300                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
5301                         ret->data[i] = arr_elem_conv;
5302                 }
5303                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5304         }
5305         return (uint64_t)ret;
5306 }
5307 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
5308         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
5309         for (size_t i = 0; i < ret.datalen; i++) {
5310                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
5311         }
5312         return ret;
5313 }
5314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFulfillHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5315         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
5316         ret->datalen = (*env)->GetArrayLength(env, elems);
5317         if (ret->datalen == 0) {
5318                 ret->data = NULL;
5319         } else {
5320                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
5321                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5322                 for (size_t i = 0; i < ret->datalen; i++) {
5323                         int64_t arr_elem = java_elems[i];
5324                         LDKUpdateFulfillHTLC arr_elem_conv;
5325                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5326                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5327                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
5328                         ret->data[i] = arr_elem_conv;
5329                 }
5330                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5331         }
5332         return (uint64_t)ret;
5333 }
5334 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
5335         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
5336         for (size_t i = 0; i < ret.datalen; i++) {
5337                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
5338         }
5339         return ret;
5340 }
5341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5342         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
5343         ret->datalen = (*env)->GetArrayLength(env, elems);
5344         if (ret->datalen == 0) {
5345                 ret->data = NULL;
5346         } else {
5347                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
5348                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5349                 for (size_t i = 0; i < ret->datalen; i++) {
5350                         int64_t arr_elem = java_elems[i];
5351                         LDKUpdateFailHTLC arr_elem_conv;
5352                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5353                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5354                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
5355                         ret->data[i] = arr_elem_conv;
5356                 }
5357                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5358         }
5359         return (uint64_t)ret;
5360 }
5361 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
5362         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
5363         for (size_t i = 0; i < ret.datalen; i++) {
5364                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
5365         }
5366         return ret;
5367 }
5368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCVec_1UpdateFailMalformedHTLCZ_1new(JNIEnv *env, jclass clz, int64_tArray elems) {
5369         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
5370         ret->datalen = (*env)->GetArrayLength(env, elems);
5371         if (ret->datalen == 0) {
5372                 ret->data = NULL;
5373         } else {
5374                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
5375                 int64_t *java_elems = (*env)->GetPrimitiveArrayCritical(env, elems, NULL);
5376                 for (size_t i = 0; i < ret->datalen; i++) {
5377                         int64_t arr_elem = java_elems[i];
5378                         LDKUpdateFailMalformedHTLC arr_elem_conv;
5379                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
5380                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
5381                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
5382                         ret->data[i] = arr_elem_conv;
5383                 }
5384                 (*env)->ReleasePrimitiveArrayCritical(env, elems, java_elems, 0);
5385         }
5386         return (uint64_t)ret;
5387 }
5388 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
5389         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
5390         for (size_t i = 0; i < ret.datalen; i++) {
5391                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
5392         }
5393         return ret;
5394 }
5395 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5396         return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
5397 }
5398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5399         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5400         CHECK(val->result_ok);
5401         LDKAcceptChannel res_var = (*val->contents.result);
5402         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5403         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5404         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5405         return res_ref;
5406 }
5407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5408         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
5409         CHECK(!val->result_ok);
5410         LDKDecodeError err_var = (*val->contents.err);
5411         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5412         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5413         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5414         return err_ref;
5415 }
5416 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5417         return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
5418 }
5419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5420         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5421         CHECK(val->result_ok);
5422         LDKAnnouncementSignatures res_var = (*val->contents.result);
5423         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5424         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5425         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5426         return res_ref;
5427 }
5428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5429         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
5430         CHECK(!val->result_ok);
5431         LDKDecodeError err_var = (*val->contents.err);
5432         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5433         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5434         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5435         return err_ref;
5436 }
5437 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5438         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
5439 }
5440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5441         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5442         CHECK(val->result_ok);
5443         LDKChannelReestablish res_var = (*val->contents.result);
5444         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5445         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5446         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5447         return res_ref;
5448 }
5449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5450         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
5451         CHECK(!val->result_ok);
5452         LDKDecodeError err_var = (*val->contents.err);
5453         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5454         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5455         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5456         return err_ref;
5457 }
5458 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5459         return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
5460 }
5461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5462         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5463         CHECK(val->result_ok);
5464         LDKClosingSigned res_var = (*val->contents.result);
5465         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5466         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5467         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5468         return res_ref;
5469 }
5470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5471         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
5472         CHECK(!val->result_ok);
5473         LDKDecodeError err_var = (*val->contents.err);
5474         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5475         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5476         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5477         return err_ref;
5478 }
5479 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5480         return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
5481 }
5482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5483         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5484         CHECK(val->result_ok);
5485         LDKCommitmentSigned res_var = (*val->contents.result);
5486         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5487         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5488         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5489         return res_ref;
5490 }
5491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5492         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
5493         CHECK(!val->result_ok);
5494         LDKDecodeError err_var = (*val->contents.err);
5495         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5496         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5497         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5498         return err_ref;
5499 }
5500 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5501         return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
5502 }
5503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5504         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5505         CHECK(val->result_ok);
5506         LDKFundingCreated res_var = (*val->contents.result);
5507         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5508         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5509         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5510         return res_ref;
5511 }
5512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5513         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
5514         CHECK(!val->result_ok);
5515         LDKDecodeError err_var = (*val->contents.err);
5516         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5517         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5518         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5519         return err_ref;
5520 }
5521 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5522         return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
5523 }
5524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5525         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5526         CHECK(val->result_ok);
5527         LDKFundingSigned res_var = (*val->contents.result);
5528         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5529         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5530         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5531         return res_ref;
5532 }
5533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5534         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
5535         CHECK(!val->result_ok);
5536         LDKDecodeError err_var = (*val->contents.err);
5537         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5538         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5539         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5540         return err_ref;
5541 }
5542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5543         return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
5544 }
5545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5546         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5547         CHECK(val->result_ok);
5548         LDKFundingLocked res_var = (*val->contents.result);
5549         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5550         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5551         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5552         return res_ref;
5553 }
5554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5555         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
5556         CHECK(!val->result_ok);
5557         LDKDecodeError err_var = (*val->contents.err);
5558         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5559         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5560         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5561         return err_ref;
5562 }
5563 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5564         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
5565 }
5566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5567         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5568         CHECK(val->result_ok);
5569         LDKInit res_var = (*val->contents.result);
5570         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5571         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5572         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5573         return res_ref;
5574 }
5575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5576         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
5577         CHECK(!val->result_ok);
5578         LDKDecodeError err_var = (*val->contents.err);
5579         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5580         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5581         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5582         return err_ref;
5583 }
5584 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5585         return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
5586 }
5587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5588         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5589         CHECK(val->result_ok);
5590         LDKOpenChannel res_var = (*val->contents.result);
5591         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5592         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5593         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5594         return res_ref;
5595 }
5596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5597         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
5598         CHECK(!val->result_ok);
5599         LDKDecodeError err_var = (*val->contents.err);
5600         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5601         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5602         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5603         return err_ref;
5604 }
5605 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5606         return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
5607 }
5608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5609         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5610         CHECK(val->result_ok);
5611         LDKRevokeAndACK res_var = (*val->contents.result);
5612         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5613         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5614         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5615         return res_ref;
5616 }
5617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5618         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
5619         CHECK(!val->result_ok);
5620         LDKDecodeError err_var = (*val->contents.err);
5621         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5622         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5623         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5624         return err_ref;
5625 }
5626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5627         return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
5628 }
5629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5630         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5631         CHECK(val->result_ok);
5632         LDKShutdown res_var = (*val->contents.result);
5633         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5634         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5635         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5636         return res_ref;
5637 }
5638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5639         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
5640         CHECK(!val->result_ok);
5641         LDKDecodeError err_var = (*val->contents.err);
5642         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5643         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5644         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5645         return err_ref;
5646 }
5647 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5648         return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
5649 }
5650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5651         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5652         CHECK(val->result_ok);
5653         LDKUpdateFailHTLC res_var = (*val->contents.result);
5654         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5655         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5656         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5657         return res_ref;
5658 }
5659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5660         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
5661         CHECK(!val->result_ok);
5662         LDKDecodeError err_var = (*val->contents.err);
5663         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5664         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5665         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5666         return err_ref;
5667 }
5668 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5669         return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
5670 }
5671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5672         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5673         CHECK(val->result_ok);
5674         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
5675         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5676         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5677         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5678         return res_ref;
5679 }
5680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5681         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
5682         CHECK(!val->result_ok);
5683         LDKDecodeError err_var = (*val->contents.err);
5684         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5685         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5686         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5687         return err_ref;
5688 }
5689 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5690         return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
5691 }
5692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5693         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5694         CHECK(val->result_ok);
5695         LDKUpdateFee res_var = (*val->contents.result);
5696         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5697         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5698         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5699         return res_ref;
5700 }
5701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5702         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
5703         CHECK(!val->result_ok);
5704         LDKDecodeError err_var = (*val->contents.err);
5705         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5706         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5707         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5708         return err_ref;
5709 }
5710 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5711         return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
5712 }
5713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5714         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5715         CHECK(val->result_ok);
5716         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5717         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5718         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5719         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5720         return res_ref;
5721 }
5722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5723         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5724         CHECK(!val->result_ok);
5725         LDKDecodeError err_var = (*val->contents.err);
5726         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5727         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5728         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5729         return err_ref;
5730 }
5731 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5732         return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
5733 }
5734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5735         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5736         CHECK(val->result_ok);
5737         LDKUpdateAddHTLC res_var = (*val->contents.result);
5738         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5739         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5740         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5741         return res_ref;
5742 }
5743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5744         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5745         CHECK(!val->result_ok);
5746         LDKDecodeError err_var = (*val->contents.err);
5747         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5748         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5749         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5750         return err_ref;
5751 }
5752 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5753         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
5754 }
5755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5756         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5757         CHECK(val->result_ok);
5758         LDKPing res_var = (*val->contents.result);
5759         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5760         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5761         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5762         return res_ref;
5763 }
5764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5765         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5766         CHECK(!val->result_ok);
5767         LDKDecodeError err_var = (*val->contents.err);
5768         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5769         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5770         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5771         return err_ref;
5772 }
5773 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5774         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
5775 }
5776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5777         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5778         CHECK(val->result_ok);
5779         LDKPong res_var = (*val->contents.result);
5780         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5781         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5782         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5783         return res_ref;
5784 }
5785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5786         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5787         CHECK(!val->result_ok);
5788         LDKDecodeError err_var = (*val->contents.err);
5789         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5790         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5791         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5792         return err_ref;
5793 }
5794 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5795         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5796 }
5797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5798         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5799         CHECK(val->result_ok);
5800         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5801         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5802         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5803         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5804         return res_ref;
5805 }
5806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5807         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5808         CHECK(!val->result_ok);
5809         LDKDecodeError err_var = (*val->contents.err);
5810         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5811         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5812         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5813         return err_ref;
5814 }
5815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5816         return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
5817 }
5818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5819         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5820         CHECK(val->result_ok);
5821         LDKChannelAnnouncement res_var = (*val->contents.result);
5822         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5823         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5824         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5825         return res_ref;
5826 }
5827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5828         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5829         CHECK(!val->result_ok);
5830         LDKDecodeError err_var = (*val->contents.err);
5831         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5832         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5833         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5834         return err_ref;
5835 }
5836 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5837         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
5838 }
5839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5840         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5841         CHECK(val->result_ok);
5842         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5843         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5844         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5845         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5846         return res_ref;
5847 }
5848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5849         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5850         CHECK(!val->result_ok);
5851         LDKDecodeError err_var = (*val->contents.err);
5852         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5853         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5854         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5855         return err_ref;
5856 }
5857 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5858         return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
5859 }
5860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5861         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5862         CHECK(val->result_ok);
5863         LDKChannelUpdate res_var = (*val->contents.result);
5864         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5865         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5866         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5867         return res_ref;
5868 }
5869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5870         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5871         CHECK(!val->result_ok);
5872         LDKDecodeError err_var = (*val->contents.err);
5873         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5874         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5875         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5876         return err_ref;
5877 }
5878 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5879         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
5880 }
5881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5882         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5883         CHECK(val->result_ok);
5884         LDKErrorMessage res_var = (*val->contents.result);
5885         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5886         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5887         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5888         return res_ref;
5889 }
5890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5891         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5892         CHECK(!val->result_ok);
5893         LDKDecodeError err_var = (*val->contents.err);
5894         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5895         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5896         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5897         return err_ref;
5898 }
5899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5900         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5901 }
5902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5903         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5904         CHECK(val->result_ok);
5905         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
5906         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5907         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5908         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5909         return res_ref;
5910 }
5911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5912         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5913         CHECK(!val->result_ok);
5914         LDKDecodeError err_var = (*val->contents.err);
5915         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5916         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5917         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5918         return err_ref;
5919 }
5920 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5921         return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
5922 }
5923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5924         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5925         CHECK(val->result_ok);
5926         LDKNodeAnnouncement res_var = (*val->contents.result);
5927         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5928         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5929         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5930         return res_ref;
5931 }
5932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5933         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5934         CHECK(!val->result_ok);
5935         LDKDecodeError err_var = (*val->contents.err);
5936         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5937         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5938         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5939         return err_ref;
5940 }
5941 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5942         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
5943 }
5944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5945         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5946         CHECK(val->result_ok);
5947         LDKQueryShortChannelIds res_var = (*val->contents.result);
5948         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5949         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5950         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5951         return res_ref;
5952 }
5953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5954         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5955         CHECK(!val->result_ok);
5956         LDKDecodeError err_var = (*val->contents.err);
5957         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5958         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5959         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5960         return err_ref;
5961 }
5962 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5963         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
5964 }
5965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5966         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5967         CHECK(val->result_ok);
5968         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
5969         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5970         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5971         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5972         return res_ref;
5973 }
5974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5975         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5976         CHECK(!val->result_ok);
5977         LDKDecodeError err_var = (*val->contents.err);
5978         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5979         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5980         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
5981         return err_ref;
5982 }
5983 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5984         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
5985 }
5986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5987         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5988         CHECK(val->result_ok);
5989         LDKQueryChannelRange res_var = (*val->contents.result);
5990         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5991         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5992         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
5993         return res_ref;
5994 }
5995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5996         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5997         CHECK(!val->result_ok);
5998         LDKDecodeError err_var = (*val->contents.err);
5999         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6000         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6001         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6002         return err_ref;
6003 }
6004 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6005         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
6006 }
6007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6008         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6009         CHECK(val->result_ok);
6010         LDKReplyChannelRange res_var = (*val->contents.result);
6011         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6012         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6013         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6014         return res_ref;
6015 }
6016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6017         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6018         CHECK(!val->result_ok);
6019         LDKDecodeError err_var = (*val->contents.err);
6020         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6021         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6022         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6023         return err_ref;
6024 }
6025 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6026         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
6027 }
6028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6029         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6030         CHECK(val->result_ok);
6031         LDKGossipTimestampFilter res_var = (*val->contents.result);
6032         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6033         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6034         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6035         return res_ref;
6036 }
6037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6038         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6039         CHECK(!val->result_ok);
6040         LDKDecodeError err_var = (*val->contents.err);
6041         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6042         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6043         uint64_t err_ref = (uint64_t)err_var.inner & ~1;
6044         return err_ref;
6045 }
6046 static jclass LDKSignOrCreationError_SignError_class = NULL;
6047 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
6048 static jclass LDKSignOrCreationError_CreationError_class = NULL;
6049 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
6050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
6051         LDKSignOrCreationError_SignError_class =
6052                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
6053         CHECK(LDKSignOrCreationError_SignError_class != NULL);
6054         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
6055         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
6056         LDKSignOrCreationError_CreationError_class =
6057                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
6058         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
6059         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
6060         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
6061 }
6062 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6063         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
6064         switch(obj->tag) {
6065                 case LDKSignOrCreationError_SignError: {
6066                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
6067                 }
6068                 case LDKSignOrCreationError_CreationError: {
6069                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
6070                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
6071                 }
6072                 default: abort();
6073         }
6074 }
6075 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1result_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6076         return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
6077 }
6078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6079         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6080         CHECK(val->result_ok);
6081         LDKInvoice res_var = (*val->contents.result);
6082         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6083         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6084         uint64_t res_ref = (uint64_t)res_var.inner & ~1;
6085         return res_ref;
6086 }
6087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6088         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
6089         CHECK(!val->result_ok);
6090         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
6091         return err_ref;
6092 }
6093 typedef struct LDKMessageSendEventsProvider_JCalls {
6094         atomic_size_t refcnt;
6095         JavaVM *vm;
6096         jweak o;
6097         jmethodID get_and_clear_pending_msg_events_meth;
6098 } LDKMessageSendEventsProvider_JCalls;
6099 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
6100         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6101         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6102                 JNIEnv *env;
6103                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6104                 if (get_jenv_res == JNI_EDETACHED) {
6105                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6106                 } else {
6107                         DO_ASSERT(get_jenv_res == JNI_OK);
6108                 }
6109                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6110                 if (get_jenv_res == JNI_EDETACHED) {
6111                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6112                 }
6113                 FREE(j_calls);
6114         }
6115 }
6116 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
6117         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6118         JNIEnv *env;
6119         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6120         if (get_jenv_res == JNI_EDETACHED) {
6121                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6122         } else {
6123                 DO_ASSERT(get_jenv_res == JNI_OK);
6124         }
6125         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6126         CHECK(obj != NULL);
6127         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
6128         if ((*env)->ExceptionCheck(env)) {
6129                 (*env)->ExceptionDescribe(env);
6130                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
6131         }
6132         LDKCVec_MessageSendEventZ ret_constr;
6133         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6134         if (ret_constr.datalen > 0)
6135                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
6136         else
6137                 ret_constr.data = NULL;
6138         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6139         for (size_t s = 0; s < ret_constr.datalen; s++) {
6140                 int64_t ret_conv_18 = ret_vals[s];
6141                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1);
6142                 ret_conv_18_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)ret_conv_18) & ~1));
6143                 ret_constr.data[s] = ret_conv_18_conv;
6144         }
6145         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6146         if (get_jenv_res == JNI_EDETACHED) {
6147                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6148         }
6149         return ret_constr;
6150 }
6151 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
6152         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
6153         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6154 }
6155 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6156         jclass c = (*env)->GetObjectClass(env, o);
6157         CHECK(c != NULL);
6158         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
6159         atomic_init(&calls->refcnt, 1);
6160         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6161         calls->o = (*env)->NewWeakGlobalRef(env, o);
6162         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
6163         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
6164
6165         LDKMessageSendEventsProvider ret = {
6166                 .this_arg = (void*) calls,
6167                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6168                 .free = LDKMessageSendEventsProvider_JCalls_free,
6169         };
6170         return ret;
6171 }
6172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6173         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6174         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
6175         return (uint64_t)res_ptr;
6176 }
6177 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6178         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)(((uint64_t)this_arg) & ~1);
6179         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6180         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6181         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6182         for (size_t s = 0; s < ret_var.datalen; s++) {
6183                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6184                 *ret_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
6185                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
6186                 ret_arr_ptr[s] = ret_conv_18_ref;
6187         }
6188         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6189         FREE(ret_var.data);
6190         return ret_arr;
6191 }
6192
6193 typedef struct LDKEventHandler_JCalls {
6194         atomic_size_t refcnt;
6195         JavaVM *vm;
6196         jweak o;
6197         jmethodID handle_event_meth;
6198 } LDKEventHandler_JCalls;
6199 static void LDKEventHandler_JCalls_free(void* this_arg) {
6200         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6201         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6202                 JNIEnv *env;
6203                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6204                 if (get_jenv_res == JNI_EDETACHED) {
6205                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6206                 } else {
6207                         DO_ASSERT(get_jenv_res == JNI_OK);
6208                 }
6209                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6210                 if (get_jenv_res == JNI_EDETACHED) {
6211                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6212                 }
6213                 FREE(j_calls);
6214         }
6215 }
6216 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
6217         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6218         JNIEnv *env;
6219         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6220         if (get_jenv_res == JNI_EDETACHED) {
6221                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6222         } else {
6223                 DO_ASSERT(get_jenv_res == JNI_OK);
6224         }
6225         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6226         *event_copy = event;
6227         uint64_t event_ref = (uint64_t)event_copy;
6228         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6229         CHECK(obj != NULL);
6230         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
6231         if ((*env)->ExceptionCheck(env)) {
6232                 (*env)->ExceptionDescribe(env);
6233                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
6234         }
6235         if (get_jenv_res == JNI_EDETACHED) {
6236                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6237         }
6238 }
6239 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
6240         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
6241         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6242 }
6243 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
6244         jclass c = (*env)->GetObjectClass(env, o);
6245         CHECK(c != NULL);
6246         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6247         atomic_init(&calls->refcnt, 1);
6248         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6249         calls->o = (*env)->NewWeakGlobalRef(env, o);
6250         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
6251         CHECK(calls->handle_event_meth != NULL);
6252
6253         LDKEventHandler ret = {
6254                 .this_arg = (void*) calls,
6255                 .handle_event = handle_event_LDKEventHandler_jcall,
6256                 .free = LDKEventHandler_JCalls_free,
6257         };
6258         return ret;
6259 }
6260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
6261         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6262         *res_ptr = LDKEventHandler_init(env, clz, o);
6263         return (uint64_t)res_ptr;
6264 }
6265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
6266         LDKEventHandler* this_arg_conv = (LDKEventHandler*)(((uint64_t)this_arg) & ~1);
6267         LDKEvent event_conv = *(LDKEvent*)(((uint64_t)event) & ~1);
6268         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6269 }
6270
6271 typedef struct LDKEventsProvider_JCalls {
6272         atomic_size_t refcnt;
6273         JavaVM *vm;
6274         jweak o;
6275         jmethodID process_pending_events_meth;
6276 } LDKEventsProvider_JCalls;
6277 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6278         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6279         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6280                 JNIEnv *env;
6281                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6282                 if (get_jenv_res == JNI_EDETACHED) {
6283                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6284                 } else {
6285                         DO_ASSERT(get_jenv_res == JNI_OK);
6286                 }
6287                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6288                 if (get_jenv_res == JNI_EDETACHED) {
6289                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6290                 }
6291                 FREE(j_calls);
6292         }
6293 }
6294 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6295         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6296         JNIEnv *env;
6297         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6298         if (get_jenv_res == JNI_EDETACHED) {
6299                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6300         } else {
6301                 DO_ASSERT(get_jenv_res == JNI_OK);
6302         }
6303         LDKEventHandler* ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6304         *ret = handler;
6305         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6306         CHECK(obj != NULL);
6307         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)ret);
6308         if ((*env)->ExceptionCheck(env)) {
6309                 (*env)->ExceptionDescribe(env);
6310                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
6311         }
6312         if (get_jenv_res == JNI_EDETACHED) {
6313                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6314         }
6315 }
6316 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
6317         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
6318         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6319 }
6320 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
6321         jclass c = (*env)->GetObjectClass(env, o);
6322         CHECK(c != NULL);
6323         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6324         atomic_init(&calls->refcnt, 1);
6325         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6326         calls->o = (*env)->NewWeakGlobalRef(env, o);
6327         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
6328         CHECK(calls->process_pending_events_meth != NULL);
6329
6330         LDKEventsProvider ret = {
6331                 .this_arg = (void*) calls,
6332                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6333                 .free = LDKEventsProvider_JCalls_free,
6334         };
6335         return ret;
6336 }
6337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
6338         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6339         *res_ptr = LDKEventsProvider_init(env, clz, o);
6340         return (uint64_t)res_ptr;
6341 }
6342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
6343         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)(((uint64_t)this_arg) & ~1);
6344         LDKEventHandler handler_conv = *(LDKEventHandler*)(((uint64_t)handler) & ~1);
6345         if (handler_conv.free == LDKEventHandler_JCalls_free) {
6346                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6347                 LDKEventHandler_JCalls_cloned(&handler_conv);
6348         }
6349         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6350 }
6351
6352 typedef struct LDKAccess_JCalls {
6353         atomic_size_t refcnt;
6354         JavaVM *vm;
6355         jweak o;
6356         jmethodID get_utxo_meth;
6357 } LDKAccess_JCalls;
6358 static void LDKAccess_JCalls_free(void* this_arg) {
6359         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6360         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6361                 JNIEnv *env;
6362                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6363                 if (get_jenv_res == JNI_EDETACHED) {
6364                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6365                 } else {
6366                         DO_ASSERT(get_jenv_res == JNI_OK);
6367                 }
6368                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6369                 if (get_jenv_res == JNI_EDETACHED) {
6370                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6371                 }
6372                 FREE(j_calls);
6373         }
6374 }
6375 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6376         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6377         JNIEnv *env;
6378         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6379         if (get_jenv_res == JNI_EDETACHED) {
6380                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6381         } else {
6382                 DO_ASSERT(get_jenv_res == JNI_OK);
6383         }
6384         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6385         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6386         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6387         CHECK(obj != NULL);
6388         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6389         if ((*env)->ExceptionCheck(env)) {
6390                 (*env)->ExceptionDescribe(env);
6391                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6392         }
6393         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
6394         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
6395         if (get_jenv_res == JNI_EDETACHED) {
6396                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6397         }
6398         return ret_conv;
6399 }
6400 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6401         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6402         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6403 }
6404 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6405         jclass c = (*env)->GetObjectClass(env, o);
6406         CHECK(c != NULL);
6407         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6408         atomic_init(&calls->refcnt, 1);
6409         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6410         calls->o = (*env)->NewWeakGlobalRef(env, o);
6411         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6412         CHECK(calls->get_utxo_meth != NULL);
6413
6414         LDKAccess ret = {
6415                 .this_arg = (void*) calls,
6416                 .get_utxo = get_utxo_LDKAccess_jcall,
6417                 .free = LDKAccess_JCalls_free,
6418         };
6419         return ret;
6420 }
6421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6422         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6423         *res_ptr = LDKAccess_init(env, clz, o);
6424         return (uint64_t)res_ptr;
6425 }
6426 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) {
6427         LDKAccess* this_arg_conv = (LDKAccess*)(((uint64_t)this_arg) & ~1);
6428         unsigned char genesis_hash_arr[32];
6429         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6430         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6431         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6432         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6433         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6434         return (uint64_t)ret_conv;
6435 }
6436
6437 typedef struct LDKListen_JCalls {
6438         atomic_size_t refcnt;
6439         JavaVM *vm;
6440         jweak o;
6441         jmethodID block_connected_meth;
6442         jmethodID block_disconnected_meth;
6443 } LDKListen_JCalls;
6444 static void LDKListen_JCalls_free(void* this_arg) {
6445         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6446         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6447                 JNIEnv *env;
6448                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6449                 if (get_jenv_res == JNI_EDETACHED) {
6450                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6451                 } else {
6452                         DO_ASSERT(get_jenv_res == JNI_OK);
6453                 }
6454                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6455                 if (get_jenv_res == JNI_EDETACHED) {
6456                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6457                 }
6458                 FREE(j_calls);
6459         }
6460 }
6461 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6462         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6463         JNIEnv *env;
6464         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6465         if (get_jenv_res == JNI_EDETACHED) {
6466                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6467         } else {
6468                 DO_ASSERT(get_jenv_res == JNI_OK);
6469         }
6470         LDKu8slice block_var = block;
6471         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
6472         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
6473         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6474         CHECK(obj != NULL);
6475         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
6476         if ((*env)->ExceptionCheck(env)) {
6477                 (*env)->ExceptionDescribe(env);
6478                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
6479         }
6480         if (get_jenv_res == JNI_EDETACHED) {
6481                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6482         }
6483 }
6484 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6485         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6486         JNIEnv *env;
6487         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6488         if (get_jenv_res == JNI_EDETACHED) {
6489                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6490         } else {
6491                 DO_ASSERT(get_jenv_res == JNI_OK);
6492         }
6493         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6494         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6495         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6496         CHECK(obj != NULL);
6497         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
6498         if ((*env)->ExceptionCheck(env)) {
6499                 (*env)->ExceptionDescribe(env);
6500                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
6501         }
6502         if (get_jenv_res == JNI_EDETACHED) {
6503                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6504         }
6505 }
6506 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
6507         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
6508         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6509 }
6510 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
6511         jclass c = (*env)->GetObjectClass(env, o);
6512         CHECK(c != NULL);
6513         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
6514         atomic_init(&calls->refcnt, 1);
6515         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6516         calls->o = (*env)->NewWeakGlobalRef(env, o);
6517         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
6518         CHECK(calls->block_connected_meth != NULL);
6519         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
6520         CHECK(calls->block_disconnected_meth != NULL);
6521
6522         LDKListen ret = {
6523                 .this_arg = (void*) calls,
6524                 .block_connected = block_connected_LDKListen_jcall,
6525                 .block_disconnected = block_disconnected_LDKListen_jcall,
6526                 .free = LDKListen_JCalls_free,
6527         };
6528         return ret;
6529 }
6530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
6531         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
6532         *res_ptr = LDKListen_init(env, clz, o);
6533         return (uint64_t)res_ptr;
6534 }
6535 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) {
6536         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6537         LDKu8slice block_ref;
6538         block_ref.datalen = (*env)->GetArrayLength(env, block);
6539         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
6540         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
6541         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
6542 }
6543
6544 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) {
6545         LDKListen* this_arg_conv = (LDKListen*)(((uint64_t)this_arg) & ~1);
6546         unsigned char header_arr[80];
6547         CHECK((*env)->GetArrayLength(env, header) == 80);
6548         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6549         unsigned char (*header_ref)[80] = &header_arr;
6550         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
6551 }
6552
6553 typedef struct LDKConfirm_JCalls {
6554         atomic_size_t refcnt;
6555         JavaVM *vm;
6556         jweak o;
6557         jmethodID transactions_confirmed_meth;
6558         jmethodID transaction_unconfirmed_meth;
6559         jmethodID best_block_updated_meth;
6560         jmethodID get_relevant_txids_meth;
6561 } LDKConfirm_JCalls;
6562 static void LDKConfirm_JCalls_free(void* this_arg) {
6563         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6564         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6565                 JNIEnv *env;
6566                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6567                 if (get_jenv_res == JNI_EDETACHED) {
6568                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6569                 } else {
6570                         DO_ASSERT(get_jenv_res == JNI_OK);
6571                 }
6572                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6573                 if (get_jenv_res == JNI_EDETACHED) {
6574                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6575                 }
6576                 FREE(j_calls);
6577         }
6578 }
6579 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
6580         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6581         JNIEnv *env;
6582         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6583         if (get_jenv_res == JNI_EDETACHED) {
6584                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6585         } else {
6586                 DO_ASSERT(get_jenv_res == JNI_OK);
6587         }
6588         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6589         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6590         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
6591         int64_tArray txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
6592         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
6593         for (size_t y = 0; y < txdata_var.datalen; y++) {
6594                 LDKC2Tuple_usizeTransactionZ* txdata_conv_24_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
6595                 *txdata_conv_24_ref = txdata_var.data[y];
6596                 txdata_arr_ptr[y] = (uint64_t)txdata_conv_24_ref;
6597         }
6598         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
6599         FREE(txdata_var.data);
6600         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6601         CHECK(obj != NULL);
6602         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
6603         if ((*env)->ExceptionCheck(env)) {
6604                 (*env)->ExceptionDescribe(env);
6605                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
6606         }
6607         if (get_jenv_res == JNI_EDETACHED) {
6608                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6609         }
6610 }
6611 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
6612         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6613         JNIEnv *env;
6614         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6615         if (get_jenv_res == JNI_EDETACHED) {
6616                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6617         } else {
6618                 DO_ASSERT(get_jenv_res == JNI_OK);
6619         }
6620         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6621         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6622         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6623         CHECK(obj != NULL);
6624         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
6625         if ((*env)->ExceptionCheck(env)) {
6626                 (*env)->ExceptionDescribe(env);
6627                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
6628         }
6629         if (get_jenv_res == JNI_EDETACHED) {
6630                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6631         }
6632 }
6633 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6634         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6635         JNIEnv *env;
6636         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6637         if (get_jenv_res == JNI_EDETACHED) {
6638                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6639         } else {
6640                 DO_ASSERT(get_jenv_res == JNI_OK);
6641         }
6642         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
6643         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
6644         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6645         CHECK(obj != NULL);
6646         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
6647         if ((*env)->ExceptionCheck(env)) {
6648                 (*env)->ExceptionDescribe(env);
6649                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
6650         }
6651         if (get_jenv_res == JNI_EDETACHED) {
6652                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6653         }
6654 }
6655 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
6656         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
6657         JNIEnv *env;
6658         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6659         if (get_jenv_res == JNI_EDETACHED) {
6660                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6661         } else {
6662                 DO_ASSERT(get_jenv_res == JNI_OK);
6663         }
6664         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6665         CHECK(obj != NULL);
6666         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
6667         if ((*env)->ExceptionCheck(env)) {
6668                 (*env)->ExceptionDescribe(env);
6669                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
6670         }
6671         LDKCVec_TxidZ ret_constr;
6672         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6673         if (ret_constr.datalen > 0)
6674                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
6675         else
6676                 ret_constr.data = NULL;
6677         for (size_t i = 0; i < ret_constr.datalen; i++) {
6678                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
6679                 LDKThirtyTwoBytes ret_conv_8_ref;
6680                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
6681                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
6682                 ret_constr.data[i] = ret_conv_8_ref;
6683         }
6684         if (get_jenv_res == JNI_EDETACHED) {
6685                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6686         }
6687         return ret_constr;
6688 }
6689 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
6690         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
6691         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6692 }
6693 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
6694         jclass c = (*env)->GetObjectClass(env, o);
6695         CHECK(c != NULL);
6696         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
6697         atomic_init(&calls->refcnt, 1);
6698         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6699         calls->o = (*env)->NewWeakGlobalRef(env, o);
6700         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
6701         CHECK(calls->transactions_confirmed_meth != NULL);
6702         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
6703         CHECK(calls->transaction_unconfirmed_meth != NULL);
6704         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
6705         CHECK(calls->best_block_updated_meth != NULL);
6706         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
6707         CHECK(calls->get_relevant_txids_meth != NULL);
6708
6709         LDKConfirm ret = {
6710                 .this_arg = (void*) calls,
6711                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
6712                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
6713                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
6714                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
6715                 .free = LDKConfirm_JCalls_free,
6716         };
6717         return ret;
6718 }
6719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
6720         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
6721         *res_ptr = LDKConfirm_init(env, clz, o);
6722         return (uint64_t)res_ptr;
6723 }
6724 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) {
6725         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6726         unsigned char header_arr[80];
6727         CHECK((*env)->GetArrayLength(env, header) == 80);
6728         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6729         unsigned char (*header_ref)[80] = &header_arr;
6730         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6731         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
6732         if (txdata_constr.datalen > 0)
6733                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6734         else
6735                 txdata_constr.data = NULL;
6736         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
6737         for (size_t y = 0; y < txdata_constr.datalen; y++) {
6738                 int64_t txdata_conv_24 = txdata_vals[y];
6739                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
6740                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
6741                 txdata_constr.data[y] = txdata_conv_24_conv;
6742         }
6743         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
6744         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
6745 }
6746
6747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
6748         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6749         unsigned char txid_arr[32];
6750         CHECK((*env)->GetArrayLength(env, txid) == 32);
6751         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6752         unsigned char (*txid_ref)[32] = &txid_arr;
6753         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
6754 }
6755
6756 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) {
6757         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6758         unsigned char header_arr[80];
6759         CHECK((*env)->GetArrayLength(env, header) == 80);
6760         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
6761         unsigned char (*header_ref)[80] = &header_arr;
6762         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
6763 }
6764
6765 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
6766         LDKConfirm* this_arg_conv = (LDKConfirm*)(((uint64_t)this_arg) & ~1);
6767         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
6768         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6769         ;
6770         for (size_t i = 0; i < ret_var.datalen; i++) {
6771                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
6772                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
6773                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6774         }
6775         FREE(ret_var.data);
6776         return ret_arr;
6777 }
6778
6779 typedef struct LDKFilter_JCalls {
6780         atomic_size_t refcnt;
6781         JavaVM *vm;
6782         jweak o;
6783         jmethodID register_tx_meth;
6784         jmethodID register_output_meth;
6785 } LDKFilter_JCalls;
6786 static void LDKFilter_JCalls_free(void* this_arg) {
6787         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6788         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6789                 JNIEnv *env;
6790                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6791                 if (get_jenv_res == JNI_EDETACHED) {
6792                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6793                 } else {
6794                         DO_ASSERT(get_jenv_res == JNI_OK);
6795                 }
6796                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6797                 if (get_jenv_res == JNI_EDETACHED) {
6798                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6799                 }
6800                 FREE(j_calls);
6801         }
6802 }
6803 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
6804         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6805         JNIEnv *env;
6806         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6807         if (get_jenv_res == JNI_EDETACHED) {
6808                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6809         } else {
6810                 DO_ASSERT(get_jenv_res == JNI_OK);
6811         }
6812         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
6813         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
6814         LDKu8slice script_pubkey_var = script_pubkey;
6815         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
6816         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
6817         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6818         CHECK(obj != NULL);
6819         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
6820         if ((*env)->ExceptionCheck(env)) {
6821                 (*env)->ExceptionDescribe(env);
6822                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
6823         }
6824         if (get_jenv_res == JNI_EDETACHED) {
6825                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6826         }
6827 }
6828 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
6829         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
6830         JNIEnv *env;
6831         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6832         if (get_jenv_res == JNI_EDETACHED) {
6833                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6834         } else {
6835                 DO_ASSERT(get_jenv_res == JNI_OK);
6836         }
6837         LDKWatchedOutput output_var = output;
6838         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6839         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6840         uint64_t output_ref = (uint64_t)output_var.inner;
6841         if (output_var.is_owned) {
6842                 output_ref |= 1;
6843         }
6844         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6845         CHECK(obj != NULL);
6846         LDKCOption_C2Tuple_usizeTransactionZZ* ret = (LDKCOption_C2Tuple_usizeTransactionZZ*)(*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
6847         if ((*env)->ExceptionCheck(env)) {
6848                 (*env)->ExceptionDescribe(env);
6849                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
6850         }
6851         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1);
6852         ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
6853         if (get_jenv_res == JNI_EDETACHED) {
6854                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6855         }
6856         return ret_conv;
6857 }
6858 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
6859         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
6860         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6861 }
6862 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
6863         jclass c = (*env)->GetObjectClass(env, o);
6864         CHECK(c != NULL);
6865         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
6866         atomic_init(&calls->refcnt, 1);
6867         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6868         calls->o = (*env)->NewWeakGlobalRef(env, o);
6869         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
6870         CHECK(calls->register_tx_meth != NULL);
6871         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
6872         CHECK(calls->register_output_meth != NULL);
6873
6874         LDKFilter ret = {
6875                 .this_arg = (void*) calls,
6876                 .register_tx = register_tx_LDKFilter_jcall,
6877                 .register_output = register_output_LDKFilter_jcall,
6878                 .free = LDKFilter_JCalls_free,
6879         };
6880         return ret;
6881 }
6882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
6883         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
6884         *res_ptr = LDKFilter_init(env, clz, o);
6885         return (uint64_t)res_ptr;
6886 }
6887 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) {
6888         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6889         unsigned char txid_arr[32];
6890         CHECK((*env)->GetArrayLength(env, txid) == 32);
6891         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
6892         unsigned char (*txid_ref)[32] = &txid_arr;
6893         LDKu8slice script_pubkey_ref;
6894         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
6895         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
6896         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
6897         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
6898 }
6899
6900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
6901         LDKFilter* this_arg_conv = (LDKFilter*)(((uint64_t)this_arg) & ~1);
6902         LDKWatchedOutput output_conv;
6903         output_conv.inner = (void*)(output & (~1));
6904         output_conv.is_owned = (output & 1) || (output == 0);
6905         output_conv = WatchedOutput_clone(&output_conv);
6906         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
6907         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
6908         uint64_t ret_ref = (uint64_t)ret_copy;
6909         return ret_ref;
6910 }
6911
6912 typedef struct LDKPersist_JCalls {
6913         atomic_size_t refcnt;
6914         JavaVM *vm;
6915         jweak o;
6916         jmethodID persist_new_channel_meth;
6917         jmethodID update_persisted_channel_meth;
6918 } LDKPersist_JCalls;
6919 static void LDKPersist_JCalls_free(void* this_arg) {
6920         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6921         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6922                 JNIEnv *env;
6923                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6924                 if (get_jenv_res == JNI_EDETACHED) {
6925                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6926                 } else {
6927                         DO_ASSERT(get_jenv_res == JNI_OK);
6928                 }
6929                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6930                 if (get_jenv_res == JNI_EDETACHED) {
6931                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6932                 }
6933                 FREE(j_calls);
6934         }
6935 }
6936 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
6937         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6938         JNIEnv *env;
6939         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6940         if (get_jenv_res == JNI_EDETACHED) {
6941                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6942         } else {
6943                 DO_ASSERT(get_jenv_res == JNI_OK);
6944         }
6945         LDKOutPoint id_var = id;
6946         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6947         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6948         uint64_t id_ref = (uint64_t)id_var.inner;
6949         if (id_var.is_owned) {
6950                 id_ref |= 1;
6951         }
6952         LDKChannelMonitor data_var = *data;
6953         data_var = ChannelMonitor_clone(data);
6954         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6955         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6956         uint64_t data_ref = (uint64_t)data_var.inner;
6957         if (data_var.is_owned) {
6958                 data_ref |= 1;
6959         }
6960         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6961         CHECK(obj != NULL);
6962         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, id_ref, data_ref);
6963         if ((*env)->ExceptionCheck(env)) {
6964                 (*env)->ExceptionDescribe(env);
6965                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
6966         }
6967         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
6968         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
6969         if (get_jenv_res == JNI_EDETACHED) {
6970                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6971         }
6972         return ret_conv;
6973 }
6974 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
6975         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
6976         JNIEnv *env;
6977         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6978         if (get_jenv_res == JNI_EDETACHED) {
6979                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6980         } else {
6981                 DO_ASSERT(get_jenv_res == JNI_OK);
6982         }
6983         LDKOutPoint id_var = id;
6984         CHECK((((uint64_t)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6985         CHECK((((uint64_t)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6986         uint64_t id_ref = (uint64_t)id_var.inner;
6987         if (id_var.is_owned) {
6988                 id_ref |= 1;
6989         }
6990         LDKChannelMonitorUpdate update_var = *update;
6991         update_var = ChannelMonitorUpdate_clone(update);
6992         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6993         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6994         uint64_t update_ref = (uint64_t)update_var.inner;
6995         if (update_var.is_owned) {
6996                 update_ref |= 1;
6997         }
6998         LDKChannelMonitor data_var = *data;
6999         data_var = ChannelMonitor_clone(data);
7000         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7001         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7002         uint64_t data_ref = (uint64_t)data_var.inner;
7003         if (data_var.is_owned) {
7004                 data_ref |= 1;
7005         }
7006         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7007         CHECK(obj != NULL);
7008         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
7009         if ((*env)->ExceptionCheck(env)) {
7010                 (*env)->ExceptionDescribe(env);
7011                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
7012         }
7013         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
7014         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
7015         if (get_jenv_res == JNI_EDETACHED) {
7016                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7017         }
7018         return ret_conv;
7019 }
7020 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
7021         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
7022         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7023 }
7024 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
7025         jclass c = (*env)->GetObjectClass(env, o);
7026         CHECK(c != NULL);
7027         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
7028         atomic_init(&calls->refcnt, 1);
7029         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7030         calls->o = (*env)->NewWeakGlobalRef(env, o);
7031         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
7032         CHECK(calls->persist_new_channel_meth != NULL);
7033         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
7034         CHECK(calls->update_persisted_channel_meth != NULL);
7035
7036         LDKPersist ret = {
7037                 .this_arg = (void*) calls,
7038                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
7039                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
7040                 .free = LDKPersist_JCalls_free,
7041         };
7042         return ret;
7043 }
7044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
7045         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
7046         *res_ptr = LDKPersist_init(env, clz, o);
7047         return (uint64_t)res_ptr;
7048 }
7049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t data) {
7050         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7051         LDKOutPoint id_conv;
7052         id_conv.inner = (void*)(id & (~1));
7053         id_conv.is_owned = (id & 1) || (id == 0);
7054         id_conv = OutPoint_clone(&id_conv);
7055         LDKChannelMonitor data_conv;
7056         data_conv.inner = (void*)(data & (~1));
7057         data_conv.is_owned = false;
7058         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7059         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
7060         return (uint64_t)ret_conv;
7061 }
7062
7063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t id, int64_t update, int64_t data) {
7064         LDKPersist* this_arg_conv = (LDKPersist*)(((uint64_t)this_arg) & ~1);
7065         LDKOutPoint id_conv;
7066         id_conv.inner = (void*)(id & (~1));
7067         id_conv.is_owned = (id & 1) || (id == 0);
7068         id_conv = OutPoint_clone(&id_conv);
7069         LDKChannelMonitorUpdate update_conv;
7070         update_conv.inner = (void*)(update & (~1));
7071         update_conv.is_owned = false;
7072         LDKChannelMonitor data_conv;
7073         data_conv.inner = (void*)(data & (~1));
7074         data_conv.is_owned = false;
7075         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7076         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
7077         return (uint64_t)ret_conv;
7078 }
7079
7080 typedef struct LDKChannelMessageHandler_JCalls {
7081         atomic_size_t refcnt;
7082         JavaVM *vm;
7083         jweak o;
7084         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7085         jmethodID handle_open_channel_meth;
7086         jmethodID handle_accept_channel_meth;
7087         jmethodID handle_funding_created_meth;
7088         jmethodID handle_funding_signed_meth;
7089         jmethodID handle_funding_locked_meth;
7090         jmethodID handle_shutdown_meth;
7091         jmethodID handle_closing_signed_meth;
7092         jmethodID handle_update_add_htlc_meth;
7093         jmethodID handle_update_fulfill_htlc_meth;
7094         jmethodID handle_update_fail_htlc_meth;
7095         jmethodID handle_update_fail_malformed_htlc_meth;
7096         jmethodID handle_commitment_signed_meth;
7097         jmethodID handle_revoke_and_ack_meth;
7098         jmethodID handle_update_fee_meth;
7099         jmethodID handle_announcement_signatures_meth;
7100         jmethodID peer_disconnected_meth;
7101         jmethodID peer_connected_meth;
7102         jmethodID handle_channel_reestablish_meth;
7103         jmethodID handle_channel_update_meth;
7104         jmethodID handle_error_meth;
7105 } LDKChannelMessageHandler_JCalls;
7106 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
7107         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7108         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7109                 JNIEnv *env;
7110                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7111                 if (get_jenv_res == JNI_EDETACHED) {
7112                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7113                 } else {
7114                         DO_ASSERT(get_jenv_res == JNI_OK);
7115                 }
7116                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7117                 if (get_jenv_res == JNI_EDETACHED) {
7118                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7119                 }
7120                 FREE(j_calls);
7121         }
7122 }
7123 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
7124         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7125         JNIEnv *env;
7126         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7127         if (get_jenv_res == JNI_EDETACHED) {
7128                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7129         } else {
7130                 DO_ASSERT(get_jenv_res == JNI_OK);
7131         }
7132         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7133         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7134         LDKInitFeatures their_features_var = their_features;
7135         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7136         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7137         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7138         if (their_features_var.is_owned) {
7139                 their_features_ref |= 1;
7140         }
7141         LDKOpenChannel msg_var = *msg;
7142         msg_var = OpenChannel_clone(msg);
7143         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7144         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7145         uint64_t msg_ref = (uint64_t)msg_var.inner;
7146         if (msg_var.is_owned) {
7147                 msg_ref |= 1;
7148         }
7149         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7150         CHECK(obj != NULL);
7151         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7152         if ((*env)->ExceptionCheck(env)) {
7153                 (*env)->ExceptionDescribe(env);
7154                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
7155         }
7156         if (get_jenv_res == JNI_EDETACHED) {
7157                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7158         }
7159 }
7160 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
7161         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7162         JNIEnv *env;
7163         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7164         if (get_jenv_res == JNI_EDETACHED) {
7165                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7166         } else {
7167                 DO_ASSERT(get_jenv_res == JNI_OK);
7168         }
7169         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7170         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7171         LDKInitFeatures their_features_var = their_features;
7172         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7173         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7174         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7175         if (their_features_var.is_owned) {
7176                 their_features_ref |= 1;
7177         }
7178         LDKAcceptChannel msg_var = *msg;
7179         msg_var = AcceptChannel_clone(msg);
7180         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7181         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7182         uint64_t msg_ref = (uint64_t)msg_var.inner;
7183         if (msg_var.is_owned) {
7184                 msg_ref |= 1;
7185         }
7186         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7187         CHECK(obj != NULL);
7188         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
7189         if ((*env)->ExceptionCheck(env)) {
7190                 (*env)->ExceptionDescribe(env);
7191                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
7192         }
7193         if (get_jenv_res == JNI_EDETACHED) {
7194                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7195         }
7196 }
7197 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
7198         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7199         JNIEnv *env;
7200         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7201         if (get_jenv_res == JNI_EDETACHED) {
7202                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7203         } else {
7204                 DO_ASSERT(get_jenv_res == JNI_OK);
7205         }
7206         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7207         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7208         LDKFundingCreated msg_var = *msg;
7209         msg_var = FundingCreated_clone(msg);
7210         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7211         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7212         uint64_t msg_ref = (uint64_t)msg_var.inner;
7213         if (msg_var.is_owned) {
7214                 msg_ref |= 1;
7215         }
7216         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7217         CHECK(obj != NULL);
7218         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
7219         if ((*env)->ExceptionCheck(env)) {
7220                 (*env)->ExceptionDescribe(env);
7221                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
7222         }
7223         if (get_jenv_res == JNI_EDETACHED) {
7224                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7225         }
7226 }
7227 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7228         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7229         JNIEnv *env;
7230         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7231         if (get_jenv_res == JNI_EDETACHED) {
7232                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7233         } else {
7234                 DO_ASSERT(get_jenv_res == JNI_OK);
7235         }
7236         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7237         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7238         LDKFundingSigned msg_var = *msg;
7239         msg_var = FundingSigned_clone(msg);
7240         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7241         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7242         uint64_t msg_ref = (uint64_t)msg_var.inner;
7243         if (msg_var.is_owned) {
7244                 msg_ref |= 1;
7245         }
7246         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7247         CHECK(obj != NULL);
7248         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
7249         if ((*env)->ExceptionCheck(env)) {
7250                 (*env)->ExceptionDescribe(env);
7251                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
7252         }
7253         if (get_jenv_res == JNI_EDETACHED) {
7254                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7255         }
7256 }
7257 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7258         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7259         JNIEnv *env;
7260         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7261         if (get_jenv_res == JNI_EDETACHED) {
7262                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7263         } else {
7264                 DO_ASSERT(get_jenv_res == JNI_OK);
7265         }
7266         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7267         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7268         LDKFundingLocked msg_var = *msg;
7269         msg_var = FundingLocked_clone(msg);
7270         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7271         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7272         uint64_t msg_ref = (uint64_t)msg_var.inner;
7273         if (msg_var.is_owned) {
7274                 msg_ref |= 1;
7275         }
7276         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7277         CHECK(obj != NULL);
7278         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
7279         if ((*env)->ExceptionCheck(env)) {
7280                 (*env)->ExceptionDescribe(env);
7281                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
7282         }
7283         if (get_jenv_res == JNI_EDETACHED) {
7284                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7285         }
7286 }
7287 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7288         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7289         JNIEnv *env;
7290         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7291         if (get_jenv_res == JNI_EDETACHED) {
7292                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7293         } else {
7294                 DO_ASSERT(get_jenv_res == JNI_OK);
7295         }
7296         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7297         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7298         LDKInitFeatures their_features_var = *their_features;
7299         their_features_var = InitFeatures_clone(their_features);
7300         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7301         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7302         uint64_t their_features_ref = (uint64_t)their_features_var.inner;
7303         if (their_features_var.is_owned) {
7304                 their_features_ref |= 1;
7305         }
7306         LDKShutdown msg_var = *msg;
7307         msg_var = Shutdown_clone(msg);
7308         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7309         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7310         uint64_t msg_ref = (uint64_t)msg_var.inner;
7311         if (msg_var.is_owned) {
7312                 msg_ref |= 1;
7313         }
7314         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7315         CHECK(obj != NULL);
7316         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
7317         if ((*env)->ExceptionCheck(env)) {
7318                 (*env)->ExceptionDescribe(env);
7319                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
7320         }
7321         if (get_jenv_res == JNI_EDETACHED) {
7322                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7323         }
7324 }
7325 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7326         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7327         JNIEnv *env;
7328         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7329         if (get_jenv_res == JNI_EDETACHED) {
7330                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7331         } else {
7332                 DO_ASSERT(get_jenv_res == JNI_OK);
7333         }
7334         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7335         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7336         LDKClosingSigned msg_var = *msg;
7337         msg_var = ClosingSigned_clone(msg);
7338         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7339         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7340         uint64_t msg_ref = (uint64_t)msg_var.inner;
7341         if (msg_var.is_owned) {
7342                 msg_ref |= 1;
7343         }
7344         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7345         CHECK(obj != NULL);
7346         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
7347         if ((*env)->ExceptionCheck(env)) {
7348                 (*env)->ExceptionDescribe(env);
7349                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
7350         }
7351         if (get_jenv_res == JNI_EDETACHED) {
7352                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7353         }
7354 }
7355 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7356         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7357         JNIEnv *env;
7358         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7359         if (get_jenv_res == JNI_EDETACHED) {
7360                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7361         } else {
7362                 DO_ASSERT(get_jenv_res == JNI_OK);
7363         }
7364         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7365         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7366         LDKUpdateAddHTLC msg_var = *msg;
7367         msg_var = UpdateAddHTLC_clone(msg);
7368         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7369         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7370         uint64_t msg_ref = (uint64_t)msg_var.inner;
7371         if (msg_var.is_owned) {
7372                 msg_ref |= 1;
7373         }
7374         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7375         CHECK(obj != NULL);
7376         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
7377         if ((*env)->ExceptionCheck(env)) {
7378                 (*env)->ExceptionDescribe(env);
7379                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
7380         }
7381         if (get_jenv_res == JNI_EDETACHED) {
7382                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7383         }
7384 }
7385 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7386         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7387         JNIEnv *env;
7388         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7389         if (get_jenv_res == JNI_EDETACHED) {
7390                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7391         } else {
7392                 DO_ASSERT(get_jenv_res == JNI_OK);
7393         }
7394         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7395         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7396         LDKUpdateFulfillHTLC msg_var = *msg;
7397         msg_var = UpdateFulfillHTLC_clone(msg);
7398         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7399         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7400         uint64_t msg_ref = (uint64_t)msg_var.inner;
7401         if (msg_var.is_owned) {
7402                 msg_ref |= 1;
7403         }
7404         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7405         CHECK(obj != NULL);
7406         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
7407         if ((*env)->ExceptionCheck(env)) {
7408                 (*env)->ExceptionDescribe(env);
7409                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
7410         }
7411         if (get_jenv_res == JNI_EDETACHED) {
7412                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7413         }
7414 }
7415 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7416         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7417         JNIEnv *env;
7418         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7419         if (get_jenv_res == JNI_EDETACHED) {
7420                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7421         } else {
7422                 DO_ASSERT(get_jenv_res == JNI_OK);
7423         }
7424         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7425         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7426         LDKUpdateFailHTLC msg_var = *msg;
7427         msg_var = UpdateFailHTLC_clone(msg);
7428         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7429         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7430         uint64_t msg_ref = (uint64_t)msg_var.inner;
7431         if (msg_var.is_owned) {
7432                 msg_ref |= 1;
7433         }
7434         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7435         CHECK(obj != NULL);
7436         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
7437         if ((*env)->ExceptionCheck(env)) {
7438                 (*env)->ExceptionDescribe(env);
7439                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
7440         }
7441         if (get_jenv_res == JNI_EDETACHED) {
7442                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7443         }
7444 }
7445 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7446         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7447         JNIEnv *env;
7448         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7449         if (get_jenv_res == JNI_EDETACHED) {
7450                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7451         } else {
7452                 DO_ASSERT(get_jenv_res == JNI_OK);
7453         }
7454         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7455         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7456         LDKUpdateFailMalformedHTLC msg_var = *msg;
7457         msg_var = UpdateFailMalformedHTLC_clone(msg);
7458         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7459         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7460         uint64_t msg_ref = (uint64_t)msg_var.inner;
7461         if (msg_var.is_owned) {
7462                 msg_ref |= 1;
7463         }
7464         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7465         CHECK(obj != NULL);
7466         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
7467         if ((*env)->ExceptionCheck(env)) {
7468                 (*env)->ExceptionDescribe(env);
7469                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
7470         }
7471         if (get_jenv_res == JNI_EDETACHED) {
7472                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7473         }
7474 }
7475 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7476         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7477         JNIEnv *env;
7478         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7479         if (get_jenv_res == JNI_EDETACHED) {
7480                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7481         } else {
7482                 DO_ASSERT(get_jenv_res == JNI_OK);
7483         }
7484         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7485         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7486         LDKCommitmentSigned msg_var = *msg;
7487         msg_var = CommitmentSigned_clone(msg);
7488         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7489         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7490         uint64_t msg_ref = (uint64_t)msg_var.inner;
7491         if (msg_var.is_owned) {
7492                 msg_ref |= 1;
7493         }
7494         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7495         CHECK(obj != NULL);
7496         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
7497         if ((*env)->ExceptionCheck(env)) {
7498                 (*env)->ExceptionDescribe(env);
7499                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
7500         }
7501         if (get_jenv_res == JNI_EDETACHED) {
7502                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7503         }
7504 }
7505 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7506         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7507         JNIEnv *env;
7508         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7509         if (get_jenv_res == JNI_EDETACHED) {
7510                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7511         } else {
7512                 DO_ASSERT(get_jenv_res == JNI_OK);
7513         }
7514         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7515         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7516         LDKRevokeAndACK msg_var = *msg;
7517         msg_var = RevokeAndACK_clone(msg);
7518         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7519         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7520         uint64_t msg_ref = (uint64_t)msg_var.inner;
7521         if (msg_var.is_owned) {
7522                 msg_ref |= 1;
7523         }
7524         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7525         CHECK(obj != NULL);
7526         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
7527         if ((*env)->ExceptionCheck(env)) {
7528                 (*env)->ExceptionDescribe(env);
7529                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
7530         }
7531         if (get_jenv_res == JNI_EDETACHED) {
7532                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7533         }
7534 }
7535 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7536         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7537         JNIEnv *env;
7538         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7539         if (get_jenv_res == JNI_EDETACHED) {
7540                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7541         } else {
7542                 DO_ASSERT(get_jenv_res == JNI_OK);
7543         }
7544         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7545         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7546         LDKUpdateFee msg_var = *msg;
7547         msg_var = UpdateFee_clone(msg);
7548         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7549         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7550         uint64_t msg_ref = (uint64_t)msg_var.inner;
7551         if (msg_var.is_owned) {
7552                 msg_ref |= 1;
7553         }
7554         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7555         CHECK(obj != NULL);
7556         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
7557         if ((*env)->ExceptionCheck(env)) {
7558                 (*env)->ExceptionDescribe(env);
7559                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
7560         }
7561         if (get_jenv_res == JNI_EDETACHED) {
7562                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7563         }
7564 }
7565 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7566         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7567         JNIEnv *env;
7568         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7569         if (get_jenv_res == JNI_EDETACHED) {
7570                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7571         } else {
7572                 DO_ASSERT(get_jenv_res == JNI_OK);
7573         }
7574         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7575         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7576         LDKAnnouncementSignatures msg_var = *msg;
7577         msg_var = AnnouncementSignatures_clone(msg);
7578         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7579         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7580         uint64_t msg_ref = (uint64_t)msg_var.inner;
7581         if (msg_var.is_owned) {
7582                 msg_ref |= 1;
7583         }
7584         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7585         CHECK(obj != NULL);
7586         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
7587         if ((*env)->ExceptionCheck(env)) {
7588                 (*env)->ExceptionDescribe(env);
7589                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
7590         }
7591         if (get_jenv_res == JNI_EDETACHED) {
7592                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7593         }
7594 }
7595 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7596         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7597         JNIEnv *env;
7598         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7599         if (get_jenv_res == JNI_EDETACHED) {
7600                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7601         } else {
7602                 DO_ASSERT(get_jenv_res == JNI_OK);
7603         }
7604         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7605         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7606         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7607         CHECK(obj != NULL);
7608         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
7609         if ((*env)->ExceptionCheck(env)) {
7610                 (*env)->ExceptionDescribe(env);
7611                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
7612         }
7613         if (get_jenv_res == JNI_EDETACHED) {
7614                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7615         }
7616 }
7617 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7618         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7619         JNIEnv *env;
7620         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7621         if (get_jenv_res == JNI_EDETACHED) {
7622                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7623         } else {
7624                 DO_ASSERT(get_jenv_res == JNI_OK);
7625         }
7626         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7627         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7628         LDKInit msg_var = *msg;
7629         msg_var = Init_clone(msg);
7630         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7631         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7632         uint64_t msg_ref = (uint64_t)msg_var.inner;
7633         if (msg_var.is_owned) {
7634                 msg_ref |= 1;
7635         }
7636         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7637         CHECK(obj != NULL);
7638         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
7639         if ((*env)->ExceptionCheck(env)) {
7640                 (*env)->ExceptionDescribe(env);
7641                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
7642         }
7643         if (get_jenv_res == JNI_EDETACHED) {
7644                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7645         }
7646 }
7647 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7648         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7649         JNIEnv *env;
7650         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7651         if (get_jenv_res == JNI_EDETACHED) {
7652                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7653         } else {
7654                 DO_ASSERT(get_jenv_res == JNI_OK);
7655         }
7656         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7657         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7658         LDKChannelReestablish msg_var = *msg;
7659         msg_var = ChannelReestablish_clone(msg);
7660         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7661         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7662         uint64_t msg_ref = (uint64_t)msg_var.inner;
7663         if (msg_var.is_owned) {
7664                 msg_ref |= 1;
7665         }
7666         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7667         CHECK(obj != NULL);
7668         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
7669         if ((*env)->ExceptionCheck(env)) {
7670                 (*env)->ExceptionDescribe(env);
7671                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
7672         }
7673         if (get_jenv_res == JNI_EDETACHED) {
7674                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7675         }
7676 }
7677 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
7678         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7679         JNIEnv *env;
7680         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7681         if (get_jenv_res == JNI_EDETACHED) {
7682                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7683         } else {
7684                 DO_ASSERT(get_jenv_res == JNI_OK);
7685         }
7686         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7687         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7688         LDKChannelUpdate msg_var = *msg;
7689         msg_var = ChannelUpdate_clone(msg);
7690         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7691         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7692         uint64_t msg_ref = (uint64_t)msg_var.inner;
7693         if (msg_var.is_owned) {
7694                 msg_ref |= 1;
7695         }
7696         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7697         CHECK(obj != NULL);
7698         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
7699         if ((*env)->ExceptionCheck(env)) {
7700                 (*env)->ExceptionDescribe(env);
7701                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
7702         }
7703         if (get_jenv_res == JNI_EDETACHED) {
7704                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7705         }
7706 }
7707 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7708         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7709         JNIEnv *env;
7710         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7711         if (get_jenv_res == JNI_EDETACHED) {
7712                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7713         } else {
7714                 DO_ASSERT(get_jenv_res == JNI_OK);
7715         }
7716         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
7717         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
7718         LDKErrorMessage msg_var = *msg;
7719         msg_var = ErrorMessage_clone(msg);
7720         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7721         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7722         uint64_t msg_ref = (uint64_t)msg_var.inner;
7723         if (msg_var.is_owned) {
7724                 msg_ref |= 1;
7725         }
7726         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7727         CHECK(obj != NULL);
7728         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
7729         if ((*env)->ExceptionCheck(env)) {
7730                 (*env)->ExceptionDescribe(env);
7731                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
7732         }
7733         if (get_jenv_res == JNI_EDETACHED) {
7734                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7735         }
7736 }
7737 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
7738         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
7739         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7740         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7741 }
7742 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7743         jclass c = (*env)->GetObjectClass(env, o);
7744         CHECK(c != NULL);
7745         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7746         atomic_init(&calls->refcnt, 1);
7747         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7748         calls->o = (*env)->NewWeakGlobalRef(env, o);
7749         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
7750         CHECK(calls->handle_open_channel_meth != NULL);
7751         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
7752         CHECK(calls->handle_accept_channel_meth != NULL);
7753         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
7754         CHECK(calls->handle_funding_created_meth != NULL);
7755         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
7756         CHECK(calls->handle_funding_signed_meth != NULL);
7757         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
7758         CHECK(calls->handle_funding_locked_meth != NULL);
7759         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
7760         CHECK(calls->handle_shutdown_meth != NULL);
7761         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
7762         CHECK(calls->handle_closing_signed_meth != NULL);
7763         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
7764         CHECK(calls->handle_update_add_htlc_meth != NULL);
7765         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
7766         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
7767         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
7768         CHECK(calls->handle_update_fail_htlc_meth != NULL);
7769         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
7770         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
7771         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
7772         CHECK(calls->handle_commitment_signed_meth != NULL);
7773         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
7774         CHECK(calls->handle_revoke_and_ack_meth != NULL);
7775         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
7776         CHECK(calls->handle_update_fee_meth != NULL);
7777         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
7778         CHECK(calls->handle_announcement_signatures_meth != NULL);
7779         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
7780         CHECK(calls->peer_disconnected_meth != NULL);
7781         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
7782         CHECK(calls->peer_connected_meth != NULL);
7783         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
7784         CHECK(calls->handle_channel_reestablish_meth != NULL);
7785         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
7786         CHECK(calls->handle_channel_update_meth != NULL);
7787         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
7788         CHECK(calls->handle_error_meth != NULL);
7789
7790         LDKChannelMessageHandler ret = {
7791                 .this_arg = (void*) calls,
7792                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7793                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7794                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7795                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7796                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7797                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7798                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7799                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7800                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7801                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7802                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7803                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7804                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7805                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7806                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7807                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7808                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7809                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7810                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7811                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7812                 .free = LDKChannelMessageHandler_JCalls_free,
7813                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
7814         };
7815         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7816         return ret;
7817 }
7818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
7819         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7820         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
7821         return (uint64_t)res_ptr;
7822 }
7823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
7824         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
7825         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
7826         DO_ASSERT((res_ptr & 1) == 0);
7827         return (int64_t)(res_ptr | 1);
7828 }
7829 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) {
7830         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7831         LDKPublicKey their_node_id_ref;
7832         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7833         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7834         LDKInitFeatures their_features_conv;
7835         their_features_conv.inner = (void*)(their_features & (~1));
7836         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7837         their_features_conv = InitFeatures_clone(&their_features_conv);
7838         LDKOpenChannel msg_conv;
7839         msg_conv.inner = (void*)(msg & (~1));
7840         msg_conv.is_owned = false;
7841         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7842 }
7843
7844 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) {
7845         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7846         LDKPublicKey their_node_id_ref;
7847         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7848         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7849         LDKInitFeatures their_features_conv;
7850         their_features_conv.inner = (void*)(their_features & (~1));
7851         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7852         their_features_conv = InitFeatures_clone(&their_features_conv);
7853         LDKAcceptChannel msg_conv;
7854         msg_conv.inner = (void*)(msg & (~1));
7855         msg_conv.is_owned = false;
7856         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7857 }
7858
7859 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) {
7860         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7861         LDKPublicKey their_node_id_ref;
7862         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7863         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7864         LDKFundingCreated msg_conv;
7865         msg_conv.inner = (void*)(msg & (~1));
7866         msg_conv.is_owned = false;
7867         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7868 }
7869
7870 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) {
7871         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7872         LDKPublicKey their_node_id_ref;
7873         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7874         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7875         LDKFundingSigned msg_conv;
7876         msg_conv.inner = (void*)(msg & (~1));
7877         msg_conv.is_owned = false;
7878         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7879 }
7880
7881 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) {
7882         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7883         LDKPublicKey their_node_id_ref;
7884         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7885         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7886         LDKFundingLocked msg_conv;
7887         msg_conv.inner = (void*)(msg & (~1));
7888         msg_conv.is_owned = false;
7889         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7890 }
7891
7892 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) {
7893         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7894         LDKPublicKey their_node_id_ref;
7895         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7896         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7897         LDKInitFeatures their_features_conv;
7898         their_features_conv.inner = (void*)(their_features & (~1));
7899         their_features_conv.is_owned = false;
7900         LDKShutdown msg_conv;
7901         msg_conv.inner = (void*)(msg & (~1));
7902         msg_conv.is_owned = false;
7903         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
7904 }
7905
7906 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) {
7907         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7908         LDKPublicKey their_node_id_ref;
7909         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7910         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7911         LDKClosingSigned msg_conv;
7912         msg_conv.inner = (void*)(msg & (~1));
7913         msg_conv.is_owned = false;
7914         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7915 }
7916
7917 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) {
7918         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7919         LDKPublicKey their_node_id_ref;
7920         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7921         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7922         LDKUpdateAddHTLC msg_conv;
7923         msg_conv.inner = (void*)(msg & (~1));
7924         msg_conv.is_owned = false;
7925         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7926 }
7927
7928 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) {
7929         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7930         LDKPublicKey their_node_id_ref;
7931         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7932         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7933         LDKUpdateFulfillHTLC msg_conv;
7934         msg_conv.inner = (void*)(msg & (~1));
7935         msg_conv.is_owned = false;
7936         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7937 }
7938
7939 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) {
7940         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7941         LDKPublicKey their_node_id_ref;
7942         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7943         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7944         LDKUpdateFailHTLC msg_conv;
7945         msg_conv.inner = (void*)(msg & (~1));
7946         msg_conv.is_owned = false;
7947         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7948 }
7949
7950 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) {
7951         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7952         LDKPublicKey their_node_id_ref;
7953         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7954         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7955         LDKUpdateFailMalformedHTLC msg_conv;
7956         msg_conv.inner = (void*)(msg & (~1));
7957         msg_conv.is_owned = false;
7958         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7959 }
7960
7961 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) {
7962         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7963         LDKPublicKey their_node_id_ref;
7964         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7965         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7966         LDKCommitmentSigned msg_conv;
7967         msg_conv.inner = (void*)(msg & (~1));
7968         msg_conv.is_owned = false;
7969         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7970 }
7971
7972 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) {
7973         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7974         LDKPublicKey their_node_id_ref;
7975         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7976         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7977         LDKRevokeAndACK msg_conv;
7978         msg_conv.inner = (void*)(msg & (~1));
7979         msg_conv.is_owned = false;
7980         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7981 }
7982
7983 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) {
7984         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7985         LDKPublicKey their_node_id_ref;
7986         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7987         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7988         LDKUpdateFee msg_conv;
7989         msg_conv.inner = (void*)(msg & (~1));
7990         msg_conv.is_owned = false;
7991         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7992 }
7993
7994 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) {
7995         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
7996         LDKPublicKey their_node_id_ref;
7997         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
7998         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
7999         LDKAnnouncementSignatures msg_conv;
8000         msg_conv.inner = (void*)(msg & (~1));
8001         msg_conv.is_owned = false;
8002         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8003 }
8004
8005 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) {
8006         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8007         LDKPublicKey their_node_id_ref;
8008         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8009         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8010         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
8011 }
8012
8013 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) {
8014         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8015         LDKPublicKey their_node_id_ref;
8016         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8017         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8018         LDKInit msg_conv;
8019         msg_conv.inner = (void*)(msg & (~1));
8020         msg_conv.is_owned = false;
8021         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8022 }
8023
8024 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) {
8025         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8026         LDKPublicKey their_node_id_ref;
8027         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8028         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8029         LDKChannelReestablish msg_conv;
8030         msg_conv.inner = (void*)(msg & (~1));
8031         msg_conv.is_owned = false;
8032         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8033 }
8034
8035 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) {
8036         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8037         LDKPublicKey their_node_id_ref;
8038         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8039         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8040         LDKChannelUpdate msg_conv;
8041         msg_conv.inner = (void*)(msg & (~1));
8042         msg_conv.is_owned = false;
8043         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8044 }
8045
8046 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) {
8047         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)(((uint64_t)this_arg) & ~1);
8048         LDKPublicKey their_node_id_ref;
8049         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8050         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8051         LDKErrorMessage msg_conv;
8052         msg_conv.inner = (void*)(msg & (~1));
8053         msg_conv.is_owned = false;
8054         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8055 }
8056
8057 typedef struct LDKRoutingMessageHandler_JCalls {
8058         atomic_size_t refcnt;
8059         JavaVM *vm;
8060         jweak o;
8061         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8062         jmethodID handle_node_announcement_meth;
8063         jmethodID handle_channel_announcement_meth;
8064         jmethodID handle_channel_update_meth;
8065         jmethodID handle_htlc_fail_channel_update_meth;
8066         jmethodID get_next_channel_announcements_meth;
8067         jmethodID get_next_node_announcements_meth;
8068         jmethodID sync_routing_table_meth;
8069         jmethodID handle_reply_channel_range_meth;
8070         jmethodID handle_reply_short_channel_ids_end_meth;
8071         jmethodID handle_query_channel_range_meth;
8072         jmethodID handle_query_short_channel_ids_meth;
8073 } LDKRoutingMessageHandler_JCalls;
8074 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
8075         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8076         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8077                 JNIEnv *env;
8078                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8079                 if (get_jenv_res == JNI_EDETACHED) {
8080                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8081                 } else {
8082                         DO_ASSERT(get_jenv_res == JNI_OK);
8083                 }
8084                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8085                 if (get_jenv_res == JNI_EDETACHED) {
8086                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8087                 }
8088                 FREE(j_calls);
8089         }
8090 }
8091 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
8092         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8093         JNIEnv *env;
8094         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8095         if (get_jenv_res == JNI_EDETACHED) {
8096                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8097         } else {
8098                 DO_ASSERT(get_jenv_res == JNI_OK);
8099         }
8100         LDKNodeAnnouncement msg_var = *msg;
8101         msg_var = NodeAnnouncement_clone(msg);
8102         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8103         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8104         uint64_t msg_ref = (uint64_t)msg_var.inner;
8105         if (msg_var.is_owned) {
8106                 msg_ref |= 1;
8107         }
8108         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8109         CHECK(obj != NULL);
8110         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
8111         if ((*env)->ExceptionCheck(env)) {
8112                 (*env)->ExceptionDescribe(env);
8113                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8114         }
8115         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8116         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8117         if (get_jenv_res == JNI_EDETACHED) {
8118                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8119         }
8120         return ret_conv;
8121 }
8122 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
8123         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8124         JNIEnv *env;
8125         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8126         if (get_jenv_res == JNI_EDETACHED) {
8127                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8128         } else {
8129                 DO_ASSERT(get_jenv_res == JNI_OK);
8130         }
8131         LDKChannelAnnouncement msg_var = *msg;
8132         msg_var = ChannelAnnouncement_clone(msg);
8133         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8134         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8135         uint64_t msg_ref = (uint64_t)msg_var.inner;
8136         if (msg_var.is_owned) {
8137                 msg_ref |= 1;
8138         }
8139         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8140         CHECK(obj != NULL);
8141         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
8142         if ((*env)->ExceptionCheck(env)) {
8143                 (*env)->ExceptionDescribe(env);
8144                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
8145         }
8146         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8147         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8148         if (get_jenv_res == JNI_EDETACHED) {
8149                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8150         }
8151         return ret_conv;
8152 }
8153 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
8154         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8155         JNIEnv *env;
8156         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8157         if (get_jenv_res == JNI_EDETACHED) {
8158                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8159         } else {
8160                 DO_ASSERT(get_jenv_res == JNI_OK);
8161         }
8162         LDKChannelUpdate msg_var = *msg;
8163         msg_var = ChannelUpdate_clone(msg);
8164         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8165         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8166         uint64_t msg_ref = (uint64_t)msg_var.inner;
8167         if (msg_var.is_owned) {
8168                 msg_ref |= 1;
8169         }
8170         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8171         CHECK(obj != NULL);
8172         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
8173         if ((*env)->ExceptionCheck(env)) {
8174                 (*env)->ExceptionDescribe(env);
8175                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8176         }
8177         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
8178         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1));
8179         if (get_jenv_res == JNI_EDETACHED) {
8180                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8181         }
8182         return ret_conv;
8183 }
8184 void handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
8185         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8186         JNIEnv *env;
8187         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8188         if (get_jenv_res == JNI_EDETACHED) {
8189                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8190         } else {
8191                 DO_ASSERT(get_jenv_res == JNI_OK);
8192         }
8193         uint64_t ret_update = (uint64_t)update;
8194         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8195         CHECK(obj != NULL);
8196         (*env)->CallVoidMethod(env, obj, j_calls->handle_htlc_fail_channel_update_meth, ret_update);
8197         if ((*env)->ExceptionCheck(env)) {
8198                 (*env)->ExceptionDescribe(env);
8199                 (*env)->FatalError(env, "A call to handle_htlc_fail_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
8200         }
8201         if (get_jenv_res == JNI_EDETACHED) {
8202                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8203         }
8204 }
8205 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
8206         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8207         JNIEnv *env;
8208         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8209         if (get_jenv_res == JNI_EDETACHED) {
8210                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8211         } else {
8212                 DO_ASSERT(get_jenv_res == JNI_OK);
8213         }
8214         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8215         CHECK(obj != NULL);
8216         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
8217         if ((*env)->ExceptionCheck(env)) {
8218                 (*env)->ExceptionDescribe(env);
8219                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8220         }
8221         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
8222         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8223         if (ret_constr.datalen > 0)
8224                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
8225         else
8226                 ret_constr.data = NULL;
8227         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8228         for (size_t l = 0; l < ret_constr.datalen; l++) {
8229                 int64_t ret_conv_63 = ret_vals[l];
8230                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1);
8231                 ret_conv_63_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)ret_conv_63) & ~1));
8232                 ret_constr.data[l] = ret_conv_63_conv;
8233         }
8234         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8235         if (get_jenv_res == JNI_EDETACHED) {
8236                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8237         }
8238         return ret_constr;
8239 }
8240 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
8241         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8242         JNIEnv *env;
8243         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8244         if (get_jenv_res == JNI_EDETACHED) {
8245                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8246         } else {
8247                 DO_ASSERT(get_jenv_res == JNI_OK);
8248         }
8249         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
8250         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
8251         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8252         CHECK(obj != NULL);
8253         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
8254         if ((*env)->ExceptionCheck(env)) {
8255                 (*env)->ExceptionDescribe(env);
8256                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
8257         }
8258         LDKCVec_NodeAnnouncementZ ret_constr;
8259         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
8260         if (ret_constr.datalen > 0)
8261                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
8262         else
8263                 ret_constr.data = NULL;
8264         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
8265         for (size_t s = 0; s < ret_constr.datalen; s++) {
8266                 int64_t ret_conv_18 = ret_vals[s];
8267                 LDKNodeAnnouncement ret_conv_18_conv;
8268                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
8269                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
8270                 ret_conv_18_conv = NodeAnnouncement_clone(&ret_conv_18_conv);
8271                 ret_constr.data[s] = ret_conv_18_conv;
8272         }
8273         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
8274         if (get_jenv_res == JNI_EDETACHED) {
8275                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8276         }
8277         return ret_constr;
8278 }
8279 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
8280         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8281         JNIEnv *env;
8282         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8283         if (get_jenv_res == JNI_EDETACHED) {
8284                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8285         } else {
8286                 DO_ASSERT(get_jenv_res == JNI_OK);
8287         }
8288         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8289         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8290         LDKInit init_var = *init;
8291         init_var = Init_clone(init);
8292         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8293         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8294         uint64_t init_ref = (uint64_t)init_var.inner;
8295         if (init_var.is_owned) {
8296                 init_ref |= 1;
8297         }
8298         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8299         CHECK(obj != NULL);
8300         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
8301         if ((*env)->ExceptionCheck(env)) {
8302                 (*env)->ExceptionDescribe(env);
8303                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
8304         }
8305         if (get_jenv_res == JNI_EDETACHED) {
8306                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8307         }
8308 }
8309 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
8310         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8311         JNIEnv *env;
8312         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8313         if (get_jenv_res == JNI_EDETACHED) {
8314                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8315         } else {
8316                 DO_ASSERT(get_jenv_res == JNI_OK);
8317         }
8318         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8319         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8320         LDKReplyChannelRange msg_var = msg;
8321         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8322         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8323         uint64_t msg_ref = (uint64_t)msg_var.inner;
8324         if (msg_var.is_owned) {
8325                 msg_ref |= 1;
8326         }
8327         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8328         CHECK(obj != NULL);
8329         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
8330         if ((*env)->ExceptionCheck(env)) {
8331                 (*env)->ExceptionDescribe(env);
8332                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8333         }
8334         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8335         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8336         if (get_jenv_res == JNI_EDETACHED) {
8337                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8338         }
8339         return ret_conv;
8340 }
8341 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8342         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8343         JNIEnv *env;
8344         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8345         if (get_jenv_res == JNI_EDETACHED) {
8346                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8347         } else {
8348                 DO_ASSERT(get_jenv_res == JNI_OK);
8349         }
8350         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8351         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8352         LDKReplyShortChannelIdsEnd msg_var = msg;
8353         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8354         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8355         uint64_t msg_ref = (uint64_t)msg_var.inner;
8356         if (msg_var.is_owned) {
8357                 msg_ref |= 1;
8358         }
8359         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8360         CHECK(obj != NULL);
8361         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
8362         if ((*env)->ExceptionCheck(env)) {
8363                 (*env)->ExceptionDescribe(env);
8364                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
8365         }
8366         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8367         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8368         if (get_jenv_res == JNI_EDETACHED) {
8369                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8370         }
8371         return ret_conv;
8372 }
8373 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8374         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8375         JNIEnv *env;
8376         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8377         if (get_jenv_res == JNI_EDETACHED) {
8378                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8379         } else {
8380                 DO_ASSERT(get_jenv_res == JNI_OK);
8381         }
8382         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8383         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8384         LDKQueryChannelRange msg_var = msg;
8385         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8386         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8387         uint64_t msg_ref = (uint64_t)msg_var.inner;
8388         if (msg_var.is_owned) {
8389                 msg_ref |= 1;
8390         }
8391         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8392         CHECK(obj != NULL);
8393         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
8394         if ((*env)->ExceptionCheck(env)) {
8395                 (*env)->ExceptionDescribe(env);
8396                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
8397         }
8398         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8399         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8400         if (get_jenv_res == JNI_EDETACHED) {
8401                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8402         }
8403         return ret_conv;
8404 }
8405 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8406         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8407         JNIEnv *env;
8408         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8409         if (get_jenv_res == JNI_EDETACHED) {
8410                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8411         } else {
8412                 DO_ASSERT(get_jenv_res == JNI_OK);
8413         }
8414         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8415         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8416         LDKQueryShortChannelIds msg_var = msg;
8417         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8418         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8419         uint64_t msg_ref = (uint64_t)msg_var.inner;
8420         if (msg_var.is_owned) {
8421                 msg_ref |= 1;
8422         }
8423         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8424         CHECK(obj != NULL);
8425         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
8426         if ((*env)->ExceptionCheck(env)) {
8427                 (*env)->ExceptionDescribe(env);
8428                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
8429         }
8430         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
8431         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1));
8432         if (get_jenv_res == JNI_EDETACHED) {
8433                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8434         }
8435         return ret_conv;
8436 }
8437 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
8438         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
8439         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8440         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8441 }
8442 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8443         jclass c = (*env)->GetObjectClass(env, o);
8444         CHECK(c != NULL);
8445         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8446         atomic_init(&calls->refcnt, 1);
8447         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8448         calls->o = (*env)->NewWeakGlobalRef(env, o);
8449         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
8450         CHECK(calls->handle_node_announcement_meth != NULL);
8451         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
8452         CHECK(calls->handle_channel_announcement_meth != NULL);
8453         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
8454         CHECK(calls->handle_channel_update_meth != NULL);
8455         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
8456         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
8457         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
8458         CHECK(calls->get_next_channel_announcements_meth != NULL);
8459         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
8460         CHECK(calls->get_next_node_announcements_meth != NULL);
8461         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
8462         CHECK(calls->sync_routing_table_meth != NULL);
8463         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
8464         CHECK(calls->handle_reply_channel_range_meth != NULL);
8465         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
8466         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
8467         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
8468         CHECK(calls->handle_query_channel_range_meth != NULL);
8469         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
8470         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
8471
8472         LDKRoutingMessageHandler ret = {
8473                 .this_arg = (void*) calls,
8474                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8475                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8476                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8477                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_LDKRoutingMessageHandler_jcall,
8478                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8479                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8480                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8481                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8482                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8483                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8484                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8485                 .free = LDKRoutingMessageHandler_JCalls_free,
8486                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8487         };
8488         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8489         return ret;
8490 }
8491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8492         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8493         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8494         return (uint64_t)res_ptr;
8495 }
8496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
8497         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
8498         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
8499         DO_ASSERT((res_ptr & 1) == 0);
8500         return (int64_t)(res_ptr | 1);
8501 }
8502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8503         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8504         LDKNodeAnnouncement msg_conv;
8505         msg_conv.inner = (void*)(msg & (~1));
8506         msg_conv.is_owned = false;
8507         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8508         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8509         return (uint64_t)ret_conv;
8510 }
8511
8512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8513         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8514         LDKChannelAnnouncement msg_conv;
8515         msg_conv.inner = (void*)(msg & (~1));
8516         msg_conv.is_owned = false;
8517         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8518         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8519         return (uint64_t)ret_conv;
8520 }
8521
8522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
8523         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8524         LDKChannelUpdate msg_conv;
8525         msg_conv.inner = (void*)(msg & (~1));
8526         msg_conv.is_owned = false;
8527         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8528         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
8529         return (uint64_t)ret_conv;
8530 }
8531
8532 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) {
8533         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8534         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
8535         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
8536 }
8537
8538 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) {
8539         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8540         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8541         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8542         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8543         for (size_t l = 0; l < ret_var.datalen; l++) {
8544                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8545                 *ret_conv_63_ref = ret_var.data[l];
8546                 ret_arr_ptr[l] = (uint64_t)ret_conv_63_ref;
8547         }
8548         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8549         FREE(ret_var.data);
8550         return ret_arr;
8551 }
8552
8553 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) {
8554         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8555         LDKPublicKey starting_point_ref;
8556         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
8557         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
8558         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8559         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8560         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8561         for (size_t s = 0; s < ret_var.datalen; s++) {
8562                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8563                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8564                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8565                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
8566                 if (ret_conv_18_var.is_owned) {
8567                         ret_conv_18_ref |= 1;
8568                 }
8569                 ret_arr_ptr[s] = ret_conv_18_ref;
8570         }
8571         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8572         FREE(ret_var.data);
8573         return ret_arr;
8574 }
8575
8576 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) {
8577         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8578         LDKPublicKey their_node_id_ref;
8579         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8580         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8581         LDKInit init_conv;
8582         init_conv.inner = (void*)(init & (~1));
8583         init_conv.is_owned = false;
8584         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8585 }
8586
8587 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) {
8588         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8589         LDKPublicKey their_node_id_ref;
8590         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8591         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8592         LDKReplyChannelRange msg_conv;
8593         msg_conv.inner = (void*)(msg & (~1));
8594         msg_conv.is_owned = (msg & 1) || (msg == 0);
8595         msg_conv = ReplyChannelRange_clone(&msg_conv);
8596         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8597         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8598         return (uint64_t)ret_conv;
8599 }
8600
8601 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) {
8602         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8603         LDKPublicKey their_node_id_ref;
8604         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8605         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8606         LDKReplyShortChannelIdsEnd msg_conv;
8607         msg_conv.inner = (void*)(msg & (~1));
8608         msg_conv.is_owned = (msg & 1) || (msg == 0);
8609         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8610         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8611         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8612         return (uint64_t)ret_conv;
8613 }
8614
8615 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) {
8616         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8617         LDKPublicKey their_node_id_ref;
8618         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8619         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8620         LDKQueryChannelRange msg_conv;
8621         msg_conv.inner = (void*)(msg & (~1));
8622         msg_conv.is_owned = (msg & 1) || (msg == 0);
8623         msg_conv = QueryChannelRange_clone(&msg_conv);
8624         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8625         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8626         return (uint64_t)ret_conv;
8627 }
8628
8629 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) {
8630         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)(((uint64_t)this_arg) & ~1);
8631         LDKPublicKey their_node_id_ref;
8632         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8633         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8634         LDKQueryShortChannelIds msg_conv;
8635         msg_conv.inner = (void*)(msg & (~1));
8636         msg_conv.is_owned = (msg & 1) || (msg == 0);
8637         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8638         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8639         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8640         return (uint64_t)ret_conv;
8641 }
8642
8643 typedef struct LDKSocketDescriptor_JCalls {
8644         atomic_size_t refcnt;
8645         JavaVM *vm;
8646         jweak o;
8647         jmethodID send_data_meth;
8648         jmethodID disconnect_socket_meth;
8649         jmethodID eq_meth;
8650         jmethodID hash_meth;
8651 } LDKSocketDescriptor_JCalls;
8652 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8653         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8654         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8655                 JNIEnv *env;
8656                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8657                 if (get_jenv_res == JNI_EDETACHED) {
8658                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8659                 } else {
8660                         DO_ASSERT(get_jenv_res == JNI_OK);
8661                 }
8662                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8663                 if (get_jenv_res == JNI_EDETACHED) {
8664                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8665                 }
8666                 FREE(j_calls);
8667         }
8668 }
8669 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8670         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8671         JNIEnv *env;
8672         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8673         if (get_jenv_res == JNI_EDETACHED) {
8674                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8675         } else {
8676                 DO_ASSERT(get_jenv_res == JNI_OK);
8677         }
8678         LDKu8slice data_var = data;
8679         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
8680         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
8681         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8682         CHECK(obj != NULL);
8683         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
8684         if ((*env)->ExceptionCheck(env)) {
8685                 (*env)->ExceptionDescribe(env);
8686                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
8687         }
8688         if (get_jenv_res == JNI_EDETACHED) {
8689                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8690         }
8691         return ret;
8692 }
8693 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8694         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8695         JNIEnv *env;
8696         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8697         if (get_jenv_res == JNI_EDETACHED) {
8698                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8699         } else {
8700                 DO_ASSERT(get_jenv_res == JNI_OK);
8701         }
8702         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8703         CHECK(obj != NULL);
8704         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
8705         if ((*env)->ExceptionCheck(env)) {
8706                 (*env)->ExceptionDescribe(env);
8707                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
8708         }
8709         if (get_jenv_res == JNI_EDETACHED) {
8710                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8711         }
8712 }
8713 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8714         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8715         JNIEnv *env;
8716         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8717         if (get_jenv_res == JNI_EDETACHED) {
8718                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8719         } else {
8720                 DO_ASSERT(get_jenv_res == JNI_OK);
8721         }
8722         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8723         *other_arg_clone = SocketDescriptor_clone(other_arg);
8724         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8725         CHECK(obj != NULL);
8726         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
8727         if ((*env)->ExceptionCheck(env)) {
8728                 (*env)->ExceptionDescribe(env);
8729                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
8730         }
8731         if (get_jenv_res == JNI_EDETACHED) {
8732                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8733         }
8734         return ret;
8735 }
8736 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8737         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8738         JNIEnv *env;
8739         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8740         if (get_jenv_res == JNI_EDETACHED) {
8741                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8742         } else {
8743                 DO_ASSERT(get_jenv_res == JNI_OK);
8744         }
8745         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8746         CHECK(obj != NULL);
8747         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
8748         if ((*env)->ExceptionCheck(env)) {
8749                 (*env)->ExceptionDescribe(env);
8750                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
8751         }
8752         if (get_jenv_res == JNI_EDETACHED) {
8753                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8754         }
8755         return ret;
8756 }
8757 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
8758         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
8759         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8760 }
8761 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
8762         jclass c = (*env)->GetObjectClass(env, o);
8763         CHECK(c != NULL);
8764         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8765         atomic_init(&calls->refcnt, 1);
8766         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8767         calls->o = (*env)->NewWeakGlobalRef(env, o);
8768         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
8769         CHECK(calls->send_data_meth != NULL);
8770         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
8771         CHECK(calls->disconnect_socket_meth != NULL);
8772         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
8773         CHECK(calls->eq_meth != NULL);
8774         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
8775         CHECK(calls->hash_meth != NULL);
8776
8777         LDKSocketDescriptor ret = {
8778                 .this_arg = (void*) calls,
8779                 .send_data = send_data_LDKSocketDescriptor_jcall,
8780                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8781                 .eq = eq_LDKSocketDescriptor_jcall,
8782                 .hash = hash_LDKSocketDescriptor_jcall,
8783                 .cloned = LDKSocketDescriptor_JCalls_cloned,
8784                 .free = LDKSocketDescriptor_JCalls_free,
8785         };
8786         return ret;
8787 }
8788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
8789         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8790         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
8791         return (uint64_t)res_ptr;
8792 }
8793 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) {
8794         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8795         LDKu8slice data_ref;
8796         data_ref.datalen = (*env)->GetArrayLength(env, data);
8797         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
8798         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8799         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
8800         return ret_val;
8801 }
8802
8803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
8804         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8805         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8806 }
8807
8808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
8809         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)(((uint64_t)this_arg) & ~1);
8810         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8811         return ret_val;
8812 }
8813
8814 typedef struct LDKChannelManagerPersister_JCalls {
8815         atomic_size_t refcnt;
8816         JavaVM *vm;
8817         jweak o;
8818         jmethodID persist_manager_meth;
8819 } LDKChannelManagerPersister_JCalls;
8820 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
8821         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8822         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8823                 JNIEnv *env;
8824                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8825                 if (get_jenv_res == JNI_EDETACHED) {
8826                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8827                 } else {
8828                         DO_ASSERT(get_jenv_res == JNI_OK);
8829                 }
8830                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8831                 if (get_jenv_res == JNI_EDETACHED) {
8832                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8833                 }
8834                 FREE(j_calls);
8835         }
8836 }
8837 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8838         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
8839         JNIEnv *env;
8840         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8841         if (get_jenv_res == JNI_EDETACHED) {
8842                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8843         } else {
8844                 DO_ASSERT(get_jenv_res == JNI_OK);
8845         }
8846         LDKChannelManager channel_manager_var = *channel_manager;
8847         // Warning: we may need a move here but no clone is available for LDKChannelManager
8848         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8849         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8850         uint64_t channel_manager_ref = (uint64_t)channel_manager_var.inner;
8851         if (channel_manager_var.is_owned) {
8852                 channel_manager_ref |= 1;
8853         }
8854         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8855         CHECK(obj != NULL);
8856         LDKCResult_NoneErrorZ* ret = (LDKCResult_NoneErrorZ*)(*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
8857         if ((*env)->ExceptionCheck(env)) {
8858                 (*env)->ExceptionDescribe(env);
8859                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
8860         }
8861         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1);
8862         ret_conv = CResult_NoneErrorZ_clone((LDKCResult_NoneErrorZ*)(((uint64_t)ret) & ~1));
8863         if (get_jenv_res == JNI_EDETACHED) {
8864                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8865         }
8866         return ret_conv;
8867 }
8868 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
8869         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
8870         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8871 }
8872 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
8873         jclass c = (*env)->GetObjectClass(env, o);
8874         CHECK(c != NULL);
8875         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
8876         atomic_init(&calls->refcnt, 1);
8877         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8878         calls->o = (*env)->NewWeakGlobalRef(env, o);
8879         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
8880         CHECK(calls->persist_manager_meth != NULL);
8881
8882         LDKChannelManagerPersister ret = {
8883                 .this_arg = (void*) calls,
8884                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
8885                 .free = LDKChannelManagerPersister_JCalls_free,
8886         };
8887         return ret;
8888 }
8889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
8890         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
8891         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
8892         return (uint64_t)res_ptr;
8893 }
8894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
8895         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)(((uint64_t)this_arg) & ~1);
8896         LDKChannelManager channel_manager_conv;
8897         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8898         channel_manager_conv.is_owned = false;
8899         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8900         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8901         return (uint64_t)ret_conv;
8902 }
8903
8904 static jclass LDKFallback_SegWitProgram_class = NULL;
8905 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
8906 static jclass LDKFallback_PubKeyHash_class = NULL;
8907 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
8908 static jclass LDKFallback_ScriptHash_class = NULL;
8909 static jmethodID LDKFallback_ScriptHash_meth = NULL;
8910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
8911         LDKFallback_SegWitProgram_class =
8912                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
8913         CHECK(LDKFallback_SegWitProgram_class != NULL);
8914         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
8915         CHECK(LDKFallback_SegWitProgram_meth != NULL);
8916         LDKFallback_PubKeyHash_class =
8917                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
8918         CHECK(LDKFallback_PubKeyHash_class != NULL);
8919         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
8920         CHECK(LDKFallback_PubKeyHash_meth != NULL);
8921         LDKFallback_ScriptHash_class =
8922                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
8923         CHECK(LDKFallback_ScriptHash_class != NULL);
8924         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
8925         CHECK(LDKFallback_ScriptHash_meth != NULL);
8926 }
8927 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8928         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
8929         switch(obj->tag) {
8930                 case LDKFallback_SegWitProgram: {
8931                         uint8_t version_val = obj->seg_wit_program.version._0;
8932                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
8933                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
8934                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
8935                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
8936                 }
8937                 case LDKFallback_PubKeyHash: {
8938                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
8939                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
8940                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
8941                 }
8942                 case LDKFallback_ScriptHash: {
8943                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
8944                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
8945                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
8946                 }
8947                 default: abort();
8948         }
8949 }
8950 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8951         LDKStr ret_str = _ldk_get_compiled_version();
8952         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8953         Str_free(ret_str);
8954         return ret_conv;
8955 }
8956
8957 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
8958         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
8959         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8960         Str_free(ret_str);
8961         return ret_conv;
8962 }
8963
8964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
8965         LDKTransaction _res_ref;
8966         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
8967         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
8968         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
8969         _res_ref.data_is_owned = true;
8970         Transaction_free(_res_ref);
8971 }
8972
8973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
8974         LDKCVec_u8Z script_pubkey_ref;
8975         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
8976         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
8977         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
8978         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8979         *ret_ref = TxOut_new(script_pubkey_ref, value);
8980         return (uint64_t)ret_ref;
8981 }
8982
8983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
8984         if ((_res & 1) != 0) return;
8985         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
8986         FREE((void*)_res);
8987         TxOut_free(_res_conv);
8988 }
8989
8990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
8991         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
8992         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8993         *ret_ref = TxOut_clone(orig_conv);
8994         return (uint64_t)ret_ref;
8995 }
8996
8997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
8998         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
8999         Str_free(dummy);
9000 }
9001
9002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9003         LDKSecretKey o_ref;
9004         CHECK((*env)->GetArrayLength(env, o) == 32);
9005         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
9006         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9007         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
9008         return (uint64_t)ret_conv;
9009 }
9010
9011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9012         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9013         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9014         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
9015         return (uint64_t)ret_conv;
9016 }
9017
9018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9019         if ((_res & 1) != 0) return;
9020         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(((uint64_t)_res) & ~1);
9021         FREE((void*)_res);
9022         CResult_SecretKeyErrorZ_free(_res_conv);
9023 }
9024
9025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
9026         LDKPublicKey o_ref;
9027         CHECK((*env)->GetArrayLength(env, o) == 33);
9028         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
9029         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9030         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
9031         return (uint64_t)ret_conv;
9032 }
9033
9034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9035         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9036         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9037         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
9038         return (uint64_t)ret_conv;
9039 }
9040
9041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9042         if ((_res & 1) != 0) return;
9043         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(((uint64_t)_res) & ~1);
9044         FREE((void*)_res);
9045         CResult_PublicKeyErrorZ_free(_res_conv);
9046 }
9047
9048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9049         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
9050         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9051         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
9052         return (uint64_t)ret_conv;
9053 }
9054
9055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9056         LDKTxCreationKeys o_conv;
9057         o_conv.inner = (void*)(o & (~1));
9058         o_conv.is_owned = (o & 1) || (o == 0);
9059         o_conv = TxCreationKeys_clone(&o_conv);
9060         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9061         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
9062         return (uint64_t)ret_conv;
9063 }
9064
9065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9066         LDKDecodeError e_conv;
9067         e_conv.inner = (void*)(e & (~1));
9068         e_conv.is_owned = (e & 1) || (e == 0);
9069         e_conv = DecodeError_clone(&e_conv);
9070         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9071         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
9072         return (uint64_t)ret_conv;
9073 }
9074
9075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9076         if ((_res & 1) != 0) return;
9077         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9078         FREE((void*)_res);
9079         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
9080 }
9081
9082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9083         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
9084         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9085         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
9086         return (uint64_t)ret_conv;
9087 }
9088
9089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9090         LDKChannelPublicKeys o_conv;
9091         o_conv.inner = (void*)(o & (~1));
9092         o_conv.is_owned = (o & 1) || (o == 0);
9093         o_conv = ChannelPublicKeys_clone(&o_conv);
9094         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9095         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
9096         return (uint64_t)ret_conv;
9097 }
9098
9099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9100         LDKDecodeError e_conv;
9101         e_conv.inner = (void*)(e & (~1));
9102         e_conv.is_owned = (e & 1) || (e == 0);
9103         e_conv = DecodeError_clone(&e_conv);
9104         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9105         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
9106         return (uint64_t)ret_conv;
9107 }
9108
9109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9110         if ((_res & 1) != 0) return;
9111         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
9112         FREE((void*)_res);
9113         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
9114 }
9115
9116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9117         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
9118         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9119         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
9120         return (uint64_t)ret_conv;
9121 }
9122
9123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9124         LDKTxCreationKeys o_conv;
9125         o_conv.inner = (void*)(o & (~1));
9126         o_conv.is_owned = (o & 1) || (o == 0);
9127         o_conv = TxCreationKeys_clone(&o_conv);
9128         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9129         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
9130         return (uint64_t)ret_conv;
9131 }
9132
9133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9134         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
9135         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9136         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
9137         return (uint64_t)ret_conv;
9138 }
9139
9140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9141         if ((_res & 1) != 0) return;
9142         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(((uint64_t)_res) & ~1);
9143         FREE((void*)_res);
9144         CResult_TxCreationKeysErrorZ_free(_res_conv);
9145 }
9146
9147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9148         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
9149         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9150         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
9151         return (uint64_t)ret_conv;
9152 }
9153
9154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
9155         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9156         *ret_copy = COption_u32Z_some(o);
9157         uint64_t ret_ref = (uint64_t)ret_copy;
9158         return ret_ref;
9159 }
9160
9161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
9162         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9163         *ret_copy = COption_u32Z_none();
9164         uint64_t ret_ref = (uint64_t)ret_copy;
9165         return ret_ref;
9166 }
9167
9168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9169         if ((_res & 1) != 0) return;
9170         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(((uint64_t)_res) & ~1);
9171         FREE((void*)_res);
9172         COption_u32Z_free(_res_conv);
9173 }
9174
9175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9176         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
9177         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9178         *ret_copy = COption_u32Z_clone(orig_conv);
9179         uint64_t ret_ref = (uint64_t)ret_copy;
9180         return ret_ref;
9181 }
9182
9183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9184         LDKHTLCOutputInCommitment o_conv;
9185         o_conv.inner = (void*)(o & (~1));
9186         o_conv.is_owned = (o & 1) || (o == 0);
9187         o_conv = HTLCOutputInCommitment_clone(&o_conv);
9188         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9189         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
9190         return (uint64_t)ret_conv;
9191 }
9192
9193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9194         LDKDecodeError e_conv;
9195         e_conv.inner = (void*)(e & (~1));
9196         e_conv.is_owned = (e & 1) || (e == 0);
9197         e_conv = DecodeError_clone(&e_conv);
9198         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9199         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
9200         return (uint64_t)ret_conv;
9201 }
9202
9203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9204         if ((_res & 1) != 0) return;
9205         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(((uint64_t)_res) & ~1);
9206         FREE((void*)_res);
9207         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
9208 }
9209
9210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9211         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
9212         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9213         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
9214         return (uint64_t)ret_conv;
9215 }
9216
9217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9218         LDKCounterpartyChannelTransactionParameters o_conv;
9219         o_conv.inner = (void*)(o & (~1));
9220         o_conv.is_owned = (o & 1) || (o == 0);
9221         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
9222         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9223         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9224         return (uint64_t)ret_conv;
9225 }
9226
9227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9228         LDKDecodeError e_conv;
9229         e_conv.inner = (void*)(e & (~1));
9230         e_conv.is_owned = (e & 1) || (e == 0);
9231         e_conv = DecodeError_clone(&e_conv);
9232         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9233         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
9234         return (uint64_t)ret_conv;
9235 }
9236
9237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9238         if ((_res & 1) != 0) return;
9239         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9240         FREE((void*)_res);
9241         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9242 }
9243
9244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9245         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9246         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9247         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9248         return (uint64_t)ret_conv;
9249 }
9250
9251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9252         LDKChannelTransactionParameters o_conv;
9253         o_conv.inner = (void*)(o & (~1));
9254         o_conv.is_owned = (o & 1) || (o == 0);
9255         o_conv = ChannelTransactionParameters_clone(&o_conv);
9256         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9257         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9258         return (uint64_t)ret_conv;
9259 }
9260
9261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9262         LDKDecodeError e_conv;
9263         e_conv.inner = (void*)(e & (~1));
9264         e_conv.is_owned = (e & 1) || (e == 0);
9265         e_conv = DecodeError_clone(&e_conv);
9266         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9267         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
9268         return (uint64_t)ret_conv;
9269 }
9270
9271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9272         if ((_res & 1) != 0) return;
9273         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(((uint64_t)_res) & ~1);
9274         FREE((void*)_res);
9275         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9276 }
9277
9278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9279         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9280         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9281         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9282         return (uint64_t)ret_conv;
9283 }
9284
9285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9286         LDKCVec_SignatureZ _res_constr;
9287         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9288         if (_res_constr.datalen > 0)
9289                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9290         else
9291                 _res_constr.data = NULL;
9292         for (size_t i = 0; i < _res_constr.datalen; i++) {
9293                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9294                 LDKSignature _res_conv_8_ref;
9295                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
9296                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
9297                 _res_constr.data[i] = _res_conv_8_ref;
9298         }
9299         CVec_SignatureZ_free(_res_constr);
9300 }
9301
9302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9303         LDKHolderCommitmentTransaction o_conv;
9304         o_conv.inner = (void*)(o & (~1));
9305         o_conv.is_owned = (o & 1) || (o == 0);
9306         o_conv = HolderCommitmentTransaction_clone(&o_conv);
9307         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9308         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
9309         return (uint64_t)ret_conv;
9310 }
9311
9312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9313         LDKDecodeError e_conv;
9314         e_conv.inner = (void*)(e & (~1));
9315         e_conv.is_owned = (e & 1) || (e == 0);
9316         e_conv = DecodeError_clone(&e_conv);
9317         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9318         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
9319         return (uint64_t)ret_conv;
9320 }
9321
9322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9323         if ((_res & 1) != 0) return;
9324         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9325         FREE((void*)_res);
9326         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
9327 }
9328
9329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9330         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9331         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9332         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9333         return (uint64_t)ret_conv;
9334 }
9335
9336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9337         LDKBuiltCommitmentTransaction o_conv;
9338         o_conv.inner = (void*)(o & (~1));
9339         o_conv.is_owned = (o & 1) || (o == 0);
9340         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
9341         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9342         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
9343         return (uint64_t)ret_conv;
9344 }
9345
9346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9347         LDKDecodeError e_conv;
9348         e_conv.inner = (void*)(e & (~1));
9349         e_conv.is_owned = (e & 1) || (e == 0);
9350         e_conv = DecodeError_clone(&e_conv);
9351         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9352         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
9353         return (uint64_t)ret_conv;
9354 }
9355
9356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9357         if ((_res & 1) != 0) return;
9358         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9359         FREE((void*)_res);
9360         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
9361 }
9362
9363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9364         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9365         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9366         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9367         return (uint64_t)ret_conv;
9368 }
9369
9370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9371         LDKCommitmentTransaction o_conv;
9372         o_conv.inner = (void*)(o & (~1));
9373         o_conv.is_owned = (o & 1) || (o == 0);
9374         o_conv = CommitmentTransaction_clone(&o_conv);
9375         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9376         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9377         return (uint64_t)ret_conv;
9378 }
9379
9380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9381         LDKDecodeError e_conv;
9382         e_conv.inner = (void*)(e & (~1));
9383         e_conv.is_owned = (e & 1) || (e == 0);
9384         e_conv = DecodeError_clone(&e_conv);
9385         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9386         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9387         return (uint64_t)ret_conv;
9388 }
9389
9390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9391         if ((_res & 1) != 0) return;
9392         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(((uint64_t)_res) & ~1);
9393         FREE((void*)_res);
9394         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9395 }
9396
9397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9398         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9399         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9400         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9401         return (uint64_t)ret_conv;
9402 }
9403
9404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9405         LDKTrustedCommitmentTransaction o_conv;
9406         o_conv.inner = (void*)(o & (~1));
9407         o_conv.is_owned = (o & 1) || (o == 0);
9408         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9409         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9410         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9411         return (uint64_t)ret_conv;
9412 }
9413
9414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
9415         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9416         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9417         return (uint64_t)ret_conv;
9418 }
9419
9420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9421         if ((_res & 1) != 0) return;
9422         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
9423         FREE((void*)_res);
9424         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9425 }
9426
9427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
9428         LDKCVec_SignatureZ o_constr;
9429         o_constr.datalen = (*env)->GetArrayLength(env, o);
9430         if (o_constr.datalen > 0)
9431                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9432         else
9433                 o_constr.data = NULL;
9434         for (size_t i = 0; i < o_constr.datalen; i++) {
9435                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
9436                 LDKSignature o_conv_8_ref;
9437                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
9438                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
9439                 o_constr.data[i] = o_conv_8_ref;
9440         }
9441         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9442         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9443         return (uint64_t)ret_conv;
9444 }
9445
9446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
9447         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9448         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9449         return (uint64_t)ret_conv;
9450 }
9451
9452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9453         if ((_res & 1) != 0) return;
9454         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
9455         FREE((void*)_res);
9456         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9457 }
9458
9459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9460         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9461         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9462         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9463         return (uint64_t)ret_conv;
9464 }
9465
9466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
9467         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9468         *ret_conv = CResult_NoneErrorZ_ok();
9469         return (uint64_t)ret_conv;
9470 }
9471
9472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9473         LDKIOError e_conv = LDKIOError_from_java(env, e);
9474         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9475         *ret_conv = CResult_NoneErrorZ_err(e_conv);
9476         return (uint64_t)ret_conv;
9477 }
9478
9479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9480         if ((_res & 1) != 0) return;
9481         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(((uint64_t)_res) & ~1);
9482         FREE((void*)_res);
9483         CResult_NoneErrorZ_free(_res_conv);
9484 }
9485
9486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9487         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
9488         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9489         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
9490         return (uint64_t)ret_conv;
9491 }
9492
9493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9494         LDKRouteHop o_conv;
9495         o_conv.inner = (void*)(o & (~1));
9496         o_conv.is_owned = (o & 1) || (o == 0);
9497         o_conv = RouteHop_clone(&o_conv);
9498         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9499         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
9500         return (uint64_t)ret_conv;
9501 }
9502
9503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9504         LDKDecodeError e_conv;
9505         e_conv.inner = (void*)(e & (~1));
9506         e_conv.is_owned = (e & 1) || (e == 0);
9507         e_conv = DecodeError_clone(&e_conv);
9508         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9509         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
9510         return (uint64_t)ret_conv;
9511 }
9512
9513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9514         if ((_res & 1) != 0) return;
9515         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(((uint64_t)_res) & ~1);
9516         FREE((void*)_res);
9517         CResult_RouteHopDecodeErrorZ_free(_res_conv);
9518 }
9519
9520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9521         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
9522         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9523         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
9524         return (uint64_t)ret_conv;
9525 }
9526
9527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9528         LDKCVec_RouteHopZ _res_constr;
9529         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9530         if (_res_constr.datalen > 0)
9531                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9532         else
9533                 _res_constr.data = NULL;
9534         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9535         for (size_t k = 0; k < _res_constr.datalen; k++) {
9536                 int64_t _res_conv_10 = _res_vals[k];
9537                 LDKRouteHop _res_conv_10_conv;
9538                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
9539                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
9540                 _res_constr.data[k] = _res_conv_10_conv;
9541         }
9542         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9543         CVec_RouteHopZ_free(_res_constr);
9544 }
9545
9546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9547         LDKCVec_CVec_RouteHopZZ _res_constr;
9548         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9549         if (_res_constr.datalen > 0)
9550                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
9551         else
9552                 _res_constr.data = NULL;
9553         for (size_t m = 0; m < _res_constr.datalen; m++) {
9554                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
9555                 LDKCVec_RouteHopZ _res_conv_12_constr;
9556                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
9557                 if (_res_conv_12_constr.datalen > 0)
9558                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9559                 else
9560                         _res_conv_12_constr.data = NULL;
9561                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
9562                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
9563                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
9564                         LDKRouteHop _res_conv_12_conv_10_conv;
9565                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
9566                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
9567                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
9568                 }
9569                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
9570                 _res_constr.data[m] = _res_conv_12_constr;
9571         }
9572         CVec_CVec_RouteHopZZ_free(_res_constr);
9573 }
9574
9575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9576         LDKRoute o_conv;
9577         o_conv.inner = (void*)(o & (~1));
9578         o_conv.is_owned = (o & 1) || (o == 0);
9579         o_conv = Route_clone(&o_conv);
9580         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9581         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
9582         return (uint64_t)ret_conv;
9583 }
9584
9585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9586         LDKDecodeError e_conv;
9587         e_conv.inner = (void*)(e & (~1));
9588         e_conv.is_owned = (e & 1) || (e == 0);
9589         e_conv = DecodeError_clone(&e_conv);
9590         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9591         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
9592         return (uint64_t)ret_conv;
9593 }
9594
9595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9596         if ((_res & 1) != 0) return;
9597         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
9598         FREE((void*)_res);
9599         CResult_RouteDecodeErrorZ_free(_res_conv);
9600 }
9601
9602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9603         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
9604         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9605         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
9606         return (uint64_t)ret_conv;
9607 }
9608
9609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
9610         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9611         *ret_copy = COption_u64Z_some(o);
9612         uint64_t ret_ref = (uint64_t)ret_copy;
9613         return ret_ref;
9614 }
9615
9616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
9617         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9618         *ret_copy = COption_u64Z_none();
9619         uint64_t ret_ref = (uint64_t)ret_copy;
9620         return ret_ref;
9621 }
9622
9623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
9624         if ((_res & 1) != 0) return;
9625         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(((uint64_t)_res) & ~1);
9626         FREE((void*)_res);
9627         COption_u64Z_free(_res_conv);
9628 }
9629
9630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9631         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9632         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9633         *ret_copy = COption_u64Z_clone(orig_conv);
9634         uint64_t ret_ref = (uint64_t)ret_copy;
9635         return ret_ref;
9636 }
9637
9638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9639         LDKCVec_ChannelDetailsZ _res_constr;
9640         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9641         if (_res_constr.datalen > 0)
9642                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9643         else
9644                 _res_constr.data = NULL;
9645         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9646         for (size_t q = 0; q < _res_constr.datalen; q++) {
9647                 int64_t _res_conv_16 = _res_vals[q];
9648                 LDKChannelDetails _res_conv_16_conv;
9649                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9650                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9651                 _res_constr.data[q] = _res_conv_16_conv;
9652         }
9653         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9654         CVec_ChannelDetailsZ_free(_res_constr);
9655 }
9656
9657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9658         LDKCVec_RouteHintZ _res_constr;
9659         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9660         if (_res_constr.datalen > 0)
9661                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9662         else
9663                 _res_constr.data = NULL;
9664         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9665         for (size_t l = 0; l < _res_constr.datalen; l++) {
9666                 int64_t _res_conv_11 = _res_vals[l];
9667                 LDKRouteHint _res_conv_11_conv;
9668                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9669                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9670                 _res_constr.data[l] = _res_conv_11_conv;
9671         }
9672         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9673         CVec_RouteHintZ_free(_res_constr);
9674 }
9675
9676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9677         LDKRoute o_conv;
9678         o_conv.inner = (void*)(o & (~1));
9679         o_conv.is_owned = (o & 1) || (o == 0);
9680         o_conv = Route_clone(&o_conv);
9681         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9682         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9683         return (uint64_t)ret_conv;
9684 }
9685
9686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9687         LDKLightningError e_conv;
9688         e_conv.inner = (void*)(e & (~1));
9689         e_conv.is_owned = (e & 1) || (e == 0);
9690         e_conv = LightningError_clone(&e_conv);
9691         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9692         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9693         return (uint64_t)ret_conv;
9694 }
9695
9696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9697         if ((_res & 1) != 0) return;
9698         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
9699         FREE((void*)_res);
9700         CResult_RouteLightningErrorZ_free(_res_conv);
9701 }
9702
9703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9704         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9705         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9706         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9707         return (uint64_t)ret_conv;
9708 }
9709
9710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9711         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
9712         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9713         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9714         return (uint64_t)ret_conv;
9715 }
9716
9717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
9718         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
9719         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9720         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9721         return (uint64_t)ret_conv;
9722 }
9723
9724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9725         if ((_res & 1) != 0) return;
9726         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
9727         FREE((void*)_res);
9728         CResult_TxOutAccessErrorZ_free(_res_conv);
9729 }
9730
9731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9732         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9733         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9734         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9735         return (uint64_t)ret_conv;
9736 }
9737
9738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9739         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9740         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9741         *ret_ref = C2Tuple_usizeTransactionZ_clone(orig_conv);
9742         return (uint64_t)ret_ref;
9743 }
9744
9745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
9746         LDKTransaction b_ref;
9747         b_ref.datalen = (*env)->GetArrayLength(env, b);
9748         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9749         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
9750         b_ref.data_is_owned = true;
9751         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9752         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
9753         return (uint64_t)ret_ref;
9754 }
9755
9756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9757         if ((_res & 1) != 0) return;
9758         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
9759         FREE((void*)_res);
9760         C2Tuple_usizeTransactionZ_free(_res_conv);
9761 }
9762
9763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9764         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9765         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9766         if (_res_constr.datalen > 0)
9767                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9768         else
9769                 _res_constr.data = NULL;
9770         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9771         for (size_t y = 0; y < _res_constr.datalen; y++) {
9772                 int64_t _res_conv_24 = _res_vals[y];
9773                 LDKC2Tuple_usizeTransactionZ _res_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res_conv_24) & ~1);
9774                 FREE((void*)_res_conv_24);
9775                 _res_constr.data[y] = _res_conv_24_conv;
9776         }
9777         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9778         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9779 }
9780
9781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
9782         LDKCVec_TxidZ _res_constr;
9783         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9784         if (_res_constr.datalen > 0)
9785                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9786         else
9787                 _res_constr.data = NULL;
9788         for (size_t i = 0; i < _res_constr.datalen; i++) {
9789                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
9790                 LDKThirtyTwoBytes _res_conv_8_ref;
9791                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
9792                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
9793                 _res_constr.data[i] = _res_conv_8_ref;
9794         }
9795         CVec_TxidZ_free(_res_constr);
9796 }
9797
9798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
9799         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9800         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
9801         return (uint64_t)ret_conv;
9802 }
9803
9804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
9805         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
9806         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9807         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
9808         return (uint64_t)ret_conv;
9809 }
9810
9811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9812         if ((_res & 1) != 0) return;
9813         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
9814         FREE((void*)_res);
9815         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
9816 }
9817
9818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9819         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
9820         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9821         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
9822         return (uint64_t)ret_conv;
9823 }
9824
9825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9826         LDKCVec_MonitorEventZ _res_constr;
9827         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9828         if (_res_constr.datalen > 0)
9829                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
9830         else
9831                 _res_constr.data = NULL;
9832         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9833         for (size_t o = 0; o < _res_constr.datalen; o++) {
9834                 int64_t _res_conv_14 = _res_vals[o];
9835                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(((uint64_t)_res_conv_14) & ~1);
9836                 FREE((void*)_res_conv_14);
9837                 _res_constr.data[o] = _res_conv_14_conv;
9838         }
9839         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9840         CVec_MonitorEventZ_free(_res_constr);
9841 }
9842
9843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
9844         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1);
9845         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9846         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
9847         uint64_t ret_ref = (uint64_t)ret_copy;
9848         return ret_ref;
9849 }
9850
9851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
9852         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9853         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
9854         uint64_t ret_ref = (uint64_t)ret_copy;
9855         return ret_ref;
9856 }
9857
9858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9859         if ((_res & 1) != 0) return;
9860         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)_res) & ~1);
9861         FREE((void*)_res);
9862         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
9863 }
9864
9865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
9866         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
9867         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9868         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
9869         uint64_t ret_ref = (uint64_t)ret_copy;
9870         return ret_ref;
9871 }
9872
9873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9874         LDKCVec_SpendableOutputDescriptorZ _res_constr;
9875         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9876         if (_res_constr.datalen > 0)
9877                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
9878         else
9879                 _res_constr.data = NULL;
9880         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9881         for (size_t b = 0; b < _res_constr.datalen; b++) {
9882                 int64_t _res_conv_27 = _res_vals[b];
9883                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)_res_conv_27) & ~1);
9884                 FREE((void*)_res_conv_27);
9885                 _res_constr.data[b] = _res_conv_27_conv;
9886         }
9887         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9888         CVec_SpendableOutputDescriptorZ_free(_res_constr);
9889 }
9890
9891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
9892         LDKCVec_MessageSendEventZ _res_constr;
9893         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
9894         if (_res_constr.datalen > 0)
9895                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9896         else
9897                 _res_constr.data = NULL;
9898         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
9899         for (size_t s = 0; s < _res_constr.datalen; s++) {
9900                 int64_t _res_conv_18 = _res_vals[s];
9901                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)_res_conv_18) & ~1);
9902                 FREE((void*)_res_conv_18);
9903                 _res_constr.data[s] = _res_conv_18_conv;
9904         }
9905         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
9906         CVec_MessageSendEventZ_free(_res_constr);
9907 }
9908
9909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9910         LDKInitFeatures o_conv;
9911         o_conv.inner = (void*)(o & (~1));
9912         o_conv.is_owned = (o & 1) || (o == 0);
9913         o_conv = InitFeatures_clone(&o_conv);
9914         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9915         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
9916         return (uint64_t)ret_conv;
9917 }
9918
9919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9920         LDKDecodeError e_conv;
9921         e_conv.inner = (void*)(e & (~1));
9922         e_conv.is_owned = (e & 1) || (e == 0);
9923         e_conv = DecodeError_clone(&e_conv);
9924         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
9925         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
9926         return (uint64_t)ret_conv;
9927 }
9928
9929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9930         if ((_res & 1) != 0) return;
9931         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9932         FREE((void*)_res);
9933         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
9934 }
9935
9936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9937         LDKNodeFeatures o_conv;
9938         o_conv.inner = (void*)(o & (~1));
9939         o_conv.is_owned = (o & 1) || (o == 0);
9940         o_conv = NodeFeatures_clone(&o_conv);
9941         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9942         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
9943         return (uint64_t)ret_conv;
9944 }
9945
9946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9947         LDKDecodeError e_conv;
9948         e_conv.inner = (void*)(e & (~1));
9949         e_conv.is_owned = (e & 1) || (e == 0);
9950         e_conv = DecodeError_clone(&e_conv);
9951         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
9952         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
9953         return (uint64_t)ret_conv;
9954 }
9955
9956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9957         if ((_res & 1) != 0) return;
9958         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9959         FREE((void*)_res);
9960         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
9961 }
9962
9963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9964         LDKChannelFeatures o_conv;
9965         o_conv.inner = (void*)(o & (~1));
9966         o_conv.is_owned = (o & 1) || (o == 0);
9967         o_conv = ChannelFeatures_clone(&o_conv);
9968         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9969         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
9970         return (uint64_t)ret_conv;
9971 }
9972
9973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
9974         LDKDecodeError e_conv;
9975         e_conv.inner = (void*)(e & (~1));
9976         e_conv.is_owned = (e & 1) || (e == 0);
9977         e_conv = DecodeError_clone(&e_conv);
9978         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
9979         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
9980         return (uint64_t)ret_conv;
9981 }
9982
9983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
9984         if ((_res & 1) != 0) return;
9985         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
9986         FREE((void*)_res);
9987         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
9988 }
9989
9990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
9991         LDKInvoiceFeatures o_conv;
9992         o_conv.inner = (void*)(o & (~1));
9993         o_conv.is_owned = (o & 1) || (o == 0);
9994         o_conv = InvoiceFeatures_clone(&o_conv);
9995         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
9996         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
9997         return (uint64_t)ret_conv;
9998 }
9999
10000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10001         LDKDecodeError e_conv;
10002         e_conv.inner = (void*)(e & (~1));
10003         e_conv.is_owned = (e & 1) || (e == 0);
10004         e_conv = DecodeError_clone(&e_conv);
10005         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10006         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
10007         return (uint64_t)ret_conv;
10008 }
10009
10010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10011         if ((_res & 1) != 0) return;
10012         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
10013         FREE((void*)_res);
10014         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
10015 }
10016
10017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10018         LDKDelayedPaymentOutputDescriptor o_conv;
10019         o_conv.inner = (void*)(o & (~1));
10020         o_conv.is_owned = (o & 1) || (o == 0);
10021         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
10022         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10023         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10024         return (uint64_t)ret_conv;
10025 }
10026
10027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10028         LDKDecodeError e_conv;
10029         e_conv.inner = (void*)(e & (~1));
10030         e_conv.is_owned = (e & 1) || (e == 0);
10031         e_conv = DecodeError_clone(&e_conv);
10032         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10033         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10034         return (uint64_t)ret_conv;
10035 }
10036
10037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10038         if ((_res & 1) != 0) return;
10039         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10040         FREE((void*)_res);
10041         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10042 }
10043
10044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10045         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10046         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10047         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10048         return (uint64_t)ret_conv;
10049 }
10050
10051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10052         LDKStaticPaymentOutputDescriptor o_conv;
10053         o_conv.inner = (void*)(o & (~1));
10054         o_conv.is_owned = (o & 1) || (o == 0);
10055         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
10056         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10057         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10058         return (uint64_t)ret_conv;
10059 }
10060
10061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10062         LDKDecodeError e_conv;
10063         e_conv.inner = (void*)(e & (~1));
10064         e_conv.is_owned = (e & 1) || (e == 0);
10065         e_conv = DecodeError_clone(&e_conv);
10066         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10067         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10068         return (uint64_t)ret_conv;
10069 }
10070
10071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10072         if ((_res & 1) != 0) return;
10073         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10074         FREE((void*)_res);
10075         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10076 }
10077
10078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10079         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10080         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10081         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10082         return (uint64_t)ret_conv;
10083 }
10084
10085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10086         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
10087         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10088         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
10089         return (uint64_t)ret_conv;
10090 }
10091
10092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10093         LDKDecodeError e_conv;
10094         e_conv.inner = (void*)(e & (~1));
10095         e_conv.is_owned = (e & 1) || (e == 0);
10096         e_conv = DecodeError_clone(&e_conv);
10097         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10098         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
10099         return (uint64_t)ret_conv;
10100 }
10101
10102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10103         if ((_res & 1) != 0) return;
10104         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
10105         FREE((void*)_res);
10106         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
10107 }
10108
10109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10110         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
10111         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10112         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
10113         return (uint64_t)ret_conv;
10114 }
10115
10116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10117         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
10118         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10119         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
10120         return (uint64_t)ret_ref;
10121 }
10122
10123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
10124         LDKSignature a_ref;
10125         CHECK((*env)->GetArrayLength(env, a) == 64);
10126         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
10127         LDKCVec_SignatureZ b_constr;
10128         b_constr.datalen = (*env)->GetArrayLength(env, b);
10129         if (b_constr.datalen > 0)
10130                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10131         else
10132                 b_constr.data = NULL;
10133         for (size_t i = 0; i < b_constr.datalen; i++) {
10134                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
10135                 LDKSignature b_conv_8_ref;
10136                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
10137                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
10138                 b_constr.data[i] = b_conv_8_ref;
10139         }
10140         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10141         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
10142         return (uint64_t)ret_ref;
10143 }
10144
10145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10146         if ((_res & 1) != 0) return;
10147         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
10148         FREE((void*)_res);
10149         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
10150 }
10151
10152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10153         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
10154         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10155         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
10156         return (uint64_t)ret_conv;
10157 }
10158
10159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
10160         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10161         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
10162         return (uint64_t)ret_conv;
10163 }
10164
10165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10166         if ((_res & 1) != 0) return;
10167         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
10168         FREE((void*)_res);
10169         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
10170 }
10171
10172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10173         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
10174         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10175         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
10176         return (uint64_t)ret_conv;
10177 }
10178
10179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10180         LDKSignature o_ref;
10181         CHECK((*env)->GetArrayLength(env, o) == 64);
10182         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
10183         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10184         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
10185         return (uint64_t)ret_conv;
10186 }
10187
10188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10189         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10190         *ret_conv = CResult_SignatureNoneZ_err();
10191         return (uint64_t)ret_conv;
10192 }
10193
10194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10195         if ((_res & 1) != 0) return;
10196         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
10197         FREE((void*)_res);
10198         CResult_SignatureNoneZ_free(_res_conv);
10199 }
10200
10201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10202         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
10203         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10204         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
10205         return (uint64_t)ret_conv;
10206 }
10207
10208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10209         LDKSign o_conv = *(LDKSign*)(((uint64_t)o) & ~1);
10210         if (o_conv.free == LDKSign_JCalls_free) {
10211                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10212                 LDKSign_JCalls_cloned(&o_conv);
10213         }
10214         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10215         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
10216         return (uint64_t)ret_conv;
10217 }
10218
10219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10220         LDKDecodeError e_conv;
10221         e_conv.inner = (void*)(e & (~1));
10222         e_conv.is_owned = (e & 1) || (e == 0);
10223         e_conv = DecodeError_clone(&e_conv);
10224         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10225         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
10226         return (uint64_t)ret_conv;
10227 }
10228
10229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10230         if ((_res & 1) != 0) return;
10231         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(((uint64_t)_res) & ~1);
10232         FREE((void*)_res);
10233         CResult_SignDecodeErrorZ_free(_res_conv);
10234 }
10235
10236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10237         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
10238         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10239         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
10240         return (uint64_t)ret_conv;
10241 }
10242
10243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
10244         LDKCVec_u8Z _res_ref;
10245         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
10246         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
10247         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
10248         CVec_u8Z_free(_res_ref);
10249 }
10250
10251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
10252         LDKRecoverableSignature arg_ref;
10253         CHECK((*env)->GetArrayLength(env, arg) == 68);
10254         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
10255         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10256         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
10257         return (uint64_t)ret_conv;
10258 }
10259
10260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
10261         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10262         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
10263         return (uint64_t)ret_conv;
10264 }
10265
10266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10267         if ((_res & 1) != 0) return;
10268         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)_res) & ~1);
10269         FREE((void*)_res);
10270         CResult_RecoverableSignatureNoneZ_free(_res_conv);
10271 }
10272
10273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10274         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
10275         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10276         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
10277         return (uint64_t)ret_conv;
10278 }
10279
10280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
10281         LDKCVec_CVec_u8ZZ _res_constr;
10282         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10283         if (_res_constr.datalen > 0)
10284                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10285         else
10286                 _res_constr.data = NULL;
10287         for (size_t i = 0; i < _res_constr.datalen; i++) {
10288                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
10289                 LDKCVec_u8Z _res_conv_8_ref;
10290                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
10291                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10292                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
10293                 _res_constr.data[i] = _res_conv_8_ref;
10294         }
10295         CVec_CVec_u8ZZ_free(_res_constr);
10296 }
10297
10298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
10299         LDKCVec_CVec_u8ZZ o_constr;
10300         o_constr.datalen = (*env)->GetArrayLength(env, o);
10301         if (o_constr.datalen > 0)
10302                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10303         else
10304                 o_constr.data = NULL;
10305         for (size_t i = 0; i < o_constr.datalen; i++) {
10306                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
10307                 LDKCVec_u8Z o_conv_8_ref;
10308                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
10309                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
10310                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
10311                 o_constr.data[i] = o_conv_8_ref;
10312         }
10313         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10314         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
10315         return (uint64_t)ret_conv;
10316 }
10317
10318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
10319         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10320         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
10321         return (uint64_t)ret_conv;
10322 }
10323
10324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10325         if ((_res & 1) != 0) return;
10326         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(((uint64_t)_res) & ~1);
10327         FREE((void*)_res);
10328         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
10329 }
10330
10331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10332         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
10333         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10334         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
10335         return (uint64_t)ret_conv;
10336 }
10337
10338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10339         LDKInMemorySigner o_conv;
10340         o_conv.inner = (void*)(o & (~1));
10341         o_conv.is_owned = (o & 1) || (o == 0);
10342         o_conv = InMemorySigner_clone(&o_conv);
10343         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10344         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
10345         return (uint64_t)ret_conv;
10346 }
10347
10348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10349         LDKDecodeError e_conv;
10350         e_conv.inner = (void*)(e & (~1));
10351         e_conv.is_owned = (e & 1) || (e == 0);
10352         e_conv = DecodeError_clone(&e_conv);
10353         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10354         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
10355         return (uint64_t)ret_conv;
10356 }
10357
10358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10359         if ((_res & 1) != 0) return;
10360         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
10361         FREE((void*)_res);
10362         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
10363 }
10364
10365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10366         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
10367         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
10368         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
10369         return (uint64_t)ret_conv;
10370 }
10371
10372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10373         LDKCVec_TxOutZ _res_constr;
10374         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10375         if (_res_constr.datalen > 0)
10376                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
10377         else
10378                 _res_constr.data = NULL;
10379         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10380         for (size_t h = 0; h < _res_constr.datalen; h++) {
10381                 int64_t _res_conv_7 = _res_vals[h];
10382                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(((uint64_t)_res_conv_7) & ~1);
10383                 FREE((void*)_res_conv_7);
10384                 _res_constr.data[h] = _res_conv_7_conv;
10385         }
10386         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10387         CVec_TxOutZ_free(_res_constr);
10388 }
10389
10390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10391         LDKTransaction o_ref;
10392         o_ref.datalen = (*env)->GetArrayLength(env, o);
10393         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
10394         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
10395         o_ref.data_is_owned = true;
10396         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10397         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
10398         return (uint64_t)ret_conv;
10399 }
10400
10401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
10402         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10403         *ret_conv = CResult_TransactionNoneZ_err();
10404         return (uint64_t)ret_conv;
10405 }
10406
10407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10408         if ((_res & 1) != 0) return;
10409         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(((uint64_t)_res) & ~1);
10410         FREE((void*)_res);
10411         CResult_TransactionNoneZ_free(_res_conv);
10412 }
10413
10414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10415         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
10416         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
10417         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
10418         return (uint64_t)ret_conv;
10419 }
10420
10421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10422         LDKThirtyTwoBytes a_ref;
10423         CHECK((*env)->GetArrayLength(env, a) == 32);
10424         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10425         LDKChannelMonitor b_conv;
10426         b_conv.inner = (void*)(b & (~1));
10427         b_conv.is_owned = (b & 1) || (b == 0);
10428         b_conv = ChannelMonitor_clone(&b_conv);
10429         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10430         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10431         return (uint64_t)ret_ref;
10432 }
10433
10434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10435         if ((_res & 1) != 0) return;
10436         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
10437         FREE((void*)_res);
10438         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10439 }
10440
10441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10442         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
10443         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10444         if (_res_constr.datalen > 0)
10445                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10446         else
10447                 _res_constr.data = NULL;
10448         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10449         for (size_t i = 0; i < _res_constr.datalen; i++) {
10450                 int64_t _res_conv_34 = _res_vals[i];
10451                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res_conv_34) & ~1);
10452                 FREE((void*)_res_conv_34);
10453                 _res_constr.data[i] = _res_conv_34_conv;
10454         }
10455         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10456         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
10457 }
10458
10459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
10460         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
10461         o_constr.datalen = (*env)->GetArrayLength(env, o);
10462         if (o_constr.datalen > 0)
10463                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
10464         else
10465                 o_constr.data = NULL;
10466         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
10467         for (size_t i = 0; i < o_constr.datalen; i++) {
10468                 int64_t o_conv_34 = o_vals[i];
10469                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_34_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_34) & ~1);
10470                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelMonitorZ
10471                 o_constr.data[i] = o_conv_34_conv;
10472         }
10473         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
10474         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10475         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
10476         return (uint64_t)ret_conv;
10477 }
10478
10479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10480         LDKIOError e_conv = LDKIOError_from_java(env, e);
10481         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
10482         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
10483         return (uint64_t)ret_conv;
10484 }
10485
10486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10487         if ((_res & 1) != 0) return;
10488         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(((uint64_t)_res) & ~1);
10489         FREE((void*)_res);
10490         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
10491 }
10492
10493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
10494         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10495         *ret_copy = COption_u16Z_some(o);
10496         uint64_t ret_ref = (uint64_t)ret_copy;
10497         return ret_ref;
10498 }
10499
10500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
10501         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10502         *ret_copy = COption_u16Z_none();
10503         uint64_t ret_ref = (uint64_t)ret_copy;
10504         return ret_ref;
10505 }
10506
10507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
10508         if ((_res & 1) != 0) return;
10509         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(((uint64_t)_res) & ~1);
10510         FREE((void*)_res);
10511         COption_u16Z_free(_res_conv);
10512 }
10513
10514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10515         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
10516         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
10517         *ret_copy = COption_u16Z_clone(orig_conv);
10518         uint64_t ret_ref = (uint64_t)ret_copy;
10519         return ret_ref;
10520 }
10521
10522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
10523         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10524         *ret_conv = CResult_NoneAPIErrorZ_ok();
10525         return (uint64_t)ret_conv;
10526 }
10527
10528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10529         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10530         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10531         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
10532         return (uint64_t)ret_conv;
10533 }
10534
10535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10536         if ((_res & 1) != 0) return;
10537         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
10538         FREE((void*)_res);
10539         CResult_NoneAPIErrorZ_free(_res_conv);
10540 }
10541
10542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10543         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
10544         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
10545         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
10546         return (uint64_t)ret_conv;
10547 }
10548
10549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10550         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
10551         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10552         if (_res_constr.datalen > 0)
10553                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
10554         else
10555                 _res_constr.data = NULL;
10556         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10557         for (size_t w = 0; w < _res_constr.datalen; w++) {
10558                 int64_t _res_conv_22 = _res_vals[w];
10559                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res_conv_22) & ~1);
10560                 FREE((void*)_res_conv_22);
10561                 _res_constr.data[w] = _res_conv_22_conv;
10562         }
10563         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10564         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
10565 }
10566
10567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10568         LDKCVec_APIErrorZ _res_constr;
10569         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10570         if (_res_constr.datalen > 0)
10571                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
10572         else
10573                 _res_constr.data = NULL;
10574         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10575         for (size_t k = 0; k < _res_constr.datalen; k++) {
10576                 int64_t _res_conv_10 = _res_vals[k];
10577                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(((uint64_t)_res_conv_10) & ~1);
10578                 FREE((void*)_res_conv_10);
10579                 _res_constr.data[k] = _res_conv_10_conv;
10580         }
10581         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10582         CVec_APIErrorZ_free(_res_constr);
10583 }
10584
10585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
10586         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10587         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
10588         return (uint64_t)ret_conv;
10589 }
10590
10591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10592         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(((uint64_t)e) & ~1);
10593         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10594         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
10595         return (uint64_t)ret_conv;
10596 }
10597
10598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10599         if ((_res & 1) != 0) return;
10600         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
10601         FREE((void*)_res);
10602         CResult_NonePaymentSendFailureZ_free(_res_conv);
10603 }
10604
10605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10606         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
10607         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10608         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
10609         return (uint64_t)ret_conv;
10610 }
10611
10612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10613         LDKCVec_NetAddressZ _res_constr;
10614         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10615         if (_res_constr.datalen > 0)
10616                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10617         else
10618                 _res_constr.data = NULL;
10619         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10620         for (size_t m = 0; m < _res_constr.datalen; m++) {
10621                 int64_t _res_conv_12 = _res_vals[m];
10622                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(((uint64_t)_res_conv_12) & ~1);
10623                 FREE((void*)_res_conv_12);
10624                 _res_constr.data[m] = _res_conv_12_conv;
10625         }
10626         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10627         CVec_NetAddressZ_free(_res_constr);
10628 }
10629
10630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10631         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
10632         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10633         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
10634         return (uint64_t)ret_ref;
10635 }
10636
10637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
10638         LDKThirtyTwoBytes a_ref;
10639         CHECK((*env)->GetArrayLength(env, a) == 32);
10640         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10641         LDKThirtyTwoBytes b_ref;
10642         CHECK((*env)->GetArrayLength(env, b) == 32);
10643         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10644         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
10645         *ret_ref = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
10646         return (uint64_t)ret_ref;
10647 }
10648
10649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10650         if ((_res & 1) != 0) return;
10651         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)_res) & ~1);
10652         FREE((void*)_res);
10653         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
10654 }
10655
10656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
10657         LDKThirtyTwoBytes o_ref;
10658         CHECK((*env)->GetArrayLength(env, o) == 32);
10659         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
10660         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10661         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
10662         return (uint64_t)ret_conv;
10663 }
10664
10665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10666         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
10667         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10668         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
10669         return (uint64_t)ret_conv;
10670 }
10671
10672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10673         if ((_res & 1) != 0) return;
10674         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(((uint64_t)_res) & ~1);
10675         FREE((void*)_res);
10676         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
10677 }
10678
10679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10680         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
10681         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
10682         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
10683         return (uint64_t)ret_conv;
10684 }
10685
10686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10687         LDKCVec_ChannelMonitorZ _res_constr;
10688         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10689         if (_res_constr.datalen > 0)
10690                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
10691         else
10692                 _res_constr.data = NULL;
10693         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10694         for (size_t q = 0; q < _res_constr.datalen; q++) {
10695                 int64_t _res_conv_16 = _res_vals[q];
10696                 LDKChannelMonitor _res_conv_16_conv;
10697                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
10698                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
10699                 _res_constr.data[q] = _res_conv_16_conv;
10700         }
10701         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10702         CVec_ChannelMonitorZ_free(_res_constr);
10703 }
10704
10705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
10706         LDKThirtyTwoBytes a_ref;
10707         CHECK((*env)->GetArrayLength(env, a) == 32);
10708         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
10709         LDKChannelManager b_conv;
10710         b_conv.inner = (void*)(b & (~1));
10711         b_conv.is_owned = (b & 1) || (b == 0);
10712         // Warning: we need a move here but no clone is available for LDKChannelManager
10713         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
10714         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
10715         return (uint64_t)ret_ref;
10716 }
10717
10718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10719         if ((_res & 1) != 0) return;
10720         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
10721         FREE((void*)_res);
10722         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
10723 }
10724
10725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10726         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
10727         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10728         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
10729         return (uint64_t)ret_conv;
10730 }
10731
10732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10733         LDKDecodeError e_conv;
10734         e_conv.inner = (void*)(e & (~1));
10735         e_conv.is_owned = (e & 1) || (e == 0);
10736         e_conv = DecodeError_clone(&e_conv);
10737         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
10738         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
10739         return (uint64_t)ret_conv;
10740 }
10741
10742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10743         if ((_res & 1) != 0) return;
10744         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
10745         FREE((void*)_res);
10746         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
10747 }
10748
10749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10750         LDKChannelConfig o_conv;
10751         o_conv.inner = (void*)(o & (~1));
10752         o_conv.is_owned = (o & 1) || (o == 0);
10753         o_conv = ChannelConfig_clone(&o_conv);
10754         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10755         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
10756         return (uint64_t)ret_conv;
10757 }
10758
10759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10760         LDKDecodeError e_conv;
10761         e_conv.inner = (void*)(e & (~1));
10762         e_conv.is_owned = (e & 1) || (e == 0);
10763         e_conv = DecodeError_clone(&e_conv);
10764         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10765         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
10766         return (uint64_t)ret_conv;
10767 }
10768
10769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10770         if ((_res & 1) != 0) return;
10771         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(((uint64_t)_res) & ~1);
10772         FREE((void*)_res);
10773         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
10774 }
10775
10776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10777         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
10778         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
10779         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
10780         return (uint64_t)ret_conv;
10781 }
10782
10783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10784         LDKOutPoint o_conv;
10785         o_conv.inner = (void*)(o & (~1));
10786         o_conv.is_owned = (o & 1) || (o == 0);
10787         o_conv = OutPoint_clone(&o_conv);
10788         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10789         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
10790         return (uint64_t)ret_conv;
10791 }
10792
10793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
10794         LDKDecodeError e_conv;
10795         e_conv.inner = (void*)(e & (~1));
10796         e_conv.is_owned = (e & 1) || (e == 0);
10797         e_conv = DecodeError_clone(&e_conv);
10798         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10799         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
10800         return (uint64_t)ret_conv;
10801 }
10802
10803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10804         if ((_res & 1) != 0) return;
10805         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(((uint64_t)_res) & ~1);
10806         FREE((void*)_res);
10807         CResult_OutPointDecodeErrorZ_free(_res_conv);
10808 }
10809
10810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10811         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
10812         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
10813         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
10814         return (uint64_t)ret_conv;
10815 }
10816
10817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
10818         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
10819         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10820         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
10821         return (uint64_t)ret_conv;
10822 }
10823
10824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
10825         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10826         *ret_conv = CResult_SiPrefixNoneZ_err();
10827         return (uint64_t)ret_conv;
10828 }
10829
10830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10831         if ((_res & 1) != 0) return;
10832         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(((uint64_t)_res) & ~1);
10833         FREE((void*)_res);
10834         CResult_SiPrefixNoneZ_free(_res_conv);
10835 }
10836
10837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10838         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
10839         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
10840         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
10841         return (uint64_t)ret_conv;
10842 }
10843
10844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10845         LDKInvoice o_conv;
10846         o_conv.inner = (void*)(o & (~1));
10847         o_conv.is_owned = (o & 1) || (o == 0);
10848         o_conv = Invoice_clone(&o_conv);
10849         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10850         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
10851         return (uint64_t)ret_conv;
10852 }
10853
10854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10855         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10856         *ret_conv = CResult_InvoiceNoneZ_err();
10857         return (uint64_t)ret_conv;
10858 }
10859
10860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10861         if ((_res & 1) != 0) return;
10862         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(((uint64_t)_res) & ~1);
10863         FREE((void*)_res);
10864         CResult_InvoiceNoneZ_free(_res_conv);
10865 }
10866
10867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10868         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
10869         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
10870         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
10871         return (uint64_t)ret_conv;
10872 }
10873
10874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10875         LDKSignedRawInvoice o_conv;
10876         o_conv.inner = (void*)(o & (~1));
10877         o_conv.is_owned = (o & 1) || (o == 0);
10878         o_conv = SignedRawInvoice_clone(&o_conv);
10879         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10880         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
10881         return (uint64_t)ret_conv;
10882 }
10883
10884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
10885         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10886         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
10887         return (uint64_t)ret_conv;
10888 }
10889
10890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10891         if ((_res & 1) != 0) return;
10892         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(((uint64_t)_res) & ~1);
10893         FREE((void*)_res);
10894         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
10895 }
10896
10897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10898         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
10899         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
10900         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
10901         return (uint64_t)ret_conv;
10902 }
10903
10904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10905         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
10906         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10907         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
10908         return (uint64_t)ret_ref;
10909 }
10910
10911 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) {
10912         LDKRawInvoice a_conv;
10913         a_conv.inner = (void*)(a & (~1));
10914         a_conv.is_owned = (a & 1) || (a == 0);
10915         a_conv = RawInvoice_clone(&a_conv);
10916         LDKThirtyTwoBytes b_ref;
10917         CHECK((*env)->GetArrayLength(env, b) == 32);
10918         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
10919         LDKInvoiceSignature c_conv;
10920         c_conv.inner = (void*)(c & (~1));
10921         c_conv.is_owned = (c & 1) || (c == 0);
10922         c_conv = InvoiceSignature_clone(&c_conv);
10923         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
10924         *ret_ref = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
10925         return (uint64_t)ret_ref;
10926 }
10927
10928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10929         if ((_res & 1) != 0) return;
10930         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(((uint64_t)_res) & ~1);
10931         FREE((void*)_res);
10932         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
10933 }
10934
10935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10936         LDKPayeePubKey o_conv;
10937         o_conv.inner = (void*)(o & (~1));
10938         o_conv.is_owned = (o & 1) || (o == 0);
10939         o_conv = PayeePubKey_clone(&o_conv);
10940         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10941         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
10942         return (uint64_t)ret_conv;
10943 }
10944
10945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10946         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
10947         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10948         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
10949         return (uint64_t)ret_conv;
10950 }
10951
10952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
10953         if ((_res & 1) != 0) return;
10954         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(((uint64_t)_res) & ~1);
10955         FREE((void*)_res);
10956         CResult_PayeePubKeyErrorZ_free(_res_conv);
10957 }
10958
10959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
10960         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
10961         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
10962         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
10963         return (uint64_t)ret_conv;
10964 }
10965
10966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
10967         LDKCVec_PrivateRouteZ _res_constr;
10968         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
10969         if (_res_constr.datalen > 0)
10970                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
10971         else
10972                 _res_constr.data = NULL;
10973         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
10974         for (size_t o = 0; o < _res_constr.datalen; o++) {
10975                 int64_t _res_conv_14 = _res_vals[o];
10976                 LDKPrivateRoute _res_conv_14_conv;
10977                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
10978                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
10979                 _res_constr.data[o] = _res_conv_14_conv;
10980         }
10981         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
10982         CVec_PrivateRouteZ_free(_res_constr);
10983 }
10984
10985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
10986         LDKPositiveTimestamp o_conv;
10987         o_conv.inner = (void*)(o & (~1));
10988         o_conv.is_owned = (o & 1) || (o == 0);
10989         o_conv = PositiveTimestamp_clone(&o_conv);
10990         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10991         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
10992         return (uint64_t)ret_conv;
10993 }
10994
10995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
10996         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
10997         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
10998         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
10999         return (uint64_t)ret_conv;
11000 }
11001
11002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11003         if ((_res & 1) != 0) return;
11004         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(((uint64_t)_res) & ~1);
11005         FREE((void*)_res);
11006         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
11007 }
11008
11009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11010         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
11011         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
11012         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
11013         return (uint64_t)ret_conv;
11014 }
11015
11016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
11017         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11018         *ret_conv = CResult_NoneSemanticErrorZ_ok();
11019         return (uint64_t)ret_conv;
11020 }
11021
11022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11023         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11024         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11025         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
11026         return (uint64_t)ret_conv;
11027 }
11028
11029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11030         if ((_res & 1) != 0) return;
11031         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(((uint64_t)_res) & ~1);
11032         FREE((void*)_res);
11033         CResult_NoneSemanticErrorZ_free(_res_conv);
11034 }
11035
11036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11037         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
11038         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
11039         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
11040         return (uint64_t)ret_conv;
11041 }
11042
11043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11044         LDKInvoice o_conv;
11045         o_conv.inner = (void*)(o & (~1));
11046         o_conv.is_owned = (o & 1) || (o == 0);
11047         o_conv = Invoice_clone(&o_conv);
11048         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11049         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
11050         return (uint64_t)ret_conv;
11051 }
11052
11053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11054         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
11055         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11056         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
11057         return (uint64_t)ret_conv;
11058 }
11059
11060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11061         if ((_res & 1) != 0) return;
11062         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(((uint64_t)_res) & ~1);
11063         FREE((void*)_res);
11064         CResult_InvoiceSemanticErrorZ_free(_res_conv);
11065 }
11066
11067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11068         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
11069         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
11070         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
11071         return (uint64_t)ret_conv;
11072 }
11073
11074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11075         LDKDescription o_conv;
11076         o_conv.inner = (void*)(o & (~1));
11077         o_conv.is_owned = (o & 1) || (o == 0);
11078         o_conv = Description_clone(&o_conv);
11079         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11080         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
11081         return (uint64_t)ret_conv;
11082 }
11083
11084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11085         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11086         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11087         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
11088         return (uint64_t)ret_conv;
11089 }
11090
11091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11092         if ((_res & 1) != 0) return;
11093         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(((uint64_t)_res) & ~1);
11094         FREE((void*)_res);
11095         CResult_DescriptionCreationErrorZ_free(_res_conv);
11096 }
11097
11098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11099         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
11100         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
11101         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
11102         return (uint64_t)ret_conv;
11103 }
11104
11105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11106         LDKExpiryTime o_conv;
11107         o_conv.inner = (void*)(o & (~1));
11108         o_conv.is_owned = (o & 1) || (o == 0);
11109         o_conv = ExpiryTime_clone(&o_conv);
11110         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11111         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
11112         return (uint64_t)ret_conv;
11113 }
11114
11115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11116         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11117         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11118         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
11119         return (uint64_t)ret_conv;
11120 }
11121
11122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11123         if ((_res & 1) != 0) return;
11124         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(((uint64_t)_res) & ~1);
11125         FREE((void*)_res);
11126         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
11127 }
11128
11129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11130         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
11131         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
11132         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
11133         return (uint64_t)ret_conv;
11134 }
11135
11136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11137         LDKPrivateRoute o_conv;
11138         o_conv.inner = (void*)(o & (~1));
11139         o_conv.is_owned = (o & 1) || (o == 0);
11140         o_conv = PrivateRoute_clone(&o_conv);
11141         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11142         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
11143         return (uint64_t)ret_conv;
11144 }
11145
11146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11147         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
11148         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11149         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
11150         return (uint64_t)ret_conv;
11151 }
11152
11153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11154         if ((_res & 1) != 0) return;
11155         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(((uint64_t)_res) & ~1);
11156         FREE((void*)_res);
11157         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
11158 }
11159
11160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11161         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
11162         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
11163         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
11164         return (uint64_t)ret_conv;
11165 }
11166
11167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
11168         LDKStr o_conv = java_to_owned_str(env, o);
11169         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11170         *ret_conv = CResult_StringErrorZ_ok(o_conv);
11171         return (uint64_t)ret_conv;
11172 }
11173
11174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11175         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11176         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
11177         *ret_conv = CResult_StringErrorZ_err(e_conv);
11178         return (uint64_t)ret_conv;
11179 }
11180
11181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11182         if ((_res & 1) != 0) return;
11183         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(((uint64_t)_res) & ~1);
11184         FREE((void*)_res);
11185         CResult_StringErrorZ_free(_res_conv);
11186 }
11187
11188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11189         LDKChannelMonitorUpdate o_conv;
11190         o_conv.inner = (void*)(o & (~1));
11191         o_conv.is_owned = (o & 1) || (o == 0);
11192         o_conv = ChannelMonitorUpdate_clone(&o_conv);
11193         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11194         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
11195         return (uint64_t)ret_conv;
11196 }
11197
11198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11199         LDKDecodeError e_conv;
11200         e_conv.inner = (void*)(e & (~1));
11201         e_conv.is_owned = (e & 1) || (e == 0);
11202         e_conv = DecodeError_clone(&e_conv);
11203         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11204         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
11205         return (uint64_t)ret_conv;
11206 }
11207
11208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11209         if ((_res & 1) != 0) return;
11210         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11211         FREE((void*)_res);
11212         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
11213 }
11214
11215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11216         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
11217         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
11218         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
11219         return (uint64_t)ret_conv;
11220 }
11221
11222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11223         LDKHTLCUpdate o_conv;
11224         o_conv.inner = (void*)(o & (~1));
11225         o_conv.is_owned = (o & 1) || (o == 0);
11226         o_conv = HTLCUpdate_clone(&o_conv);
11227         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11228         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
11229         return (uint64_t)ret_conv;
11230 }
11231
11232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11233         LDKDecodeError e_conv;
11234         e_conv.inner = (void*)(e & (~1));
11235         e_conv.is_owned = (e & 1) || (e == 0);
11236         e_conv = DecodeError_clone(&e_conv);
11237         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11238         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
11239         return (uint64_t)ret_conv;
11240 }
11241
11242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11243         if ((_res & 1) != 0) return;
11244         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
11245         FREE((void*)_res);
11246         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
11247 }
11248
11249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11250         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
11251         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
11252         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
11253         return (uint64_t)ret_conv;
11254 }
11255
11256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
11257         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11258         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
11259         return (uint64_t)ret_conv;
11260 }
11261
11262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11263         LDKMonitorUpdateError e_conv;
11264         e_conv.inner = (void*)(e & (~1));
11265         e_conv.is_owned = (e & 1) || (e == 0);
11266         e_conv = MonitorUpdateError_clone(&e_conv);
11267         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11268         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
11269         return (uint64_t)ret_conv;
11270 }
11271
11272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11273         if ((_res & 1) != 0) return;
11274         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
11275         FREE((void*)_res);
11276         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
11277 }
11278
11279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11280         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
11281         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
11282         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
11283         return (uint64_t)ret_conv;
11284 }
11285
11286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11287         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
11288         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11289         *ret_ref = C2Tuple_OutPointScriptZ_clone(orig_conv);
11290         return (uint64_t)ret_ref;
11291 }
11292
11293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
11294         LDKOutPoint a_conv;
11295         a_conv.inner = (void*)(a & (~1));
11296         a_conv.is_owned = (a & 1) || (a == 0);
11297         a_conv = OutPoint_clone(&a_conv);
11298         LDKCVec_u8Z b_ref;
11299         b_ref.datalen = (*env)->GetArrayLength(env, b);
11300         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11301         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11302         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
11303         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
11304         return (uint64_t)ret_ref;
11305 }
11306
11307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11308         if ((_res & 1) != 0) return;
11309         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
11310         FREE((void*)_res);
11311         C2Tuple_OutPointScriptZ_free(_res_conv);
11312 }
11313
11314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11315         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
11316         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11317         *ret_ref = C2Tuple_u32ScriptZ_clone(orig_conv);
11318         return (uint64_t)ret_ref;
11319 }
11320
11321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
11322         LDKCVec_u8Z b_ref;
11323         b_ref.datalen = (*env)->GetArrayLength(env, b);
11324         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
11325         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
11326         LDKC2Tuple_u32ScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
11327         *ret_ref = C2Tuple_u32ScriptZ_new(a, b_ref);
11328         return (uint64_t)ret_ref;
11329 }
11330
11331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11332         if ((_res & 1) != 0) return;
11333         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res) & ~1);
11334         FREE((void*)_res);
11335         C2Tuple_u32ScriptZ_free(_res_conv);
11336 }
11337
11338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11339         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
11340         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11341         if (_res_constr.datalen > 0)
11342                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11343         else
11344                 _res_constr.data = NULL;
11345         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11346         for (size_t b = 0; b < _res_constr.datalen; b++) {
11347                 int64_t _res_conv_27 = _res_vals[b];
11348                 LDKC2Tuple_u32ScriptZ _res_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)_res_conv_27) & ~1);
11349                 FREE((void*)_res_conv_27);
11350                 _res_constr.data[b] = _res_conv_27_conv;
11351         }
11352         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11353         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
11354 }
11355
11356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11357         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
11358         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11359         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
11360         return (uint64_t)ret_ref;
11361 }
11362
11363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11364         LDKThirtyTwoBytes a_ref;
11365         CHECK((*env)->GetArrayLength(env, a) == 32);
11366         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11367         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
11368         b_constr.datalen = (*env)->GetArrayLength(env, b);
11369         if (b_constr.datalen > 0)
11370                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
11371         else
11372                 b_constr.data = NULL;
11373         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11374         for (size_t b = 0; b < b_constr.datalen; b++) {
11375                 int64_t b_conv_27 = b_vals[b];
11376                 LDKC2Tuple_u32ScriptZ b_conv_27_conv = *(LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1);
11377                 b_conv_27_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_27) & ~1));
11378                 b_constr.data[b] = b_conv_27_conv;
11379         }
11380         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11381         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
11382         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
11383         return (uint64_t)ret_ref;
11384 }
11385
11386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11387         if ((_res & 1) != 0) return;
11388         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res) & ~1);
11389         FREE((void*)_res);
11390         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
11391 }
11392
11393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11394         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
11395         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11396         if (_res_constr.datalen > 0)
11397                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
11398         else
11399                 _res_constr.data = NULL;
11400         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11401         for (size_t v = 0; v < _res_constr.datalen; v++) {
11402                 int64_t _res_conv_47 = _res_vals[v];
11403                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_47_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)_res_conv_47) & ~1);
11404                 FREE((void*)_res_conv_47);
11405                 _res_constr.data[v] = _res_conv_47_conv;
11406         }
11407         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11408         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
11409 }
11410
11411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11412         LDKCVec_EventZ _res_constr;
11413         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11414         if (_res_constr.datalen > 0)
11415                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
11416         else
11417                 _res_constr.data = NULL;
11418         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11419         for (size_t h = 0; h < _res_constr.datalen; h++) {
11420                 int64_t _res_conv_7 = _res_vals[h];
11421                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(((uint64_t)_res_conv_7) & ~1);
11422                 FREE((void*)_res_conv_7);
11423                 _res_constr.data[h] = _res_conv_7_conv;
11424         }
11425         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11426         CVec_EventZ_free(_res_constr);
11427 }
11428
11429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11430         LDKCVec_TransactionZ _res_constr;
11431         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11432         if (_res_constr.datalen > 0)
11433                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
11434         else
11435                 _res_constr.data = NULL;
11436         for (size_t i = 0; i < _res_constr.datalen; i++) {
11437                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11438                 LDKTransaction _res_conv_8_ref;
11439                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
11440                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
11441                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
11442                 _res_conv_8_ref.data_is_owned = true;
11443                 _res_constr.data[i] = _res_conv_8_ref;
11444         }
11445         CVec_TransactionZ_free(_res_constr);
11446 }
11447
11448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11449         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
11450         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11451         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
11452         return (uint64_t)ret_ref;
11453 }
11454
11455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
11456         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
11457         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
11458         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
11459         return (uint64_t)ret_ref;
11460 }
11461
11462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11463         if ((_res & 1) != 0) return;
11464         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
11465         FREE((void*)_res);
11466         C2Tuple_u32TxOutZ_free(_res_conv);
11467 }
11468
11469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11470         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
11471         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11472         if (_res_constr.datalen > 0)
11473                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11474         else
11475                 _res_constr.data = NULL;
11476         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11477         for (size_t a = 0; a < _res_constr.datalen; a++) {
11478                 int64_t _res_conv_26 = _res_vals[a];
11479                 LDKC2Tuple_u32TxOutZ _res_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res_conv_26) & ~1);
11480                 FREE((void*)_res_conv_26);
11481                 _res_constr.data[a] = _res_conv_26_conv;
11482         }
11483         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11484         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
11485 }
11486
11487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11488         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
11489         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11490         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
11491         return (uint64_t)ret_ref;
11492 }
11493
11494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
11495         LDKThirtyTwoBytes a_ref;
11496         CHECK((*env)->GetArrayLength(env, a) == 32);
11497         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
11498         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
11499         b_constr.datalen = (*env)->GetArrayLength(env, b);
11500         if (b_constr.datalen > 0)
11501                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
11502         else
11503                 b_constr.data = NULL;
11504         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
11505         for (size_t a = 0; a < b_constr.datalen; a++) {
11506                 int64_t b_conv_26 = b_vals[a];
11507                 LDKC2Tuple_u32TxOutZ b_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1);
11508                 b_conv_26_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_26) & ~1));
11509                 b_constr.data[a] = b_conv_26_conv;
11510         }
11511         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
11512         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
11513         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
11514         return (uint64_t)ret_ref;
11515 }
11516
11517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11518         if ((_res & 1) != 0) return;
11519         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
11520         FREE((void*)_res);
11521         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
11522 }
11523
11524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11525         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
11526         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11527         if (_res_constr.datalen > 0)
11528                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
11529         else
11530                 _res_constr.data = NULL;
11531         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11532         for (size_t u = 0; u < _res_constr.datalen; u++) {
11533                 int64_t _res_conv_46 = _res_vals[u];
11534                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res_conv_46) & ~1);
11535                 FREE((void*)_res_conv_46);
11536                 _res_constr.data[u] = _res_conv_46_conv;
11537         }
11538         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11539         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
11540 }
11541
11542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11543         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
11544         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11545         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
11546         return (uint64_t)ret_conv;
11547 }
11548
11549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11550         LDKDecodeError e_conv;
11551         e_conv.inner = (void*)(e & (~1));
11552         e_conv.is_owned = (e & 1) || (e == 0);
11553         e_conv = DecodeError_clone(&e_conv);
11554         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
11555         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
11556         return (uint64_t)ret_conv;
11557 }
11558
11559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11560         if ((_res & 1) != 0) return;
11561         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
11562         FREE((void*)_res);
11563         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
11564 }
11565
11566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11567         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11568         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11569         return (uint64_t)ret_conv;
11570 }
11571
11572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11573         LDKLightningError e_conv;
11574         e_conv.inner = (void*)(e & (~1));
11575         e_conv.is_owned = (e & 1) || (e == 0);
11576         e_conv = LightningError_clone(&e_conv);
11577         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11578         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11579         return (uint64_t)ret_conv;
11580 }
11581
11582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11583         if ((_res & 1) != 0) return;
11584         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
11585         FREE((void*)_res);
11586         CResult_boolLightningErrorZ_free(_res_conv);
11587 }
11588
11589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11590         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11591         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11592         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11593         return (uint64_t)ret_conv;
11594 }
11595
11596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11597         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11598         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11599         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11600         return (uint64_t)ret_ref;
11601 }
11602
11603 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) {
11604         LDKChannelAnnouncement a_conv;
11605         a_conv.inner = (void*)(a & (~1));
11606         a_conv.is_owned = (a & 1) || (a == 0);
11607         a_conv = ChannelAnnouncement_clone(&a_conv);
11608         LDKChannelUpdate b_conv;
11609         b_conv.inner = (void*)(b & (~1));
11610         b_conv.is_owned = (b & 1) || (b == 0);
11611         b_conv = ChannelUpdate_clone(&b_conv);
11612         LDKChannelUpdate c_conv;
11613         c_conv.inner = (void*)(c & (~1));
11614         c_conv.is_owned = (c & 1) || (c == 0);
11615         c_conv = ChannelUpdate_clone(&c_conv);
11616         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11617         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11618         return (uint64_t)ret_ref;
11619 }
11620
11621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11622         if ((_res & 1) != 0) return;
11623         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
11624         FREE((void*)_res);
11625         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11626 }
11627
11628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11629         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11630         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11631         if (_res_constr.datalen > 0)
11632                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11633         else
11634                 _res_constr.data = NULL;
11635         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11636         for (size_t l = 0; l < _res_constr.datalen; l++) {
11637                 int64_t _res_conv_63 = _res_vals[l];
11638                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res_conv_63) & ~1);
11639                 FREE((void*)_res_conv_63);
11640                 _res_constr.data[l] = _res_conv_63_conv;
11641         }
11642         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11643         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11644 }
11645
11646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11647         LDKCVec_NodeAnnouncementZ _res_constr;
11648         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11649         if (_res_constr.datalen > 0)
11650                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11651         else
11652                 _res_constr.data = NULL;
11653         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11654         for (size_t s = 0; s < _res_constr.datalen; s++) {
11655                 int64_t _res_conv_18 = _res_vals[s];
11656                 LDKNodeAnnouncement _res_conv_18_conv;
11657                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11658                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11659                 _res_constr.data[s] = _res_conv_18_conv;
11660         }
11661         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11662         CVec_NodeAnnouncementZ_free(_res_constr);
11663 }
11664
11665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
11666         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11667         *ret_conv = CResult_NoneLightningErrorZ_ok();
11668         return (uint64_t)ret_conv;
11669 }
11670
11671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11672         LDKLightningError e_conv;
11673         e_conv.inner = (void*)(e & (~1));
11674         e_conv.is_owned = (e & 1) || (e == 0);
11675         e_conv = LightningError_clone(&e_conv);
11676         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11677         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11678         return (uint64_t)ret_conv;
11679 }
11680
11681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11682         if ((_res & 1) != 0) return;
11683         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
11684         FREE((void*)_res);
11685         CResult_NoneLightningErrorZ_free(_res_conv);
11686 }
11687
11688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11689         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11690         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11691         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11692         return (uint64_t)ret_conv;
11693 }
11694
11695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11696         LDKCVec_PublicKeyZ _res_constr;
11697         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11698         if (_res_constr.datalen > 0)
11699                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11700         else
11701                 _res_constr.data = NULL;
11702         for (size_t i = 0; i < _res_constr.datalen; i++) {
11703                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11704                 LDKPublicKey _res_conv_8_ref;
11705                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
11706                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
11707                 _res_constr.data[i] = _res_conv_8_ref;
11708         }
11709         CVec_PublicKeyZ_free(_res_constr);
11710 }
11711
11712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11713         LDKCVec_u8Z o_ref;
11714         o_ref.datalen = (*env)->GetArrayLength(env, o);
11715         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11716         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
11717         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11718         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11719         return (uint64_t)ret_conv;
11720 }
11721
11722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11723         LDKPeerHandleError e_conv;
11724         e_conv.inner = (void*)(e & (~1));
11725         e_conv.is_owned = (e & 1) || (e == 0);
11726         e_conv = PeerHandleError_clone(&e_conv);
11727         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11728         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11729         return (uint64_t)ret_conv;
11730 }
11731
11732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11733         if ((_res & 1) != 0) return;
11734         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11735         FREE((void*)_res);
11736         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11737 }
11738
11739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11740         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11741         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11742         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11743         return (uint64_t)ret_conv;
11744 }
11745
11746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
11747         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11748         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11749         return (uint64_t)ret_conv;
11750 }
11751
11752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11753         LDKPeerHandleError e_conv;
11754         e_conv.inner = (void*)(e & (~1));
11755         e_conv.is_owned = (e & 1) || (e == 0);
11756         e_conv = PeerHandleError_clone(&e_conv);
11757         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11758         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11759         return (uint64_t)ret_conv;
11760 }
11761
11762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11763         if ((_res & 1) != 0) return;
11764         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11765         FREE((void*)_res);
11766         CResult_NonePeerHandleErrorZ_free(_res_conv);
11767 }
11768
11769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11770         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
11771         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11772         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
11773         return (uint64_t)ret_conv;
11774 }
11775
11776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
11777         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11778         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
11779         return (uint64_t)ret_conv;
11780 }
11781
11782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11783         LDKPeerHandleError e_conv;
11784         e_conv.inner = (void*)(e & (~1));
11785         e_conv.is_owned = (e & 1) || (e == 0);
11786         e_conv = PeerHandleError_clone(&e_conv);
11787         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11788         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
11789         return (uint64_t)ret_conv;
11790 }
11791
11792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11793         if ((_res & 1) != 0) return;
11794         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
11795         FREE((void*)_res);
11796         CResult_boolPeerHandleErrorZ_free(_res_conv);
11797 }
11798
11799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11800         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
11801         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11802         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
11803         return (uint64_t)ret_conv;
11804 }
11805
11806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11807         LDKDirectionalChannelInfo o_conv;
11808         o_conv.inner = (void*)(o & (~1));
11809         o_conv.is_owned = (o & 1) || (o == 0);
11810         o_conv = DirectionalChannelInfo_clone(&o_conv);
11811         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11812         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
11813         return (uint64_t)ret_conv;
11814 }
11815
11816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11817         LDKDecodeError e_conv;
11818         e_conv.inner = (void*)(e & (~1));
11819         e_conv.is_owned = (e & 1) || (e == 0);
11820         e_conv = DecodeError_clone(&e_conv);
11821         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11822         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
11823         return (uint64_t)ret_conv;
11824 }
11825
11826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11827         if ((_res & 1) != 0) return;
11828         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11829         FREE((void*)_res);
11830         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
11831 }
11832
11833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11834         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
11835         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
11836         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
11837         return (uint64_t)ret_conv;
11838 }
11839
11840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11841         LDKChannelInfo o_conv;
11842         o_conv.inner = (void*)(o & (~1));
11843         o_conv.is_owned = (o & 1) || (o == 0);
11844         o_conv = ChannelInfo_clone(&o_conv);
11845         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11846         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
11847         return (uint64_t)ret_conv;
11848 }
11849
11850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11851         LDKDecodeError e_conv;
11852         e_conv.inner = (void*)(e & (~1));
11853         e_conv.is_owned = (e & 1) || (e == 0);
11854         e_conv = DecodeError_clone(&e_conv);
11855         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11856         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
11857         return (uint64_t)ret_conv;
11858 }
11859
11860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11861         if ((_res & 1) != 0) return;
11862         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11863         FREE((void*)_res);
11864         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
11865 }
11866
11867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11868         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
11869         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
11870         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
11871         return (uint64_t)ret_conv;
11872 }
11873
11874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11875         LDKRoutingFees o_conv;
11876         o_conv.inner = (void*)(o & (~1));
11877         o_conv.is_owned = (o & 1) || (o == 0);
11878         o_conv = RoutingFees_clone(&o_conv);
11879         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11880         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
11881         return (uint64_t)ret_conv;
11882 }
11883
11884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11885         LDKDecodeError e_conv;
11886         e_conv.inner = (void*)(e & (~1));
11887         e_conv.is_owned = (e & 1) || (e == 0);
11888         e_conv = DecodeError_clone(&e_conv);
11889         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11890         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
11891         return (uint64_t)ret_conv;
11892 }
11893
11894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11895         if ((_res & 1) != 0) return;
11896         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
11897         FREE((void*)_res);
11898         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
11899 }
11900
11901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11902         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
11903         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
11904         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
11905         return (uint64_t)ret_conv;
11906 }
11907
11908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11909         LDKNodeAnnouncementInfo o_conv;
11910         o_conv.inner = (void*)(o & (~1));
11911         o_conv.is_owned = (o & 1) || (o == 0);
11912         o_conv = NodeAnnouncementInfo_clone(&o_conv);
11913         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11914         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
11915         return (uint64_t)ret_conv;
11916 }
11917
11918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11919         LDKDecodeError e_conv;
11920         e_conv.inner = (void*)(e & (~1));
11921         e_conv.is_owned = (e & 1) || (e == 0);
11922         e_conv = DecodeError_clone(&e_conv);
11923         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11924         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
11925         return (uint64_t)ret_conv;
11926 }
11927
11928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11929         if ((_res & 1) != 0) return;
11930         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11931         FREE((void*)_res);
11932         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
11933 }
11934
11935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11936         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
11937         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
11938         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
11939         return (uint64_t)ret_conv;
11940 }
11941
11942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
11943         LDKCVec_u64Z _res_constr;
11944         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11945         if (_res_constr.datalen > 0)
11946                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11947         else
11948                 _res_constr.data = NULL;
11949         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
11950         for (size_t g = 0; g < _res_constr.datalen; g++) {
11951                 int64_t _res_conv_6 = _res_vals[g];
11952                 _res_constr.data[g] = _res_conv_6;
11953         }
11954         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
11955         CVec_u64Z_free(_res_constr);
11956 }
11957
11958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11959         LDKNodeInfo o_conv;
11960         o_conv.inner = (void*)(o & (~1));
11961         o_conv.is_owned = (o & 1) || (o == 0);
11962         o_conv = NodeInfo_clone(&o_conv);
11963         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11964         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
11965         return (uint64_t)ret_conv;
11966 }
11967
11968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11969         LDKDecodeError e_conv;
11970         e_conv.inner = (void*)(e & (~1));
11971         e_conv.is_owned = (e & 1) || (e == 0);
11972         e_conv = DecodeError_clone(&e_conv);
11973         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11974         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
11975         return (uint64_t)ret_conv;
11976 }
11977
11978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11979         if ((_res & 1) != 0) return;
11980         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
11981         FREE((void*)_res);
11982         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
11983 }
11984
11985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11986         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
11987         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
11988         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
11989         return (uint64_t)ret_conv;
11990 }
11991
11992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11993         LDKNetworkGraph o_conv;
11994         o_conv.inner = (void*)(o & (~1));
11995         o_conv.is_owned = (o & 1) || (o == 0);
11996         o_conv = NetworkGraph_clone(&o_conv);
11997         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
11998         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
11999         return (uint64_t)ret_conv;
12000 }
12001
12002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12003         LDKDecodeError e_conv;
12004         e_conv.inner = (void*)(e & (~1));
12005         e_conv.is_owned = (e & 1) || (e == 0);
12006         e_conv = DecodeError_clone(&e_conv);
12007         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12008         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
12009         return (uint64_t)ret_conv;
12010 }
12011
12012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12013         if ((_res & 1) != 0) return;
12014         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
12015         FREE((void*)_res);
12016         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
12017 }
12018
12019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12020         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
12021         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12022         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
12023         return (uint64_t)ret_conv;
12024 }
12025
12026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1ok(JNIEnv *env, jclass clz, int64_t o) {
12027         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12028         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12029         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
12030         return (uint64_t)ret_conv;
12031 }
12032
12033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1err(JNIEnv *env, jclass clz, int8_t e) {
12034         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12035         *ret_conv = CResult_NetAddressu8Z_err(e);
12036         return (uint64_t)ret_conv;
12037 }
12038
12039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12040         if ((_res & 1) != 0) return;
12041         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
12042         FREE((void*)_res);
12043         CResult_NetAddressu8Z_free(_res_conv);
12044 }
12045
12046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressu8Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12047         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
12048         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
12049         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
12050         return (uint64_t)ret_conv;
12051 }
12052
12053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12054         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
12055         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12056         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
12057         return (uint64_t)ret_conv;
12058 }
12059
12060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12061         LDKDecodeError e_conv;
12062         e_conv.inner = (void*)(e & (~1));
12063         e_conv.is_owned = (e & 1) || (e == 0);
12064         e_conv = DecodeError_clone(&e_conv);
12065         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12066         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
12067         return (uint64_t)ret_conv;
12068 }
12069
12070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12071         if ((_res & 1) != 0) return;
12072         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
12073         FREE((void*)_res);
12074         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
12075 }
12076
12077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12078         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* orig_conv = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(orig & ~1);
12079         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
12080         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_clone(orig_conv);
12081         return (uint64_t)ret_conv;
12082 }
12083
12084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12085         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
12086         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12087         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
12088         return (uint64_t)ret_conv;
12089 }
12090
12091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12092         LDKDecodeError e_conv;
12093         e_conv.inner = (void*)(e & (~1));
12094         e_conv.is_owned = (e & 1) || (e == 0);
12095         e_conv = DecodeError_clone(&e_conv);
12096         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12097         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
12098         return (uint64_t)ret_conv;
12099 }
12100
12101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12102         if ((_res & 1) != 0) return;
12103         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(((uint64_t)_res) & ~1);
12104         FREE((void*)_res);
12105         CResult_NetAddressDecodeErrorZ_free(_res_conv);
12106 }
12107
12108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12109         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
12110         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
12111         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
12112         return (uint64_t)ret_conv;
12113 }
12114
12115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12116         LDKCVec_UpdateAddHTLCZ _res_constr;
12117         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12118         if (_res_constr.datalen > 0)
12119                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
12120         else
12121                 _res_constr.data = NULL;
12122         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12123         for (size_t p = 0; p < _res_constr.datalen; p++) {
12124                 int64_t _res_conv_15 = _res_vals[p];
12125                 LDKUpdateAddHTLC _res_conv_15_conv;
12126                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
12127                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
12128                 _res_constr.data[p] = _res_conv_15_conv;
12129         }
12130         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12131         CVec_UpdateAddHTLCZ_free(_res_constr);
12132 }
12133
12134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12135         LDKCVec_UpdateFulfillHTLCZ _res_constr;
12136         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12137         if (_res_constr.datalen > 0)
12138                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
12139         else
12140                 _res_constr.data = NULL;
12141         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12142         for (size_t t = 0; t < _res_constr.datalen; t++) {
12143                 int64_t _res_conv_19 = _res_vals[t];
12144                 LDKUpdateFulfillHTLC _res_conv_19_conv;
12145                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
12146                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
12147                 _res_constr.data[t] = _res_conv_19_conv;
12148         }
12149         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12150         CVec_UpdateFulfillHTLCZ_free(_res_constr);
12151 }
12152
12153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12154         LDKCVec_UpdateFailHTLCZ _res_constr;
12155         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12156         if (_res_constr.datalen > 0)
12157                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
12158         else
12159                 _res_constr.data = NULL;
12160         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12161         for (size_t q = 0; q < _res_constr.datalen; q++) {
12162                 int64_t _res_conv_16 = _res_vals[q];
12163                 LDKUpdateFailHTLC _res_conv_16_conv;
12164                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12165                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12166                 _res_constr.data[q] = _res_conv_16_conv;
12167         }
12168         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12169         CVec_UpdateFailHTLCZ_free(_res_constr);
12170 }
12171
12172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12173         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
12174         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12175         if (_res_constr.datalen > 0)
12176                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
12177         else
12178                 _res_constr.data = NULL;
12179         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12180         for (size_t z = 0; z < _res_constr.datalen; z++) {
12181                 int64_t _res_conv_25 = _res_vals[z];
12182                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
12183                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
12184                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
12185                 _res_constr.data[z] = _res_conv_25_conv;
12186         }
12187         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12188         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
12189 }
12190
12191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12192         LDKAcceptChannel o_conv;
12193         o_conv.inner = (void*)(o & (~1));
12194         o_conv.is_owned = (o & 1) || (o == 0);
12195         o_conv = AcceptChannel_clone(&o_conv);
12196         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12197         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
12198         return (uint64_t)ret_conv;
12199 }
12200
12201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12202         LDKDecodeError e_conv;
12203         e_conv.inner = (void*)(e & (~1));
12204         e_conv.is_owned = (e & 1) || (e == 0);
12205         e_conv = DecodeError_clone(&e_conv);
12206         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12207         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
12208         return (uint64_t)ret_conv;
12209 }
12210
12211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12212         if ((_res & 1) != 0) return;
12213         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12214         FREE((void*)_res);
12215         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
12216 }
12217
12218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12219         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
12220         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
12221         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
12222         return (uint64_t)ret_conv;
12223 }
12224
12225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12226         LDKAnnouncementSignatures o_conv;
12227         o_conv.inner = (void*)(o & (~1));
12228         o_conv.is_owned = (o & 1) || (o == 0);
12229         o_conv = AnnouncementSignatures_clone(&o_conv);
12230         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12231         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
12232         return (uint64_t)ret_conv;
12233 }
12234
12235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12236         LDKDecodeError e_conv;
12237         e_conv.inner = (void*)(e & (~1));
12238         e_conv.is_owned = (e & 1) || (e == 0);
12239         e_conv = DecodeError_clone(&e_conv);
12240         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12241         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
12242         return (uint64_t)ret_conv;
12243 }
12244
12245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12246         if ((_res & 1) != 0) return;
12247         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(((uint64_t)_res) & ~1);
12248         FREE((void*)_res);
12249         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
12250 }
12251
12252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12253         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
12254         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
12255         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
12256         return (uint64_t)ret_conv;
12257 }
12258
12259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12260         LDKChannelReestablish o_conv;
12261         o_conv.inner = (void*)(o & (~1));
12262         o_conv.is_owned = (o & 1) || (o == 0);
12263         o_conv = ChannelReestablish_clone(&o_conv);
12264         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12265         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
12266         return (uint64_t)ret_conv;
12267 }
12268
12269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12270         LDKDecodeError e_conv;
12271         e_conv.inner = (void*)(e & (~1));
12272         e_conv.is_owned = (e & 1) || (e == 0);
12273         e_conv = DecodeError_clone(&e_conv);
12274         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12275         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
12276         return (uint64_t)ret_conv;
12277 }
12278
12279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12280         if ((_res & 1) != 0) return;
12281         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
12282         FREE((void*)_res);
12283         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
12284 }
12285
12286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12287         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
12288         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12289         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
12290         return (uint64_t)ret_conv;
12291 }
12292
12293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12294         LDKClosingSigned o_conv;
12295         o_conv.inner = (void*)(o & (~1));
12296         o_conv.is_owned = (o & 1) || (o == 0);
12297         o_conv = ClosingSigned_clone(&o_conv);
12298         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12299         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
12300         return (uint64_t)ret_conv;
12301 }
12302
12303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12304         LDKDecodeError e_conv;
12305         e_conv.inner = (void*)(e & (~1));
12306         e_conv.is_owned = (e & 1) || (e == 0);
12307         e_conv = DecodeError_clone(&e_conv);
12308         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12309         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
12310         return (uint64_t)ret_conv;
12311 }
12312
12313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12314         if ((_res & 1) != 0) return;
12315         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12316         FREE((void*)_res);
12317         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
12318 }
12319
12320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12321         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
12322         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
12323         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
12324         return (uint64_t)ret_conv;
12325 }
12326
12327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12328         LDKCommitmentSigned o_conv;
12329         o_conv.inner = (void*)(o & (~1));
12330         o_conv.is_owned = (o & 1) || (o == 0);
12331         o_conv = CommitmentSigned_clone(&o_conv);
12332         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12333         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
12334         return (uint64_t)ret_conv;
12335 }
12336
12337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12338         LDKDecodeError e_conv;
12339         e_conv.inner = (void*)(e & (~1));
12340         e_conv.is_owned = (e & 1) || (e == 0);
12341         e_conv = DecodeError_clone(&e_conv);
12342         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12343         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
12344         return (uint64_t)ret_conv;
12345 }
12346
12347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12348         if ((_res & 1) != 0) return;
12349         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12350         FREE((void*)_res);
12351         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
12352 }
12353
12354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12355         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
12356         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
12357         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
12358         return (uint64_t)ret_conv;
12359 }
12360
12361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12362         LDKFundingCreated o_conv;
12363         o_conv.inner = (void*)(o & (~1));
12364         o_conv.is_owned = (o & 1) || (o == 0);
12365         o_conv = FundingCreated_clone(&o_conv);
12366         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12367         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
12368         return (uint64_t)ret_conv;
12369 }
12370
12371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12372         LDKDecodeError e_conv;
12373         e_conv.inner = (void*)(e & (~1));
12374         e_conv.is_owned = (e & 1) || (e == 0);
12375         e_conv = DecodeError_clone(&e_conv);
12376         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12377         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
12378         return (uint64_t)ret_conv;
12379 }
12380
12381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12382         if ((_res & 1) != 0) return;
12383         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12384         FREE((void*)_res);
12385         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
12386 }
12387
12388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12389         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
12390         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
12391         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
12392         return (uint64_t)ret_conv;
12393 }
12394
12395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12396         LDKFundingSigned o_conv;
12397         o_conv.inner = (void*)(o & (~1));
12398         o_conv.is_owned = (o & 1) || (o == 0);
12399         o_conv = FundingSigned_clone(&o_conv);
12400         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12401         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
12402         return (uint64_t)ret_conv;
12403 }
12404
12405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12406         LDKDecodeError e_conv;
12407         e_conv.inner = (void*)(e & (~1));
12408         e_conv.is_owned = (e & 1) || (e == 0);
12409         e_conv = DecodeError_clone(&e_conv);
12410         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12411         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
12412         return (uint64_t)ret_conv;
12413 }
12414
12415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12416         if ((_res & 1) != 0) return;
12417         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12418         FREE((void*)_res);
12419         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
12420 }
12421
12422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12423         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
12424         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
12425         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
12426         return (uint64_t)ret_conv;
12427 }
12428
12429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12430         LDKFundingLocked o_conv;
12431         o_conv.inner = (void*)(o & (~1));
12432         o_conv.is_owned = (o & 1) || (o == 0);
12433         o_conv = FundingLocked_clone(&o_conv);
12434         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12435         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
12436         return (uint64_t)ret_conv;
12437 }
12438
12439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12440         LDKDecodeError e_conv;
12441         e_conv.inner = (void*)(e & (~1));
12442         e_conv.is_owned = (e & 1) || (e == 0);
12443         e_conv = DecodeError_clone(&e_conv);
12444         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12445         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
12446         return (uint64_t)ret_conv;
12447 }
12448
12449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12450         if ((_res & 1) != 0) return;
12451         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(((uint64_t)_res) & ~1);
12452         FREE((void*)_res);
12453         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
12454 }
12455
12456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12457         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
12458         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
12459         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
12460         return (uint64_t)ret_conv;
12461 }
12462
12463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12464         LDKInit o_conv;
12465         o_conv.inner = (void*)(o & (~1));
12466         o_conv.is_owned = (o & 1) || (o == 0);
12467         o_conv = Init_clone(&o_conv);
12468         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12469         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
12470         return (uint64_t)ret_conv;
12471 }
12472
12473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12474         LDKDecodeError e_conv;
12475         e_conv.inner = (void*)(e & (~1));
12476         e_conv.is_owned = (e & 1) || (e == 0);
12477         e_conv = DecodeError_clone(&e_conv);
12478         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12479         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
12480         return (uint64_t)ret_conv;
12481 }
12482
12483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12484         if ((_res & 1) != 0) return;
12485         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
12486         FREE((void*)_res);
12487         CResult_InitDecodeErrorZ_free(_res_conv);
12488 }
12489
12490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12491         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
12492         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12493         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
12494         return (uint64_t)ret_conv;
12495 }
12496
12497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12498         LDKOpenChannel o_conv;
12499         o_conv.inner = (void*)(o & (~1));
12500         o_conv.is_owned = (o & 1) || (o == 0);
12501         o_conv = OpenChannel_clone(&o_conv);
12502         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12503         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
12504         return (uint64_t)ret_conv;
12505 }
12506
12507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12508         LDKDecodeError e_conv;
12509         e_conv.inner = (void*)(e & (~1));
12510         e_conv.is_owned = (e & 1) || (e == 0);
12511         e_conv = DecodeError_clone(&e_conv);
12512         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12513         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
12514         return (uint64_t)ret_conv;
12515 }
12516
12517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12518         if ((_res & 1) != 0) return;
12519         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(((uint64_t)_res) & ~1);
12520         FREE((void*)_res);
12521         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
12522 }
12523
12524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12525         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
12526         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
12527         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
12528         return (uint64_t)ret_conv;
12529 }
12530
12531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12532         LDKRevokeAndACK o_conv;
12533         o_conv.inner = (void*)(o & (~1));
12534         o_conv.is_owned = (o & 1) || (o == 0);
12535         o_conv = RevokeAndACK_clone(&o_conv);
12536         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12537         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
12538         return (uint64_t)ret_conv;
12539 }
12540
12541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12542         LDKDecodeError e_conv;
12543         e_conv.inner = (void*)(e & (~1));
12544         e_conv.is_owned = (e & 1) || (e == 0);
12545         e_conv = DecodeError_clone(&e_conv);
12546         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12547         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
12548         return (uint64_t)ret_conv;
12549 }
12550
12551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12552         if ((_res & 1) != 0) return;
12553         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(((uint64_t)_res) & ~1);
12554         FREE((void*)_res);
12555         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
12556 }
12557
12558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12559         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
12560         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
12561         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
12562         return (uint64_t)ret_conv;
12563 }
12564
12565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12566         LDKShutdown o_conv;
12567         o_conv.inner = (void*)(o & (~1));
12568         o_conv.is_owned = (o & 1) || (o == 0);
12569         o_conv = Shutdown_clone(&o_conv);
12570         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12571         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
12572         return (uint64_t)ret_conv;
12573 }
12574
12575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12576         LDKDecodeError e_conv;
12577         e_conv.inner = (void*)(e & (~1));
12578         e_conv.is_owned = (e & 1) || (e == 0);
12579         e_conv = DecodeError_clone(&e_conv);
12580         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12581         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
12582         return (uint64_t)ret_conv;
12583 }
12584
12585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12586         if ((_res & 1) != 0) return;
12587         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(((uint64_t)_res) & ~1);
12588         FREE((void*)_res);
12589         CResult_ShutdownDecodeErrorZ_free(_res_conv);
12590 }
12591
12592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12593         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
12594         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
12595         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
12596         return (uint64_t)ret_conv;
12597 }
12598
12599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12600         LDKUpdateFailHTLC o_conv;
12601         o_conv.inner = (void*)(o & (~1));
12602         o_conv.is_owned = (o & 1) || (o == 0);
12603         o_conv = UpdateFailHTLC_clone(&o_conv);
12604         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12605         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
12606         return (uint64_t)ret_conv;
12607 }
12608
12609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12610         LDKDecodeError e_conv;
12611         e_conv.inner = (void*)(e & (~1));
12612         e_conv.is_owned = (e & 1) || (e == 0);
12613         e_conv = DecodeError_clone(&e_conv);
12614         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12615         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
12616         return (uint64_t)ret_conv;
12617 }
12618
12619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12620         if ((_res & 1) != 0) return;
12621         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12622         FREE((void*)_res);
12623         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
12624 }
12625
12626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12627         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
12628         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
12629         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
12630         return (uint64_t)ret_conv;
12631 }
12632
12633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12634         LDKUpdateFailMalformedHTLC o_conv;
12635         o_conv.inner = (void*)(o & (~1));
12636         o_conv.is_owned = (o & 1) || (o == 0);
12637         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
12638         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12639         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
12640         return (uint64_t)ret_conv;
12641 }
12642
12643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12644         LDKDecodeError e_conv;
12645         e_conv.inner = (void*)(e & (~1));
12646         e_conv.is_owned = (e & 1) || (e == 0);
12647         e_conv = DecodeError_clone(&e_conv);
12648         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12649         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
12650         return (uint64_t)ret_conv;
12651 }
12652
12653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12654         if ((_res & 1) != 0) return;
12655         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12656         FREE((void*)_res);
12657         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
12658 }
12659
12660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12661         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
12662         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
12663         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
12664         return (uint64_t)ret_conv;
12665 }
12666
12667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12668         LDKUpdateFee o_conv;
12669         o_conv.inner = (void*)(o & (~1));
12670         o_conv.is_owned = (o & 1) || (o == 0);
12671         o_conv = UpdateFee_clone(&o_conv);
12672         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12673         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
12674         return (uint64_t)ret_conv;
12675 }
12676
12677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12678         LDKDecodeError e_conv;
12679         e_conv.inner = (void*)(e & (~1));
12680         e_conv.is_owned = (e & 1) || (e == 0);
12681         e_conv = DecodeError_clone(&e_conv);
12682         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12683         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
12684         return (uint64_t)ret_conv;
12685 }
12686
12687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12688         if ((_res & 1) != 0) return;
12689         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(((uint64_t)_res) & ~1);
12690         FREE((void*)_res);
12691         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
12692 }
12693
12694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12695         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
12696         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
12697         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
12698         return (uint64_t)ret_conv;
12699 }
12700
12701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12702         LDKUpdateFulfillHTLC o_conv;
12703         o_conv.inner = (void*)(o & (~1));
12704         o_conv.is_owned = (o & 1) || (o == 0);
12705         o_conv = UpdateFulfillHTLC_clone(&o_conv);
12706         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12707         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
12708         return (uint64_t)ret_conv;
12709 }
12710
12711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12712         LDKDecodeError e_conv;
12713         e_conv.inner = (void*)(e & (~1));
12714         e_conv.is_owned = (e & 1) || (e == 0);
12715         e_conv = DecodeError_clone(&e_conv);
12716         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12717         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
12718         return (uint64_t)ret_conv;
12719 }
12720
12721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12722         if ((_res & 1) != 0) return;
12723         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12724         FREE((void*)_res);
12725         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
12726 }
12727
12728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12729         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
12730         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
12731         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
12732         return (uint64_t)ret_conv;
12733 }
12734
12735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12736         LDKUpdateAddHTLC o_conv;
12737         o_conv.inner = (void*)(o & (~1));
12738         o_conv.is_owned = (o & 1) || (o == 0);
12739         o_conv = UpdateAddHTLC_clone(&o_conv);
12740         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12741         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
12742         return (uint64_t)ret_conv;
12743 }
12744
12745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12746         LDKDecodeError e_conv;
12747         e_conv.inner = (void*)(e & (~1));
12748         e_conv.is_owned = (e & 1) || (e == 0);
12749         e_conv = DecodeError_clone(&e_conv);
12750         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12751         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
12752         return (uint64_t)ret_conv;
12753 }
12754
12755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12756         if ((_res & 1) != 0) return;
12757         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(((uint64_t)_res) & ~1);
12758         FREE((void*)_res);
12759         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
12760 }
12761
12762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12763         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
12764         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
12765         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
12766         return (uint64_t)ret_conv;
12767 }
12768
12769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12770         LDKPing o_conv;
12771         o_conv.inner = (void*)(o & (~1));
12772         o_conv.is_owned = (o & 1) || (o == 0);
12773         o_conv = Ping_clone(&o_conv);
12774         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12775         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
12776         return (uint64_t)ret_conv;
12777 }
12778
12779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12780         LDKDecodeError e_conv;
12781         e_conv.inner = (void*)(e & (~1));
12782         e_conv.is_owned = (e & 1) || (e == 0);
12783         e_conv = DecodeError_clone(&e_conv);
12784         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12785         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
12786         return (uint64_t)ret_conv;
12787 }
12788
12789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12790         if ((_res & 1) != 0) return;
12791         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
12792         FREE((void*)_res);
12793         CResult_PingDecodeErrorZ_free(_res_conv);
12794 }
12795
12796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12797         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
12798         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12799         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
12800         return (uint64_t)ret_conv;
12801 }
12802
12803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12804         LDKPong o_conv;
12805         o_conv.inner = (void*)(o & (~1));
12806         o_conv.is_owned = (o & 1) || (o == 0);
12807         o_conv = Pong_clone(&o_conv);
12808         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12809         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
12810         return (uint64_t)ret_conv;
12811 }
12812
12813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12814         LDKDecodeError e_conv;
12815         e_conv.inner = (void*)(e & (~1));
12816         e_conv.is_owned = (e & 1) || (e == 0);
12817         e_conv = DecodeError_clone(&e_conv);
12818         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12819         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
12820         return (uint64_t)ret_conv;
12821 }
12822
12823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12824         if ((_res & 1) != 0) return;
12825         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
12826         FREE((void*)_res);
12827         CResult_PongDecodeErrorZ_free(_res_conv);
12828 }
12829
12830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12831         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
12832         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12833         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
12834         return (uint64_t)ret_conv;
12835 }
12836
12837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12838         LDKUnsignedChannelAnnouncement o_conv;
12839         o_conv.inner = (void*)(o & (~1));
12840         o_conv.is_owned = (o & 1) || (o == 0);
12841         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
12842         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12843         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
12844         return (uint64_t)ret_conv;
12845 }
12846
12847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12848         LDKDecodeError e_conv;
12849         e_conv.inner = (void*)(e & (~1));
12850         e_conv.is_owned = (e & 1) || (e == 0);
12851         e_conv = DecodeError_clone(&e_conv);
12852         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12853         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
12854         return (uint64_t)ret_conv;
12855 }
12856
12857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12858         if ((_res & 1) != 0) return;
12859         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12860         FREE((void*)_res);
12861         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
12862 }
12863
12864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12865         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12866         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12867         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12868         return (uint64_t)ret_conv;
12869 }
12870
12871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12872         LDKChannelAnnouncement o_conv;
12873         o_conv.inner = (void*)(o & (~1));
12874         o_conv.is_owned = (o & 1) || (o == 0);
12875         o_conv = ChannelAnnouncement_clone(&o_conv);
12876         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12877         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
12878         return (uint64_t)ret_conv;
12879 }
12880
12881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12882         LDKDecodeError e_conv;
12883         e_conv.inner = (void*)(e & (~1));
12884         e_conv.is_owned = (e & 1) || (e == 0);
12885         e_conv = DecodeError_clone(&e_conv);
12886         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12887         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
12888         return (uint64_t)ret_conv;
12889 }
12890
12891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12892         if ((_res & 1) != 0) return;
12893         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
12894         FREE((void*)_res);
12895         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
12896 }
12897
12898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12899         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
12900         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
12901         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
12902         return (uint64_t)ret_conv;
12903 }
12904
12905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12906         LDKUnsignedChannelUpdate o_conv;
12907         o_conv.inner = (void*)(o & (~1));
12908         o_conv.is_owned = (o & 1) || (o == 0);
12909         o_conv = UnsignedChannelUpdate_clone(&o_conv);
12910         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12911         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
12912         return (uint64_t)ret_conv;
12913 }
12914
12915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12916         LDKDecodeError e_conv;
12917         e_conv.inner = (void*)(e & (~1));
12918         e_conv.is_owned = (e & 1) || (e == 0);
12919         e_conv = DecodeError_clone(&e_conv);
12920         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12921         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
12922         return (uint64_t)ret_conv;
12923 }
12924
12925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12926         if ((_res & 1) != 0) return;
12927         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12928         FREE((void*)_res);
12929         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
12930 }
12931
12932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12933         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
12934         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12935         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
12936         return (uint64_t)ret_conv;
12937 }
12938
12939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12940         LDKChannelUpdate o_conv;
12941         o_conv.inner = (void*)(o & (~1));
12942         o_conv.is_owned = (o & 1) || (o == 0);
12943         o_conv = ChannelUpdate_clone(&o_conv);
12944         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12945         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
12946         return (uint64_t)ret_conv;
12947 }
12948
12949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12950         LDKDecodeError e_conv;
12951         e_conv.inner = (void*)(e & (~1));
12952         e_conv.is_owned = (e & 1) || (e == 0);
12953         e_conv = DecodeError_clone(&e_conv);
12954         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12955         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
12956         return (uint64_t)ret_conv;
12957 }
12958
12959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12960         if ((_res & 1) != 0) return;
12961         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
12962         FREE((void*)_res);
12963         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
12964 }
12965
12966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12967         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
12968         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
12969         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
12970         return (uint64_t)ret_conv;
12971 }
12972
12973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12974         LDKErrorMessage o_conv;
12975         o_conv.inner = (void*)(o & (~1));
12976         o_conv.is_owned = (o & 1) || (o == 0);
12977         o_conv = ErrorMessage_clone(&o_conv);
12978         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12979         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
12980         return (uint64_t)ret_conv;
12981 }
12982
12983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12984         LDKDecodeError e_conv;
12985         e_conv.inner = (void*)(e & (~1));
12986         e_conv.is_owned = (e & 1) || (e == 0);
12987         e_conv = DecodeError_clone(&e_conv);
12988         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12989         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
12990         return (uint64_t)ret_conv;
12991 }
12992
12993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12994         if ((_res & 1) != 0) return;
12995         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
12996         FREE((void*)_res);
12997         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
12998 }
12999
13000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13001         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
13002         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
13003         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
13004         return (uint64_t)ret_conv;
13005 }
13006
13007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13008         LDKUnsignedNodeAnnouncement o_conv;
13009         o_conv.inner = (void*)(o & (~1));
13010         o_conv.is_owned = (o & 1) || (o == 0);
13011         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
13012         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13013         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
13014         return (uint64_t)ret_conv;
13015 }
13016
13017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13018         LDKDecodeError e_conv;
13019         e_conv.inner = (void*)(e & (~1));
13020         e_conv.is_owned = (e & 1) || (e == 0);
13021         e_conv = DecodeError_clone(&e_conv);
13022         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13023         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
13024         return (uint64_t)ret_conv;
13025 }
13026
13027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13028         if ((_res & 1) != 0) return;
13029         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13030         FREE((void*)_res);
13031         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
13032 }
13033
13034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13035         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
13036         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
13037         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
13038         return (uint64_t)ret_conv;
13039 }
13040
13041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13042         LDKNodeAnnouncement o_conv;
13043         o_conv.inner = (void*)(o & (~1));
13044         o_conv.is_owned = (o & 1) || (o == 0);
13045         o_conv = NodeAnnouncement_clone(&o_conv);
13046         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13047         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
13048         return (uint64_t)ret_conv;
13049 }
13050
13051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13052         LDKDecodeError e_conv;
13053         e_conv.inner = (void*)(e & (~1));
13054         e_conv.is_owned = (e & 1) || (e == 0);
13055         e_conv = DecodeError_clone(&e_conv);
13056         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13057         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
13058         return (uint64_t)ret_conv;
13059 }
13060
13061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13062         if ((_res & 1) != 0) return;
13063         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
13064         FREE((void*)_res);
13065         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
13066 }
13067
13068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13069         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
13070         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
13071         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
13072         return (uint64_t)ret_conv;
13073 }
13074
13075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13076         LDKQueryShortChannelIds o_conv;
13077         o_conv.inner = (void*)(o & (~1));
13078         o_conv.is_owned = (o & 1) || (o == 0);
13079         o_conv = QueryShortChannelIds_clone(&o_conv);
13080         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13081         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
13082         return (uint64_t)ret_conv;
13083 }
13084
13085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13086         LDKDecodeError e_conv;
13087         e_conv.inner = (void*)(e & (~1));
13088         e_conv.is_owned = (e & 1) || (e == 0);
13089         e_conv = DecodeError_clone(&e_conv);
13090         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13091         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
13092         return (uint64_t)ret_conv;
13093 }
13094
13095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13096         if ((_res & 1) != 0) return;
13097         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
13098         FREE((void*)_res);
13099         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
13100 }
13101
13102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13103         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
13104         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
13105         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
13106         return (uint64_t)ret_conv;
13107 }
13108
13109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13110         LDKReplyShortChannelIdsEnd o_conv;
13111         o_conv.inner = (void*)(o & (~1));
13112         o_conv.is_owned = (o & 1) || (o == 0);
13113         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
13114         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13115         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
13116         return (uint64_t)ret_conv;
13117 }
13118
13119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13120         LDKDecodeError e_conv;
13121         e_conv.inner = (void*)(e & (~1));
13122         e_conv.is_owned = (e & 1) || (e == 0);
13123         e_conv = DecodeError_clone(&e_conv);
13124         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13125         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
13126         return (uint64_t)ret_conv;
13127 }
13128
13129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13130         if ((_res & 1) != 0) return;
13131         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
13132         FREE((void*)_res);
13133         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
13134 }
13135
13136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13137         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
13138         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
13139         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
13140         return (uint64_t)ret_conv;
13141 }
13142
13143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13144         LDKQueryChannelRange o_conv;
13145         o_conv.inner = (void*)(o & (~1));
13146         o_conv.is_owned = (o & 1) || (o == 0);
13147         o_conv = QueryChannelRange_clone(&o_conv);
13148         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13149         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
13150         return (uint64_t)ret_conv;
13151 }
13152
13153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13154         LDKDecodeError e_conv;
13155         e_conv.inner = (void*)(e & (~1));
13156         e_conv.is_owned = (e & 1) || (e == 0);
13157         e_conv = DecodeError_clone(&e_conv);
13158         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13159         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
13160         return (uint64_t)ret_conv;
13161 }
13162
13163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13164         if ((_res & 1) != 0) return;
13165         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13166         FREE((void*)_res);
13167         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
13168 }
13169
13170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13171         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
13172         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
13173         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
13174         return (uint64_t)ret_conv;
13175 }
13176
13177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13178         LDKReplyChannelRange o_conv;
13179         o_conv.inner = (void*)(o & (~1));
13180         o_conv.is_owned = (o & 1) || (o == 0);
13181         o_conv = ReplyChannelRange_clone(&o_conv);
13182         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13183         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
13184         return (uint64_t)ret_conv;
13185 }
13186
13187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13188         LDKDecodeError e_conv;
13189         e_conv.inner = (void*)(e & (~1));
13190         e_conv.is_owned = (e & 1) || (e == 0);
13191         e_conv = DecodeError_clone(&e_conv);
13192         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13193         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
13194         return (uint64_t)ret_conv;
13195 }
13196
13197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13198         if ((_res & 1) != 0) return;
13199         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
13200         FREE((void*)_res);
13201         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
13202 }
13203
13204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13205         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
13206         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
13207         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
13208         return (uint64_t)ret_conv;
13209 }
13210
13211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13212         LDKGossipTimestampFilter o_conv;
13213         o_conv.inner = (void*)(o & (~1));
13214         o_conv.is_owned = (o & 1) || (o == 0);
13215         o_conv = GossipTimestampFilter_clone(&o_conv);
13216         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13217         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
13218         return (uint64_t)ret_conv;
13219 }
13220
13221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13222         LDKDecodeError e_conv;
13223         e_conv.inner = (void*)(e & (~1));
13224         e_conv.is_owned = (e & 1) || (e == 0);
13225         e_conv = DecodeError_clone(&e_conv);
13226         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13227         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
13228         return (uint64_t)ret_conv;
13229 }
13230
13231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13232         if ((_res & 1) != 0) return;
13233         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
13234         FREE((void*)_res);
13235         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
13236 }
13237
13238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13239         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
13240         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
13241         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
13242         return (uint64_t)ret_conv;
13243 }
13244
13245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13246         LDKInvoice o_conv;
13247         o_conv.inner = (void*)(o & (~1));
13248         o_conv.is_owned = (o & 1) || (o == 0);
13249         o_conv = Invoice_clone(&o_conv);
13250         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13251         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
13252         return (uint64_t)ret_conv;
13253 }
13254
13255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13256         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(((uint64_t)e) & ~1);
13257         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13258         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
13259         return (uint64_t)ret_conv;
13260 }
13261
13262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13263         if ((_res & 1) != 0) return;
13264         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(((uint64_t)_res) & ~1);
13265         FREE((void*)_res);
13266         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
13267 }
13268
13269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13270         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
13271         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
13272         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
13273         return (uint64_t)ret_conv;
13274 }
13275
13276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13277         if ((this_ptr & 1) != 0) return;
13278         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
13279         FREE((void*)this_ptr);
13280         Event_free(this_ptr_conv);
13281 }
13282
13283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13284         LDKEvent* orig_conv = (LDKEvent*)orig;
13285         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13286         *ret_copy = Event_clone(orig_conv);
13287         uint64_t ret_ref = (uint64_t)ret_copy;
13288         return ret_ref;
13289 }
13290
13291 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) {
13292         LDKThirtyTwoBytes temporary_channel_id_ref;
13293         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
13294         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
13295         LDKCVec_u8Z output_script_ref;
13296         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
13297         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
13298         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
13299         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13300         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
13301         uint64_t ret_ref = (uint64_t)ret_copy;
13302         return ret_ref;
13303 }
13304
13305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t amt, int64_t user_payment_id) {
13306         LDKThirtyTwoBytes payment_hash_ref;
13307         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13308         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13309         LDKThirtyTwoBytes payment_preimage_ref;
13310         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13311         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13312         LDKThirtyTwoBytes payment_secret_ref;
13313         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13314         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13315         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13316         *ret_copy = Event_payment_received(payment_hash_ref, payment_preimage_ref, payment_secret_ref, amt, user_payment_id);
13317         uint64_t ret_ref = (uint64_t)ret_copy;
13318         return ret_ref;
13319 }
13320
13321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_preimage) {
13322         LDKThirtyTwoBytes payment_preimage_ref;
13323         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13324         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13325         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13326         *ret_copy = Event_payment_sent(payment_preimage_ref);
13327         uint64_t ret_ref = (uint64_t)ret_copy;
13328         return ret_ref;
13329 }
13330
13331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_hash, jboolean rejected_by_dest) {
13332         LDKThirtyTwoBytes payment_hash_ref;
13333         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13334         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13335         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13336         *ret_copy = Event_payment_failed(payment_hash_ref, rejected_by_dest);
13337         uint64_t ret_ref = (uint64_t)ret_copy;
13338         return ret_ref;
13339 }
13340
13341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
13342         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13343         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
13344         uint64_t ret_ref = (uint64_t)ret_copy;
13345         return ret_ref;
13346 }
13347
13348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
13349         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
13350         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
13351         if (outputs_constr.datalen > 0)
13352                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
13353         else
13354                 outputs_constr.data = NULL;
13355         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
13356         for (size_t b = 0; b < outputs_constr.datalen; b++) {
13357                 int64_t outputs_conv_27 = outputs_vals[b];
13358                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1);
13359                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
13360                 outputs_constr.data[b] = outputs_conv_27_conv;
13361         }
13362         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
13363         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
13364         *ret_copy = Event_spendable_outputs(outputs_constr);
13365         uint64_t ret_ref = (uint64_t)ret_copy;
13366         return ret_ref;
13367 }
13368
13369 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
13370         LDKEvent* obj_conv = (LDKEvent*)obj;
13371         LDKCVec_u8Z ret_var = Event_write(obj_conv);
13372         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13373         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13374         CVec_u8Z_free(ret_var);
13375         return ret_arr;
13376 }
13377
13378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13379         if ((this_ptr & 1) != 0) return;
13380         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
13381         FREE((void*)this_ptr);
13382         MessageSendEvent_free(this_ptr_conv);
13383 }
13384
13385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13386         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
13387         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13388         *ret_copy = MessageSendEvent_clone(orig_conv);
13389         uint64_t ret_ref = (uint64_t)ret_copy;
13390         return ret_ref;
13391 }
13392
13393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13394         LDKPublicKey node_id_ref;
13395         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13396         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13397         LDKAcceptChannel msg_conv;
13398         msg_conv.inner = (void*)(msg & (~1));
13399         msg_conv.is_owned = (msg & 1) || (msg == 0);
13400         msg_conv = AcceptChannel_clone(&msg_conv);
13401         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13402         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
13403         uint64_t ret_ref = (uint64_t)ret_copy;
13404         return ret_ref;
13405 }
13406
13407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13408         LDKPublicKey node_id_ref;
13409         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13410         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13411         LDKOpenChannel msg_conv;
13412         msg_conv.inner = (void*)(msg & (~1));
13413         msg_conv.is_owned = (msg & 1) || (msg == 0);
13414         msg_conv = OpenChannel_clone(&msg_conv);
13415         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13416         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
13417         uint64_t ret_ref = (uint64_t)ret_copy;
13418         return ret_ref;
13419 }
13420
13421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13422         LDKPublicKey node_id_ref;
13423         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13424         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13425         LDKFundingCreated msg_conv;
13426         msg_conv.inner = (void*)(msg & (~1));
13427         msg_conv.is_owned = (msg & 1) || (msg == 0);
13428         msg_conv = FundingCreated_clone(&msg_conv);
13429         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13430         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
13431         uint64_t ret_ref = (uint64_t)ret_copy;
13432         return ret_ref;
13433 }
13434
13435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13436         LDKPublicKey node_id_ref;
13437         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13438         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13439         LDKFundingSigned msg_conv;
13440         msg_conv.inner = (void*)(msg & (~1));
13441         msg_conv.is_owned = (msg & 1) || (msg == 0);
13442         msg_conv = FundingSigned_clone(&msg_conv);
13443         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13444         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
13445         uint64_t ret_ref = (uint64_t)ret_copy;
13446         return ret_ref;
13447 }
13448
13449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13450         LDKPublicKey node_id_ref;
13451         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13452         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13453         LDKFundingLocked msg_conv;
13454         msg_conv.inner = (void*)(msg & (~1));
13455         msg_conv.is_owned = (msg & 1) || (msg == 0);
13456         msg_conv = FundingLocked_clone(&msg_conv);
13457         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13458         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
13459         uint64_t ret_ref = (uint64_t)ret_copy;
13460         return ret_ref;
13461 }
13462
13463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13464         LDKPublicKey node_id_ref;
13465         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13466         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13467         LDKAnnouncementSignatures msg_conv;
13468         msg_conv.inner = (void*)(msg & (~1));
13469         msg_conv.is_owned = (msg & 1) || (msg == 0);
13470         msg_conv = AnnouncementSignatures_clone(&msg_conv);
13471         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13472         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
13473         uint64_t ret_ref = (uint64_t)ret_copy;
13474         return ret_ref;
13475 }
13476
13477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
13478         LDKPublicKey node_id_ref;
13479         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13480         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13481         LDKCommitmentUpdate updates_conv;
13482         updates_conv.inner = (void*)(updates & (~1));
13483         updates_conv.is_owned = (updates & 1) || (updates == 0);
13484         updates_conv = CommitmentUpdate_clone(&updates_conv);
13485         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13486         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
13487         uint64_t ret_ref = (uint64_t)ret_copy;
13488         return ret_ref;
13489 }
13490
13491 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) {
13492         LDKPublicKey node_id_ref;
13493         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13494         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13495         LDKRevokeAndACK msg_conv;
13496         msg_conv.inner = (void*)(msg & (~1));
13497         msg_conv.is_owned = (msg & 1) || (msg == 0);
13498         msg_conv = RevokeAndACK_clone(&msg_conv);
13499         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13500         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
13501         uint64_t ret_ref = (uint64_t)ret_copy;
13502         return ret_ref;
13503 }
13504
13505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13506         LDKPublicKey node_id_ref;
13507         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13508         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13509         LDKClosingSigned msg_conv;
13510         msg_conv.inner = (void*)(msg & (~1));
13511         msg_conv.is_owned = (msg & 1) || (msg == 0);
13512         msg_conv = ClosingSigned_clone(&msg_conv);
13513         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13514         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
13515         uint64_t ret_ref = (uint64_t)ret_copy;
13516         return ret_ref;
13517 }
13518
13519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13520         LDKPublicKey node_id_ref;
13521         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13522         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13523         LDKShutdown msg_conv;
13524         msg_conv.inner = (void*)(msg & (~1));
13525         msg_conv.is_owned = (msg & 1) || (msg == 0);
13526         msg_conv = Shutdown_clone(&msg_conv);
13527         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13528         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
13529         uint64_t ret_ref = (uint64_t)ret_copy;
13530         return ret_ref;
13531 }
13532
13533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13534         LDKPublicKey node_id_ref;
13535         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13536         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13537         LDKChannelReestablish msg_conv;
13538         msg_conv.inner = (void*)(msg & (~1));
13539         msg_conv.is_owned = (msg & 1) || (msg == 0);
13540         msg_conv = ChannelReestablish_clone(&msg_conv);
13541         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13542         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
13543         uint64_t ret_ref = (uint64_t)ret_copy;
13544         return ret_ref;
13545 }
13546
13547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
13548         LDKChannelAnnouncement msg_conv;
13549         msg_conv.inner = (void*)(msg & (~1));
13550         msg_conv.is_owned = (msg & 1) || (msg == 0);
13551         msg_conv = ChannelAnnouncement_clone(&msg_conv);
13552         LDKChannelUpdate update_msg_conv;
13553         update_msg_conv.inner = (void*)(update_msg & (~1));
13554         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
13555         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
13556         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13557         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
13558         uint64_t ret_ref = (uint64_t)ret_copy;
13559         return ret_ref;
13560 }
13561
13562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
13563         LDKNodeAnnouncement msg_conv;
13564         msg_conv.inner = (void*)(msg & (~1));
13565         msg_conv.is_owned = (msg & 1) || (msg == 0);
13566         msg_conv = NodeAnnouncement_clone(&msg_conv);
13567         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13568         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
13569         uint64_t ret_ref = (uint64_t)ret_copy;
13570         return ret_ref;
13571 }
13572
13573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
13574         LDKChannelUpdate msg_conv;
13575         msg_conv.inner = (void*)(msg & (~1));
13576         msg_conv.is_owned = (msg & 1) || (msg == 0);
13577         msg_conv = ChannelUpdate_clone(&msg_conv);
13578         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13579         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
13580         uint64_t ret_ref = (uint64_t)ret_copy;
13581         return ret_ref;
13582 }
13583
13584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
13585         LDKPublicKey node_id_ref;
13586         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13587         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13588         LDKChannelUpdate msg_conv;
13589         msg_conv.inner = (void*)(msg & (~1));
13590         msg_conv.is_owned = (msg & 1) || (msg == 0);
13591         msg_conv = ChannelUpdate_clone(&msg_conv);
13592         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13593         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
13594         uint64_t ret_ref = (uint64_t)ret_copy;
13595         return ret_ref;
13596 }
13597
13598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
13599         LDKPublicKey node_id_ref;
13600         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13601         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13602         LDKErrorAction action_conv = *(LDKErrorAction*)(((uint64_t)action) & ~1);
13603         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13604         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
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_MessageSendEvent_1payment_1failure_1network_1update(JNIEnv *env, jclass clz, int64_t update) {
13610         LDKHTLCFailChannelUpdate update_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)update) & ~1);
13611         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13612         *ret_copy = MessageSendEvent_payment_failure_network_update(update_conv);
13613         uint64_t ret_ref = (uint64_t)ret_copy;
13614         return ret_ref;
13615 }
13616
13617 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) {
13618         LDKPublicKey node_id_ref;
13619         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13620         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13621         LDKQueryChannelRange msg_conv;
13622         msg_conv.inner = (void*)(msg & (~1));
13623         msg_conv.is_owned = (msg & 1) || (msg == 0);
13624         msg_conv = QueryChannelRange_clone(&msg_conv);
13625         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13626         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
13627         uint64_t ret_ref = (uint64_t)ret_copy;
13628         return ret_ref;
13629 }
13630
13631 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) {
13632         LDKPublicKey node_id_ref;
13633         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13634         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13635         LDKQueryShortChannelIds msg_conv;
13636         msg_conv.inner = (void*)(msg & (~1));
13637         msg_conv.is_owned = (msg & 1) || (msg == 0);
13638         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13639         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13640         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
13641         uint64_t ret_ref = (uint64_t)ret_copy;
13642         return ret_ref;
13643 }
13644
13645 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) {
13646         LDKPublicKey node_id_ref;
13647         CHECK((*env)->GetArrayLength(env, node_id) == 33);
13648         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
13649         LDKReplyChannelRange msg_conv;
13650         msg_conv.inner = (void*)(msg & (~1));
13651         msg_conv.is_owned = (msg & 1) || (msg == 0);
13652         msg_conv = ReplyChannelRange_clone(&msg_conv);
13653         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
13654         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
13655         uint64_t ret_ref = (uint64_t)ret_copy;
13656         return ret_ref;
13657 }
13658
13659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13660         if ((this_ptr & 1) != 0) return;
13661         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
13662         FREE((void*)this_ptr);
13663         MessageSendEventsProvider_free(this_ptr_conv);
13664 }
13665
13666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13667         if ((this_ptr & 1) != 0) return;
13668         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
13669         FREE((void*)this_ptr);
13670         EventsProvider_free(this_ptr_conv);
13671 }
13672
13673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13674         if ((this_ptr & 1) != 0) return;
13675         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(((uint64_t)this_ptr) & ~1);
13676         FREE((void*)this_ptr);
13677         EventHandler_free(this_ptr_conv);
13678 }
13679
13680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13681         if ((this_ptr & 1) != 0) return;
13682         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
13683         FREE((void*)this_ptr);
13684         APIError_free(this_ptr_conv);
13685 }
13686
13687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13688         LDKAPIError* orig_conv = (LDKAPIError*)orig;
13689         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13690         *ret_copy = APIError_clone(orig_conv);
13691         uint64_t ret_ref = (uint64_t)ret_copy;
13692         return ret_ref;
13693 }
13694
13695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
13696         LDKStr err_conv = java_to_owned_str(env, err);
13697         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13698         *ret_copy = APIError_apimisuse_error(err_conv);
13699         uint64_t ret_ref = (uint64_t)ret_copy;
13700         return ret_ref;
13701 }
13702
13703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
13704         LDKStr err_conv = java_to_owned_str(env, err);
13705         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13706         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
13707         uint64_t ret_ref = (uint64_t)ret_copy;
13708         return ret_ref;
13709 }
13710
13711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
13712         LDKStr err_conv = java_to_owned_str(env, err);
13713         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13714         *ret_copy = APIError_route_error(err_conv);
13715         uint64_t ret_ref = (uint64_t)ret_copy;
13716         return ret_ref;
13717 }
13718
13719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
13720         LDKStr err_conv = java_to_owned_str(env, err);
13721         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13722         *ret_copy = APIError_channel_unavailable(err_conv);
13723         uint64_t ret_ref = (uint64_t)ret_copy;
13724         return ret_ref;
13725 }
13726
13727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
13728         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
13729         *ret_copy = APIError_monitor_update_failed();
13730         uint64_t ret_ref = (uint64_t)ret_copy;
13731         return ret_ref;
13732 }
13733
13734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
13735         LDKu8slice msg_ref;
13736         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13737         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13738         unsigned char sk_arr[32];
13739         CHECK((*env)->GetArrayLength(env, sk) == 32);
13740         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
13741         unsigned char (*sk_ref)[32] = &sk_arr;
13742         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
13743         *ret_conv = sign(msg_ref, sk_ref);
13744         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13745         return (uint64_t)ret_conv;
13746 }
13747
13748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
13749         LDKu8slice msg_ref;
13750         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13751         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13752         LDKStr sig_conv = java_to_owned_str(env, sig);
13753         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13754         *ret_conv = recover_pk(msg_ref, sig_conv);
13755         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13756         return (uint64_t)ret_conv;
13757 }
13758
13759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
13760         LDKu8slice msg_ref;
13761         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
13762         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
13763         LDKStr sig_conv = java_to_owned_str(env, sig);
13764         LDKPublicKey pk_ref;
13765         CHECK((*env)->GetArrayLength(env, pk) == 33);
13766         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
13767         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
13768         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
13769         return ret_val;
13770 }
13771
13772 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13773         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
13774         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
13775         return ret_conv;
13776 }
13777
13778 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
13779         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
13780         return ret_conv;
13781 }
13782
13783 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
13784         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
13785         return ret_conv;
13786 }
13787
13788 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
13789         jclass ret_conv = LDKLevel_to_java(env, Level_info());
13790         return ret_conv;
13791 }
13792
13793 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
13794         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
13795         return ret_conv;
13796 }
13797
13798 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
13799         jclass ret_conv = LDKLevel_to_java(env, Level_error());
13800         return ret_conv;
13801 }
13802
13803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
13804         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
13805         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
13806         jboolean ret_val = Level_eq(a_conv, b_conv);
13807         return ret_val;
13808 }
13809
13810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
13811         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
13812         int64_t ret_val = Level_hash(o_conv);
13813         return ret_val;
13814 }
13815
13816 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
13817         jclass ret_conv = LDKLevel_to_java(env, Level_max());
13818         return ret_conv;
13819 }
13820
13821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
13822         if ((this_ptr & 1) != 0) return;
13823         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
13824         FREE((void*)this_ptr);
13825         Logger_free(this_ptr_conv);
13826 }
13827
13828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13829         LDKChannelHandshakeConfig this_obj_conv;
13830         this_obj_conv.inner = (void*)(this_obj & (~1));
13831         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13832         ChannelHandshakeConfig_free(this_obj_conv);
13833 }
13834
13835 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13836         LDKChannelHandshakeConfig this_ptr_conv;
13837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13838         this_ptr_conv.is_owned = false;
13839         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
13840         return ret_val;
13841 }
13842
13843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
13844         LDKChannelHandshakeConfig this_ptr_conv;
13845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13846         this_ptr_conv.is_owned = false;
13847         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
13848 }
13849
13850 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
13851         LDKChannelHandshakeConfig this_ptr_conv;
13852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13853         this_ptr_conv.is_owned = false;
13854         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
13855         return ret_val;
13856 }
13857
13858 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) {
13859         LDKChannelHandshakeConfig this_ptr_conv;
13860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13861         this_ptr_conv.is_owned = false;
13862         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
13863 }
13864
13865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13866         LDKChannelHandshakeConfig this_ptr_conv;
13867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13868         this_ptr_conv.is_owned = false;
13869         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
13870         return ret_val;
13871 }
13872
13873 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) {
13874         LDKChannelHandshakeConfig this_ptr_conv;
13875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13876         this_ptr_conv.is_owned = false;
13877         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
13878 }
13879
13880 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) {
13881         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
13882         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13883         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13884         uint64_t ret_ref = (uint64_t)ret_var.inner;
13885         if (ret_var.is_owned) {
13886                 ret_ref |= 1;
13887         }
13888         return ret_ref;
13889 }
13890
13891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13892         LDKChannelHandshakeConfig orig_conv;
13893         orig_conv.inner = (void*)(orig & (~1));
13894         orig_conv.is_owned = false;
13895         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
13896         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13897         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13898         uint64_t ret_ref = (uint64_t)ret_var.inner;
13899         if (ret_var.is_owned) {
13900                 ret_ref |= 1;
13901         }
13902         return ret_ref;
13903 }
13904
13905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
13906         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
13907         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13908         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13909         uint64_t ret_ref = (uint64_t)ret_var.inner;
13910         if (ret_var.is_owned) {
13911                 ret_ref |= 1;
13912         }
13913         return ret_ref;
13914 }
13915
13916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
13917         LDKChannelHandshakeLimits this_obj_conv;
13918         this_obj_conv.inner = (void*)(this_obj & (~1));
13919         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
13920         ChannelHandshakeLimits_free(this_obj_conv);
13921 }
13922
13923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13924         LDKChannelHandshakeLimits this_ptr_conv;
13925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13926         this_ptr_conv.is_owned = false;
13927         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
13928         return ret_val;
13929 }
13930
13931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
13932         LDKChannelHandshakeLimits this_ptr_conv;
13933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13934         this_ptr_conv.is_owned = false;
13935         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
13936 }
13937
13938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
13939         LDKChannelHandshakeLimits this_ptr_conv;
13940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13941         this_ptr_conv.is_owned = false;
13942         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
13943         return ret_val;
13944 }
13945
13946 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) {
13947         LDKChannelHandshakeLimits this_ptr_conv;
13948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13949         this_ptr_conv.is_owned = false;
13950         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
13951 }
13952
13953 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) {
13954         LDKChannelHandshakeLimits this_ptr_conv;
13955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13956         this_ptr_conv.is_owned = false;
13957         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
13958         return ret_val;
13959 }
13960
13961 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) {
13962         LDKChannelHandshakeLimits this_ptr_conv;
13963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13964         this_ptr_conv.is_owned = false;
13965         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
13966 }
13967
13968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
13969         LDKChannelHandshakeLimits this_ptr_conv;
13970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13971         this_ptr_conv.is_owned = false;
13972         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
13973         return ret_val;
13974 }
13975
13976 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) {
13977         LDKChannelHandshakeLimits this_ptr_conv;
13978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13979         this_ptr_conv.is_owned = false;
13980         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
13981 }
13982
13983 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
13984         LDKChannelHandshakeLimits this_ptr_conv;
13985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13986         this_ptr_conv.is_owned = false;
13987         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
13988         return ret_val;
13989 }
13990
13991 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) {
13992         LDKChannelHandshakeLimits this_ptr_conv;
13993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13994         this_ptr_conv.is_owned = false;
13995         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
13996 }
13997
13998 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
13999         LDKChannelHandshakeLimits this_ptr_conv;
14000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14001         this_ptr_conv.is_owned = false;
14002         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
14003         return ret_val;
14004 }
14005
14006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
14007         LDKChannelHandshakeLimits this_ptr_conv;
14008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14009         this_ptr_conv.is_owned = false;
14010         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
14011 }
14012
14013 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
14014         LDKChannelHandshakeLimits this_ptr_conv;
14015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14016         this_ptr_conv.is_owned = false;
14017         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
14018         return ret_val;
14019 }
14020
14021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14022         LDKChannelHandshakeLimits this_ptr_conv;
14023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14024         this_ptr_conv.is_owned = false;
14025         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
14026 }
14027
14028 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
14029         LDKChannelHandshakeLimits this_ptr_conv;
14030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14031         this_ptr_conv.is_owned = false;
14032         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
14033         return ret_val;
14034 }
14035
14036 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) {
14037         LDKChannelHandshakeLimits this_ptr_conv;
14038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14039         this_ptr_conv.is_owned = false;
14040         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
14041 }
14042
14043 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) {
14044         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);
14045         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14046         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14047         uint64_t ret_ref = (uint64_t)ret_var.inner;
14048         if (ret_var.is_owned) {
14049                 ret_ref |= 1;
14050         }
14051         return ret_ref;
14052 }
14053
14054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14055         LDKChannelHandshakeLimits orig_conv;
14056         orig_conv.inner = (void*)(orig & (~1));
14057         orig_conv.is_owned = false;
14058         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
14059         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14060         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14061         uint64_t ret_ref = (uint64_t)ret_var.inner;
14062         if (ret_var.is_owned) {
14063                 ret_ref |= 1;
14064         }
14065         return ret_ref;
14066 }
14067
14068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
14069         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
14070         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14071         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14072         uint64_t ret_ref = (uint64_t)ret_var.inner;
14073         if (ret_var.is_owned) {
14074                 ret_ref |= 1;
14075         }
14076         return ret_ref;
14077 }
14078
14079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14080         LDKChannelConfig this_obj_conv;
14081         this_obj_conv.inner = (void*)(this_obj & (~1));
14082         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14083         ChannelConfig_free(this_obj_conv);
14084 }
14085
14086 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
14087         LDKChannelConfig this_ptr_conv;
14088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14089         this_ptr_conv.is_owned = false;
14090         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
14091         return ret_val;
14092 }
14093
14094 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) {
14095         LDKChannelConfig this_ptr_conv;
14096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14097         this_ptr_conv.is_owned = false;
14098         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
14099 }
14100
14101 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
14102         LDKChannelConfig this_ptr_conv;
14103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14104         this_ptr_conv.is_owned = false;
14105         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
14106         return ret_val;
14107 }
14108
14109 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) {
14110         LDKChannelConfig this_ptr_conv;
14111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14112         this_ptr_conv.is_owned = false;
14113         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
14114 }
14115
14116 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
14117         LDKChannelConfig this_ptr_conv;
14118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14119         this_ptr_conv.is_owned = false;
14120         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
14121         return ret_val;
14122 }
14123
14124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
14125         LDKChannelConfig this_ptr_conv;
14126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14127         this_ptr_conv.is_owned = false;
14128         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
14129 }
14130
14131 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
14132         LDKChannelConfig this_ptr_conv;
14133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14134         this_ptr_conv.is_owned = false;
14135         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
14136         return ret_val;
14137 }
14138
14139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14140         LDKChannelConfig this_ptr_conv;
14141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14142         this_ptr_conv.is_owned = false;
14143         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
14144 }
14145
14146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14147         LDKChannelConfig this_ptr_conv;
14148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14149         this_ptr_conv.is_owned = false;
14150         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
14151         return ret_val;
14152 }
14153
14154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
14155         LDKChannelConfig this_ptr_conv;
14156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14157         this_ptr_conv.is_owned = false;
14158         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
14159 }
14160
14161 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) {
14162         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);
14163         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14164         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14165         uint64_t ret_ref = (uint64_t)ret_var.inner;
14166         if (ret_var.is_owned) {
14167                 ret_ref |= 1;
14168         }
14169         return ret_ref;
14170 }
14171
14172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14173         LDKChannelConfig orig_conv;
14174         orig_conv.inner = (void*)(orig & (~1));
14175         orig_conv.is_owned = false;
14176         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
14177         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14178         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14179         uint64_t ret_ref = (uint64_t)ret_var.inner;
14180         if (ret_var.is_owned) {
14181                 ret_ref |= 1;
14182         }
14183         return ret_ref;
14184 }
14185
14186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
14187         LDKChannelConfig ret_var = ChannelConfig_default();
14188         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14189         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14190         uint64_t ret_ref = (uint64_t)ret_var.inner;
14191         if (ret_var.is_owned) {
14192                 ret_ref |= 1;
14193         }
14194         return ret_ref;
14195 }
14196
14197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
14198         LDKChannelConfig obj_conv;
14199         obj_conv.inner = (void*)(obj & (~1));
14200         obj_conv.is_owned = false;
14201         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
14202         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14203         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14204         CVec_u8Z_free(ret_var);
14205         return ret_arr;
14206 }
14207
14208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14209         LDKu8slice ser_ref;
14210         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14211         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14212         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14213         *ret_conv = ChannelConfig_read(ser_ref);
14214         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14215         return (uint64_t)ret_conv;
14216 }
14217
14218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14219         LDKUserConfig this_obj_conv;
14220         this_obj_conv.inner = (void*)(this_obj & (~1));
14221         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14222         UserConfig_free(this_obj_conv);
14223 }
14224
14225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
14226         LDKUserConfig this_ptr_conv;
14227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14228         this_ptr_conv.is_owned = false;
14229         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
14230         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14231         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14232         uint64_t ret_ref = (uint64_t)ret_var.inner;
14233         if (ret_var.is_owned) {
14234                 ret_ref |= 1;
14235         }
14236         return ret_ref;
14237 }
14238
14239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14240         LDKUserConfig this_ptr_conv;
14241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14242         this_ptr_conv.is_owned = false;
14243         LDKChannelHandshakeConfig val_conv;
14244         val_conv.inner = (void*)(val & (~1));
14245         val_conv.is_owned = (val & 1) || (val == 0);
14246         val_conv = ChannelHandshakeConfig_clone(&val_conv);
14247         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
14248 }
14249
14250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
14251         LDKUserConfig this_ptr_conv;
14252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14253         this_ptr_conv.is_owned = false;
14254         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
14255         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14256         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14257         uint64_t ret_ref = (uint64_t)ret_var.inner;
14258         if (ret_var.is_owned) {
14259                 ret_ref |= 1;
14260         }
14261         return ret_ref;
14262 }
14263
14264 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) {
14265         LDKUserConfig this_ptr_conv;
14266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14267         this_ptr_conv.is_owned = false;
14268         LDKChannelHandshakeLimits val_conv;
14269         val_conv.inner = (void*)(val & (~1));
14270         val_conv.is_owned = (val & 1) || (val == 0);
14271         val_conv = ChannelHandshakeLimits_clone(&val_conv);
14272         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
14273 }
14274
14275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
14276         LDKUserConfig this_ptr_conv;
14277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14278         this_ptr_conv.is_owned = false;
14279         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
14280         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14281         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14282         uint64_t ret_ref = (uint64_t)ret_var.inner;
14283         if (ret_var.is_owned) {
14284                 ret_ref |= 1;
14285         }
14286         return ret_ref;
14287 }
14288
14289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14290         LDKUserConfig this_ptr_conv;
14291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14292         this_ptr_conv.is_owned = false;
14293         LDKChannelConfig val_conv;
14294         val_conv.inner = (void*)(val & (~1));
14295         val_conv.is_owned = (val & 1) || (val == 0);
14296         val_conv = ChannelConfig_clone(&val_conv);
14297         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
14298 }
14299
14300 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
14301         LDKUserConfig this_ptr_conv;
14302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14303         this_ptr_conv.is_owned = false;
14304         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
14305         return ret_val;
14306 }
14307
14308 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) {
14309         LDKUserConfig this_ptr_conv;
14310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14311         this_ptr_conv.is_owned = false;
14312         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
14313 }
14314
14315 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) {
14316         LDKChannelHandshakeConfig own_channel_config_arg_conv;
14317         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
14318         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
14319         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
14320         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
14321         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
14322         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
14323         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
14324         LDKChannelConfig channel_options_arg_conv;
14325         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
14326         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
14327         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
14328         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);
14329         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14330         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14331         uint64_t ret_ref = (uint64_t)ret_var.inner;
14332         if (ret_var.is_owned) {
14333                 ret_ref |= 1;
14334         }
14335         return ret_ref;
14336 }
14337
14338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14339         LDKUserConfig orig_conv;
14340         orig_conv.inner = (void*)(orig & (~1));
14341         orig_conv.is_owned = false;
14342         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
14343         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14344         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14345         uint64_t ret_ref = (uint64_t)ret_var.inner;
14346         if (ret_var.is_owned) {
14347                 ret_ref |= 1;
14348         }
14349         return ret_ref;
14350 }
14351
14352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
14353         LDKUserConfig ret_var = UserConfig_default();
14354         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14355         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14356         uint64_t ret_ref = (uint64_t)ret_var.inner;
14357         if (ret_var.is_owned) {
14358                 ret_ref |= 1;
14359         }
14360         return ret_ref;
14361 }
14362
14363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14364         LDKBestBlock this_obj_conv;
14365         this_obj_conv.inner = (void*)(this_obj & (~1));
14366         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14367         BestBlock_free(this_obj_conv);
14368 }
14369
14370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14371         LDKBestBlock orig_conv;
14372         orig_conv.inner = (void*)(orig & (~1));
14373         orig_conv.is_owned = false;
14374         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
14375         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14376         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14377         uint64_t ret_ref = (uint64_t)ret_var.inner;
14378         if (ret_var.is_owned) {
14379                 ret_ref |= 1;
14380         }
14381         return ret_ref;
14382 }
14383
14384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
14385         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
14386         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
14387         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14388         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14389         uint64_t ret_ref = (uint64_t)ret_var.inner;
14390         if (ret_var.is_owned) {
14391                 ret_ref |= 1;
14392         }
14393         return ret_ref;
14394 }
14395
14396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
14397         LDKThirtyTwoBytes block_hash_ref;
14398         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
14399         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
14400         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
14401         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14402         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14403         uint64_t ret_ref = (uint64_t)ret_var.inner;
14404         if (ret_var.is_owned) {
14405                 ret_ref |= 1;
14406         }
14407         return ret_ref;
14408 }
14409
14410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14411         LDKBestBlock this_arg_conv;
14412         this_arg_conv.inner = (void*)(this_arg & (~1));
14413         this_arg_conv.is_owned = false;
14414         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14415         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
14416         return ret_arr;
14417 }
14418
14419 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
14420         LDKBestBlock this_arg_conv;
14421         this_arg_conv.inner = (void*)(this_arg & (~1));
14422         this_arg_conv.is_owned = false;
14423         int32_t ret_val = BestBlock_height(&this_arg_conv);
14424         return ret_val;
14425 }
14426
14427 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14428         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
14429         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
14430         return ret_conv;
14431 }
14432
14433 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
14434         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
14435         return ret_conv;
14436 }
14437
14438 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
14439         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
14440         return ret_conv;
14441 }
14442
14443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14444         if ((this_ptr & 1) != 0) return;
14445         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
14446         FREE((void*)this_ptr);
14447         Access_free(this_ptr_conv);
14448 }
14449
14450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14451         if ((this_ptr & 1) != 0) return;
14452         LDKListen this_ptr_conv = *(LDKListen*)(((uint64_t)this_ptr) & ~1);
14453         FREE((void*)this_ptr);
14454         Listen_free(this_ptr_conv);
14455 }
14456
14457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14458         if ((this_ptr & 1) != 0) return;
14459         LDKConfirm this_ptr_conv = *(LDKConfirm*)(((uint64_t)this_ptr) & ~1);
14460         FREE((void*)this_ptr);
14461         Confirm_free(this_ptr_conv);
14462 }
14463
14464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14465         if ((this_ptr & 1) != 0) return;
14466         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
14467         FREE((void*)this_ptr);
14468         Watch_free(this_ptr_conv);
14469 }
14470
14471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14472         if ((this_ptr & 1) != 0) return;
14473         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
14474         FREE((void*)this_ptr);
14475         Filter_free(this_ptr_conv);
14476 }
14477
14478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14479         LDKWatchedOutput this_obj_conv;
14480         this_obj_conv.inner = (void*)(this_obj & (~1));
14481         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14482         WatchedOutput_free(this_obj_conv);
14483 }
14484
14485 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
14486         LDKWatchedOutput this_ptr_conv;
14487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14488         this_ptr_conv.is_owned = false;
14489         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
14490         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
14491         return ret_arr;
14492 }
14493
14494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14495         LDKWatchedOutput this_ptr_conv;
14496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14497         this_ptr_conv.is_owned = false;
14498         LDKThirtyTwoBytes val_ref;
14499         CHECK((*env)->GetArrayLength(env, val) == 32);
14500         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
14501         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
14502 }
14503
14504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
14505         LDKWatchedOutput this_ptr_conv;
14506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14507         this_ptr_conv.is_owned = false;
14508         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
14509         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14510         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14511         uint64_t ret_ref = (uint64_t)ret_var.inner;
14512         if (ret_var.is_owned) {
14513                 ret_ref |= 1;
14514         }
14515         return ret_ref;
14516 }
14517
14518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14519         LDKWatchedOutput this_ptr_conv;
14520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14521         this_ptr_conv.is_owned = false;
14522         LDKOutPoint val_conv;
14523         val_conv.inner = (void*)(val & (~1));
14524         val_conv.is_owned = (val & 1) || (val == 0);
14525         val_conv = OutPoint_clone(&val_conv);
14526         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
14527 }
14528
14529 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
14530         LDKWatchedOutput this_ptr_conv;
14531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14532         this_ptr_conv.is_owned = false;
14533         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
14534         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14535         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14536         return ret_arr;
14537 }
14538
14539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
14540         LDKWatchedOutput this_ptr_conv;
14541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14542         this_ptr_conv.is_owned = false;
14543         LDKCVec_u8Z val_ref;
14544         val_ref.datalen = (*env)->GetArrayLength(env, val);
14545         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
14546         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
14547         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
14548 }
14549
14550 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) {
14551         LDKThirtyTwoBytes block_hash_arg_ref;
14552         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
14553         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
14554         LDKOutPoint outpoint_arg_conv;
14555         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
14556         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
14557         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
14558         LDKCVec_u8Z script_pubkey_arg_ref;
14559         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
14560         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
14561         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
14562         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
14563         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14564         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14565         uint64_t ret_ref = (uint64_t)ret_var.inner;
14566         if (ret_var.is_owned) {
14567                 ret_ref |= 1;
14568         }
14569         return ret_ref;
14570 }
14571
14572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14573         LDKWatchedOutput orig_conv;
14574         orig_conv.inner = (void*)(orig & (~1));
14575         orig_conv.is_owned = false;
14576         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
14577         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14578         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14579         uint64_t ret_ref = (uint64_t)ret_var.inner;
14580         if (ret_var.is_owned) {
14581                 ret_ref |= 1;
14582         }
14583         return ret_ref;
14584 }
14585
14586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
14587         LDKWatchedOutput o_conv;
14588         o_conv.inner = (void*)(o & (~1));
14589         o_conv.is_owned = false;
14590         int64_t ret_val = WatchedOutput_hash(&o_conv);
14591         return ret_val;
14592 }
14593
14594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14595         if ((this_ptr & 1) != 0) return;
14596         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
14597         FREE((void*)this_ptr);
14598         BroadcasterInterface_free(this_ptr_conv);
14599 }
14600
14601 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14602         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
14603         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
14604         return ret_conv;
14605 }
14606
14607 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
14608         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
14609         return ret_conv;
14610 }
14611
14612 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
14613         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
14614         return ret_conv;
14615 }
14616
14617 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
14618         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
14619         return ret_conv;
14620 }
14621
14622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14623         if ((this_ptr & 1) != 0) return;
14624         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
14625         FREE((void*)this_ptr);
14626         FeeEstimator_free(this_ptr_conv);
14627 }
14628
14629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14630         LDKChainMonitor this_obj_conv;
14631         this_obj_conv.inner = (void*)(this_obj & (~1));
14632         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14633         ChainMonitor_free(this_obj_conv);
14634 }
14635
14636 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) {
14637         LDKFilter *chain_source_conv_ptr = NULL;
14638         if (chain_source != 0) {
14639                 LDKFilter chain_source_conv;
14640                 chain_source_conv = *(LDKFilter*)(((uint64_t)chain_source) & ~1);
14641                 if (chain_source_conv.free == LDKFilter_JCalls_free) {
14642                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14643                         LDKFilter_JCalls_cloned(&chain_source_conv);
14644                 }
14645                 chain_source_conv_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
14646                 *chain_source_conv_ptr = chain_source_conv;
14647         }
14648         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14649         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
14650                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14651                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
14652         }
14653         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14654         if (logger_conv.free == LDKLogger_JCalls_free) {
14655                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14656                 LDKLogger_JCalls_cloned(&logger_conv);
14657         }
14658         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
14659         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
14660                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14661                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
14662         }
14663         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
14664         if (persister_conv.free == LDKPersist_JCalls_free) {
14665                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14666                 LDKPersist_JCalls_cloned(&persister_conv);
14667         }
14668         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv_ptr, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
14669         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14670         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14671         uint64_t ret_ref = (uint64_t)ret_var.inner;
14672         if (ret_var.is_owned) {
14673                 ret_ref |= 1;
14674         }
14675         return ret_ref;
14676 }
14677
14678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
14679         LDKChainMonitor this_arg_conv;
14680         this_arg_conv.inner = (void*)(this_arg & (~1));
14681         this_arg_conv.is_owned = false;
14682         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
14683         *ret = ChainMonitor_as_Listen(&this_arg_conv);
14684         return (uint64_t)ret;
14685 }
14686
14687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
14688         LDKChainMonitor this_arg_conv;
14689         this_arg_conv.inner = (void*)(this_arg & (~1));
14690         this_arg_conv.is_owned = false;
14691         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
14692         *ret = ChainMonitor_as_Confirm(&this_arg_conv);
14693         return (uint64_t)ret;
14694 }
14695
14696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
14697         LDKChainMonitor this_arg_conv;
14698         this_arg_conv.inner = (void*)(this_arg & (~1));
14699         this_arg_conv.is_owned = false;
14700         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
14701         *ret = ChainMonitor_as_Watch(&this_arg_conv);
14702         return (uint64_t)ret;
14703 }
14704
14705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
14706         LDKChainMonitor this_arg_conv;
14707         this_arg_conv.inner = (void*)(this_arg & (~1));
14708         this_arg_conv.is_owned = false;
14709         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
14710         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
14711         return (uint64_t)ret;
14712 }
14713
14714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14715         LDKChannelMonitorUpdate this_obj_conv;
14716         this_obj_conv.inner = (void*)(this_obj & (~1));
14717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14718         ChannelMonitorUpdate_free(this_obj_conv);
14719 }
14720
14721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
14722         LDKChannelMonitorUpdate this_ptr_conv;
14723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14724         this_ptr_conv.is_owned = false;
14725         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
14726         return ret_val;
14727 }
14728
14729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
14730         LDKChannelMonitorUpdate this_ptr_conv;
14731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14732         this_ptr_conv.is_owned = false;
14733         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
14734 }
14735
14736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14737         LDKChannelMonitorUpdate orig_conv;
14738         orig_conv.inner = (void*)(orig & (~1));
14739         orig_conv.is_owned = false;
14740         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
14741         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14742         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14743         uint64_t ret_ref = (uint64_t)ret_var.inner;
14744         if (ret_var.is_owned) {
14745                 ret_ref |= 1;
14746         }
14747         return ret_ref;
14748 }
14749
14750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
14751         LDKChannelMonitorUpdate obj_conv;
14752         obj_conv.inner = (void*)(obj & (~1));
14753         obj_conv.is_owned = false;
14754         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
14755         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14756         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14757         CVec_u8Z_free(ret_var);
14758         return ret_arr;
14759 }
14760
14761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14762         LDKu8slice ser_ref;
14763         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14764         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14765         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
14766         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
14767         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14768         return (uint64_t)ret_conv;
14769 }
14770
14771 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14772         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
14773         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
14774         return ret_conv;
14775 }
14776
14777 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
14778         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
14779         return ret_conv;
14780 }
14781
14782 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
14783         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
14784         return ret_conv;
14785 }
14786
14787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14788         LDKMonitorUpdateError this_obj_conv;
14789         this_obj_conv.inner = (void*)(this_obj & (~1));
14790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14791         MonitorUpdateError_free(this_obj_conv);
14792 }
14793
14794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14795         LDKMonitorUpdateError orig_conv;
14796         orig_conv.inner = (void*)(orig & (~1));
14797         orig_conv.is_owned = false;
14798         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
14799         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14800         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14801         uint64_t ret_ref = (uint64_t)ret_var.inner;
14802         if (ret_var.is_owned) {
14803                 ret_ref |= 1;
14804         }
14805         return ret_ref;
14806 }
14807
14808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
14809         if ((this_ptr & 1) != 0) return;
14810         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(((uint64_t)this_ptr) & ~1);
14811         FREE((void*)this_ptr);
14812         MonitorEvent_free(this_ptr_conv);
14813 }
14814
14815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14816         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
14817         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14818         *ret_copy = MonitorEvent_clone(orig_conv);
14819         uint64_t ret_ref = (uint64_t)ret_copy;
14820         return ret_ref;
14821 }
14822
14823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
14824         LDKHTLCUpdate a_conv;
14825         a_conv.inner = (void*)(a & (~1));
14826         a_conv.is_owned = (a & 1) || (a == 0);
14827         a_conv = HTLCUpdate_clone(&a_conv);
14828         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14829         *ret_copy = MonitorEvent_htlcevent(a_conv);
14830         uint64_t ret_ref = (uint64_t)ret_copy;
14831         return ret_ref;
14832 }
14833
14834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1broadcasted(JNIEnv *env, jclass clz, int64_t a) {
14835         LDKOutPoint a_conv;
14836         a_conv.inner = (void*)(a & (~1));
14837         a_conv.is_owned = (a & 1) || (a == 0);
14838         a_conv = OutPoint_clone(&a_conv);
14839         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14840         *ret_copy = MonitorEvent_commitment_tx_broadcasted(a_conv);
14841         uint64_t ret_ref = (uint64_t)ret_copy;
14842         return ret_ref;
14843 }
14844
14845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14846         LDKHTLCUpdate this_obj_conv;
14847         this_obj_conv.inner = (void*)(this_obj & (~1));
14848         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14849         HTLCUpdate_free(this_obj_conv);
14850 }
14851
14852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14853         LDKHTLCUpdate orig_conv;
14854         orig_conv.inner = (void*)(orig & (~1));
14855         orig_conv.is_owned = false;
14856         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_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 int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
14867         LDKHTLCUpdate obj_conv;
14868         obj_conv.inner = (void*)(obj & (~1));
14869         obj_conv.is_owned = false;
14870         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
14871         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14872         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14873         CVec_u8Z_free(ret_var);
14874         return ret_arr;
14875 }
14876
14877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
14878         LDKu8slice ser_ref;
14879         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
14880         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
14881         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
14882         *ret_conv = HTLCUpdate_read(ser_ref);
14883         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
14884         return (uint64_t)ret_conv;
14885 }
14886
14887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
14888         LDKChannelMonitor this_obj_conv;
14889         this_obj_conv.inner = (void*)(this_obj & (~1));
14890         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
14891         ChannelMonitor_free(this_obj_conv);
14892 }
14893
14894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14895         LDKChannelMonitor orig_conv;
14896         orig_conv.inner = (void*)(orig & (~1));
14897         orig_conv.is_owned = false;
14898         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
14899         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14900         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14901         uint64_t ret_ref = (uint64_t)ret_var.inner;
14902         if (ret_var.is_owned) {
14903                 ret_ref |= 1;
14904         }
14905         return ret_ref;
14906 }
14907
14908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
14909         LDKChannelMonitor obj_conv;
14910         obj_conv.inner = (void*)(obj & (~1));
14911         obj_conv.is_owned = false;
14912         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
14913         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
14914         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
14915         CVec_u8Z_free(ret_var);
14916         return ret_arr;
14917 }
14918
14919 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) {
14920         LDKChannelMonitor this_arg_conv;
14921         this_arg_conv.inner = (void*)(this_arg & (~1));
14922         this_arg_conv.is_owned = false;
14923         LDKChannelMonitorUpdate updates_conv;
14924         updates_conv.inner = (void*)(updates & (~1));
14925         updates_conv.is_owned = false;
14926         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
14927         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
14928         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
14929         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
14930         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
14931         return (uint64_t)ret_conv;
14932 }
14933
14934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14935         LDKChannelMonitor this_arg_conv;
14936         this_arg_conv.inner = (void*)(this_arg & (~1));
14937         this_arg_conv.is_owned = false;
14938         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
14939         return ret_val;
14940 }
14941
14942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
14943         LDKChannelMonitor this_arg_conv;
14944         this_arg_conv.inner = (void*)(this_arg & (~1));
14945         this_arg_conv.is_owned = false;
14946         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
14947         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
14948         return (uint64_t)ret_ref;
14949 }
14950
14951 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
14952         LDKChannelMonitor this_arg_conv;
14953         this_arg_conv.inner = (void*)(this_arg & (~1));
14954         this_arg_conv.is_owned = false;
14955         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
14956         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14957         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14958         for (size_t v = 0; v < ret_var.datalen; v++) {
14959                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_47_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
14960                 *ret_conv_47_ref = ret_var.data[v];
14961                 ret_arr_ptr[v] = (uint64_t)ret_conv_47_ref;
14962         }
14963         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14964         FREE(ret_var.data);
14965         return ret_arr;
14966 }
14967
14968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
14969         LDKChannelMonitor this_arg_conv;
14970         this_arg_conv.inner = (void*)(this_arg & (~1));
14971         this_arg_conv.is_owned = false;
14972         LDKFilter* filter_conv = (LDKFilter*)(((uint64_t)filter) & ~1);
14973         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
14974 }
14975
14976 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14977         LDKChannelMonitor this_arg_conv;
14978         this_arg_conv.inner = (void*)(this_arg & (~1));
14979         this_arg_conv.is_owned = false;
14980         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
14981         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14982         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14983         for (size_t o = 0; o < ret_var.datalen; o++) {
14984                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
14985                 *ret_conv_14_copy = MonitorEvent_clone(&ret_var.data[o]);
14986                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
14987                 ret_arr_ptr[o] = ret_conv_14_ref;
14988         }
14989         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14990         FREE(ret_var.data);
14991         return ret_arr;
14992 }
14993
14994 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
14995         LDKChannelMonitor this_arg_conv;
14996         this_arg_conv.inner = (void*)(this_arg & (~1));
14997         this_arg_conv.is_owned = false;
14998         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
14999         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15000         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15001         for (size_t h = 0; h < ret_var.datalen; h++) {
15002                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
15003                 *ret_conv_7_copy = Event_clone(&ret_var.data[h]);
15004                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
15005                 ret_arr_ptr[h] = ret_conv_7_ref;
15006         }
15007         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15008         FREE(ret_var.data);
15009         return ret_arr;
15010 }
15011
15012 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) {
15013         LDKChannelMonitor this_arg_conv;
15014         this_arg_conv.inner = (void*)(this_arg & (~1));
15015         this_arg_conv.is_owned = false;
15016         LDKLogger* logger_conv = (LDKLogger*)(((uint64_t)logger) & ~1);
15017         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
15018         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
15019         ;
15020         for (size_t i = 0; i < ret_var.datalen; i++) {
15021                 LDKTransaction ret_conv_8_var = ret_var.data[i];
15022                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
15023                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
15024                 Transaction_free(ret_conv_8_var);
15025                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
15026         }
15027         FREE(ret_var.data);
15028         return ret_arr;
15029 }
15030
15031 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) {
15032         LDKChannelMonitor this_arg_conv;
15033         this_arg_conv.inner = (void*)(this_arg & (~1));
15034         this_arg_conv.is_owned = false;
15035         unsigned char header_arr[80];
15036         CHECK((*env)->GetArrayLength(env, header) == 80);
15037         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15038         unsigned char (*header_ref)[80] = &header_arr;
15039         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
15040         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
15041         if (txdata_constr.datalen > 0)
15042                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15043         else
15044                 txdata_constr.data = NULL;
15045         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
15046         for (size_t y = 0; y < txdata_constr.datalen; y++) {
15047                 int64_t txdata_conv_24 = txdata_vals[y];
15048                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
15049                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
15050                 txdata_constr.data[y] = txdata_conv_24_conv;
15051         }
15052         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
15053         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15054         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15055                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15056                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15057         }
15058         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15059         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15060                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15061                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15062         }
15063         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15064         if (logger_conv.free == LDKLogger_JCalls_free) {
15065                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15066                 LDKLogger_JCalls_cloned(&logger_conv);
15067         }
15068         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);
15069         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15070         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15071         for (size_t u = 0; u < ret_var.datalen; u++) {
15072                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15073                 *ret_conv_46_ref = ret_var.data[u];
15074                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
15075         }
15076         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15077         FREE(ret_var.data);
15078         return ret_arr;
15079 }
15080
15081 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) {
15082         LDKChannelMonitor this_arg_conv;
15083         this_arg_conv.inner = (void*)(this_arg & (~1));
15084         this_arg_conv.is_owned = false;
15085         unsigned char header_arr[80];
15086         CHECK((*env)->GetArrayLength(env, header) == 80);
15087         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15088         unsigned char (*header_ref)[80] = &header_arr;
15089         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15090         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15091                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15092                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15093         }
15094         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15095         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15096                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15097                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15098         }
15099         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15100         if (logger_conv.free == LDKLogger_JCalls_free) {
15101                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15102                 LDKLogger_JCalls_cloned(&logger_conv);
15103         }
15104         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
15105 }
15106
15107 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) {
15108         LDKChannelMonitor this_arg_conv;
15109         this_arg_conv.inner = (void*)(this_arg & (~1));
15110         this_arg_conv.is_owned = false;
15111         unsigned char header_arr[80];
15112         CHECK((*env)->GetArrayLength(env, header) == 80);
15113         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15114         unsigned char (*header_ref)[80] = &header_arr;
15115         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
15116         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
15117         if (txdata_constr.datalen > 0)
15118                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15119         else
15120                 txdata_constr.data = NULL;
15121         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
15122         for (size_t y = 0; y < txdata_constr.datalen; y++) {
15123                 int64_t txdata_conv_24 = txdata_vals[y];
15124                 LDKC2Tuple_usizeTransactionZ txdata_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1);
15125                 txdata_conv_24_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_24) & ~1));
15126                 txdata_constr.data[y] = txdata_conv_24_conv;
15127         }
15128         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
15129         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15130         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15131                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15132                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15133         }
15134         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15135         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15136                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15137                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15138         }
15139         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15140         if (logger_conv.free == LDKLogger_JCalls_free) {
15141                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15142                 LDKLogger_JCalls_cloned(&logger_conv);
15143         }
15144         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);
15145         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15146         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15147         for (size_t u = 0; u < ret_var.datalen; u++) {
15148                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15149                 *ret_conv_46_ref = ret_var.data[u];
15150                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
15151         }
15152         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15153         FREE(ret_var.data);
15154         return ret_arr;
15155 }
15156
15157 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) {
15158         LDKChannelMonitor this_arg_conv;
15159         this_arg_conv.inner = (void*)(this_arg & (~1));
15160         this_arg_conv.is_owned = false;
15161         unsigned char txid_arr[32];
15162         CHECK((*env)->GetArrayLength(env, txid) == 32);
15163         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
15164         unsigned char (*txid_ref)[32] = &txid_arr;
15165         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15166         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15167                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15168                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15169         }
15170         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15171         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15172                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15173                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15174         }
15175         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15176         if (logger_conv.free == LDKLogger_JCalls_free) {
15177                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15178                 LDKLogger_JCalls_cloned(&logger_conv);
15179         }
15180         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
15181 }
15182
15183 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) {
15184         LDKChannelMonitor this_arg_conv;
15185         this_arg_conv.inner = (void*)(this_arg & (~1));
15186         this_arg_conv.is_owned = false;
15187         unsigned char header_arr[80];
15188         CHECK((*env)->GetArrayLength(env, header) == 80);
15189         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
15190         unsigned char (*header_ref)[80] = &header_arr;
15191         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
15192         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
15193                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15194                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
15195         }
15196         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
15197         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
15198                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15199                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
15200         }
15201         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
15202         if (logger_conv.free == LDKLogger_JCalls_free) {
15203                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15204                 LDKLogger_JCalls_cloned(&logger_conv);
15205         }
15206         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
15207         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15208         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15209         for (size_t u = 0; u < ret_var.datalen; u++) {
15210                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
15211                 *ret_conv_46_ref = ret_var.data[u];
15212                 ret_arr_ptr[u] = (uint64_t)ret_conv_46_ref;
15213         }
15214         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15215         FREE(ret_var.data);
15216         return ret_arr;
15217 }
15218
15219 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
15220         LDKChannelMonitor this_arg_conv;
15221         this_arg_conv.inner = (void*)(this_arg & (~1));
15222         this_arg_conv.is_owned = false;
15223         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
15224         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
15225         ;
15226         for (size_t i = 0; i < ret_var.datalen; i++) {
15227                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
15228                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
15229                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
15230         }
15231         FREE(ret_var.data);
15232         return ret_arr;
15233 }
15234
15235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
15236         LDKChannelMonitor this_arg_conv;
15237         this_arg_conv.inner = (void*)(this_arg & (~1));
15238         this_arg_conv.is_owned = false;
15239         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
15240         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15241         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15242         uint64_t ret_ref = (uint64_t)ret_var.inner;
15243         if (ret_var.is_owned) {
15244                 ret_ref |= 1;
15245         }
15246         return ret_ref;
15247 }
15248
15249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15250         if ((this_ptr & 1) != 0) return;
15251         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
15252         FREE((void*)this_ptr);
15253         Persist_free(this_ptr_conv);
15254 }
15255
15256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
15257         LDKu8slice ser_ref;
15258         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15259         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15260         LDKKeysInterface* arg_conv = (LDKKeysInterface*)(((uint64_t)arg) & ~1);
15261         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
15262         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
15263         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15264         return (uint64_t)ret_conv;
15265 }
15266
15267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15268         LDKOutPoint this_obj_conv;
15269         this_obj_conv.inner = (void*)(this_obj & (~1));
15270         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15271         OutPoint_free(this_obj_conv);
15272 }
15273
15274 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
15275         LDKOutPoint this_ptr_conv;
15276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15277         this_ptr_conv.is_owned = false;
15278         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15279         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
15280         return ret_arr;
15281 }
15282
15283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15284         LDKOutPoint this_ptr_conv;
15285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15286         this_ptr_conv.is_owned = false;
15287         LDKThirtyTwoBytes val_ref;
15288         CHECK((*env)->GetArrayLength(env, val) == 32);
15289         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15290         OutPoint_set_txid(&this_ptr_conv, val_ref);
15291 }
15292
15293 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
15294         LDKOutPoint this_ptr_conv;
15295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15296         this_ptr_conv.is_owned = false;
15297         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
15298         return ret_val;
15299 }
15300
15301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15302         LDKOutPoint this_ptr_conv;
15303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15304         this_ptr_conv.is_owned = false;
15305         OutPoint_set_index(&this_ptr_conv, val);
15306 }
15307
15308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
15309         LDKThirtyTwoBytes txid_arg_ref;
15310         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
15311         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
15312         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
15313         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15314         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15315         uint64_t ret_ref = (uint64_t)ret_var.inner;
15316         if (ret_var.is_owned) {
15317                 ret_ref |= 1;
15318         }
15319         return ret_ref;
15320 }
15321
15322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15323         LDKOutPoint orig_conv;
15324         orig_conv.inner = (void*)(orig & (~1));
15325         orig_conv.is_owned = false;
15326         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
15327         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15328         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15329         uint64_t ret_ref = (uint64_t)ret_var.inner;
15330         if (ret_var.is_owned) {
15331                 ret_ref |= 1;
15332         }
15333         return ret_ref;
15334 }
15335
15336 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
15337         LDKOutPoint a_conv;
15338         a_conv.inner = (void*)(a & (~1));
15339         a_conv.is_owned = false;
15340         LDKOutPoint b_conv;
15341         b_conv.inner = (void*)(b & (~1));
15342         b_conv.is_owned = false;
15343         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
15344         return ret_val;
15345 }
15346
15347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
15348         LDKOutPoint o_conv;
15349         o_conv.inner = (void*)(o & (~1));
15350         o_conv.is_owned = false;
15351         int64_t ret_val = OutPoint_hash(&o_conv);
15352         return ret_val;
15353 }
15354
15355 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
15356         LDKOutPoint this_arg_conv;
15357         this_arg_conv.inner = (void*)(this_arg & (~1));
15358         this_arg_conv.is_owned = false;
15359         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15360         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
15361         return ret_arr;
15362 }
15363
15364 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
15365         LDKOutPoint obj_conv;
15366         obj_conv.inner = (void*)(obj & (~1));
15367         obj_conv.is_owned = false;
15368         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
15369         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15370         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15371         CVec_u8Z_free(ret_var);
15372         return ret_arr;
15373 }
15374
15375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15376         LDKu8slice ser_ref;
15377         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15378         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15379         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
15380         *ret_conv = OutPoint_read(ser_ref);
15381         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15382         return (uint64_t)ret_conv;
15383 }
15384
15385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15386         LDKDelayedPaymentOutputDescriptor this_obj_conv;
15387         this_obj_conv.inner = (void*)(this_obj & (~1));
15388         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15389         DelayedPaymentOutputDescriptor_free(this_obj_conv);
15390 }
15391
15392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15393         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15395         this_ptr_conv.is_owned = false;
15396         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15397         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15398         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15399         uint64_t ret_ref = (uint64_t)ret_var.inner;
15400         if (ret_var.is_owned) {
15401                 ret_ref |= 1;
15402         }
15403         return ret_ref;
15404 }
15405
15406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15407         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15409         this_ptr_conv.is_owned = false;
15410         LDKOutPoint val_conv;
15411         val_conv.inner = (void*)(val & (~1));
15412         val_conv.is_owned = (val & 1) || (val == 0);
15413         val_conv = OutPoint_clone(&val_conv);
15414         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15415 }
15416
15417 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
15418         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15420         this_ptr_conv.is_owned = false;
15421         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15422         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
15423         return ret_arr;
15424 }
15425
15426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15427         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15429         this_ptr_conv.is_owned = false;
15430         LDKPublicKey val_ref;
15431         CHECK((*env)->GetArrayLength(env, val) == 33);
15432         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15433         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
15434 }
15435
15436 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
15437         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15439         this_ptr_conv.is_owned = false;
15440         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
15441         return ret_val;
15442 }
15443
15444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
15445         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15447         this_ptr_conv.is_owned = false;
15448         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
15449 }
15450
15451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15452         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15454         this_ptr_conv.is_owned = false;
15455         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15456         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15457 }
15458
15459 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
15460         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15462         this_ptr_conv.is_owned = false;
15463         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15464         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
15465         return ret_arr;
15466 }
15467
15468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15469         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15471         this_ptr_conv.is_owned = false;
15472         LDKPublicKey val_ref;
15473         CHECK((*env)->GetArrayLength(env, val) == 33);
15474         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
15475         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
15476 }
15477
15478 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15479         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15481         this_ptr_conv.is_owned = false;
15482         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15483         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15484         return ret_arr;
15485 }
15486
15487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15488         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15490         this_ptr_conv.is_owned = false;
15491         LDKThirtyTwoBytes val_ref;
15492         CHECK((*env)->GetArrayLength(env, val) == 32);
15493         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15494         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15495 }
15496
15497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15498         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15500         this_ptr_conv.is_owned = false;
15501         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15502         return ret_val;
15503 }
15504
15505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15506         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
15507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15508         this_ptr_conv.is_owned = false;
15509         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15510 }
15511
15512 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) {
15513         LDKOutPoint outpoint_arg_conv;
15514         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15515         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15516         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15517         LDKPublicKey per_commitment_point_arg_ref;
15518         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
15519         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
15520         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15521         LDKPublicKey revocation_pubkey_arg_ref;
15522         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
15523         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
15524         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15525         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15526         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15527         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);
15528         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15529         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15530         uint64_t ret_ref = (uint64_t)ret_var.inner;
15531         if (ret_var.is_owned) {
15532                 ret_ref |= 1;
15533         }
15534         return ret_ref;
15535 }
15536
15537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15538         LDKDelayedPaymentOutputDescriptor orig_conv;
15539         orig_conv.inner = (void*)(orig & (~1));
15540         orig_conv.is_owned = false;
15541         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
15542         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15543         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15544         uint64_t ret_ref = (uint64_t)ret_var.inner;
15545         if (ret_var.is_owned) {
15546                 ret_ref |= 1;
15547         }
15548         return ret_ref;
15549 }
15550
15551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15552         LDKDelayedPaymentOutputDescriptor obj_conv;
15553         obj_conv.inner = (void*)(obj & (~1));
15554         obj_conv.is_owned = false;
15555         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
15556         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15557         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15558         CVec_u8Z_free(ret_var);
15559         return ret_arr;
15560 }
15561
15562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15563         LDKu8slice ser_ref;
15564         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15565         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15566         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15567         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
15568         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15569         return (uint64_t)ret_conv;
15570 }
15571
15572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15573         LDKStaticPaymentOutputDescriptor this_obj_conv;
15574         this_obj_conv.inner = (void*)(this_obj & (~1));
15575         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15576         StaticPaymentOutputDescriptor_free(this_obj_conv);
15577 }
15578
15579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
15580         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15582         this_ptr_conv.is_owned = false;
15583         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
15584         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15585         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15586         uint64_t ret_ref = (uint64_t)ret_var.inner;
15587         if (ret_var.is_owned) {
15588                 ret_ref |= 1;
15589         }
15590         return ret_ref;
15591 }
15592
15593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15594         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15596         this_ptr_conv.is_owned = false;
15597         LDKOutPoint val_conv;
15598         val_conv.inner = (void*)(val & (~1));
15599         val_conv.is_owned = (val & 1) || (val == 0);
15600         val_conv = OutPoint_clone(&val_conv);
15601         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
15602 }
15603
15604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15605         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15607         this_ptr_conv.is_owned = false;
15608         LDKTxOut val_conv = *(LDKTxOut*)(((uint64_t)val) & ~1);
15609         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
15610 }
15611
15612 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
15613         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15615         this_ptr_conv.is_owned = false;
15616         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15617         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
15618         return ret_arr;
15619 }
15620
15621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15622         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15624         this_ptr_conv.is_owned = false;
15625         LDKThirtyTwoBytes val_ref;
15626         CHECK((*env)->GetArrayLength(env, val) == 32);
15627         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15628         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
15629 }
15630
15631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
15632         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15634         this_ptr_conv.is_owned = false;
15635         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
15636         return ret_val;
15637 }
15638
15639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
15640         LDKStaticPaymentOutputDescriptor this_ptr_conv;
15641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15642         this_ptr_conv.is_owned = false;
15643         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
15644 }
15645
15646 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) {
15647         LDKOutPoint outpoint_arg_conv;
15648         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
15649         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
15650         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
15651         LDKTxOut output_arg_conv = *(LDKTxOut*)(((uint64_t)output_arg) & ~1);
15652         LDKThirtyTwoBytes channel_keys_id_arg_ref;
15653         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
15654         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
15655         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
15656         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15657         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15658         uint64_t ret_ref = (uint64_t)ret_var.inner;
15659         if (ret_var.is_owned) {
15660                 ret_ref |= 1;
15661         }
15662         return ret_ref;
15663 }
15664
15665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15666         LDKStaticPaymentOutputDescriptor orig_conv;
15667         orig_conv.inner = (void*)(orig & (~1));
15668         orig_conv.is_owned = false;
15669         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
15670         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15671         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15672         uint64_t ret_ref = (uint64_t)ret_var.inner;
15673         if (ret_var.is_owned) {
15674                 ret_ref |= 1;
15675         }
15676         return ret_ref;
15677 }
15678
15679 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15680         LDKStaticPaymentOutputDescriptor obj_conv;
15681         obj_conv.inner = (void*)(obj & (~1));
15682         obj_conv.is_owned = false;
15683         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
15684         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15685         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15686         CVec_u8Z_free(ret_var);
15687         return ret_arr;
15688 }
15689
15690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15691         LDKu8slice ser_ref;
15692         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15693         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15694         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15695         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
15696         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15697         return (uint64_t)ret_conv;
15698 }
15699
15700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15701         if ((this_ptr & 1) != 0) return;
15702         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
15703         FREE((void*)this_ptr);
15704         SpendableOutputDescriptor_free(this_ptr_conv);
15705 }
15706
15707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15708         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
15709         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15710         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
15711         uint64_t ret_ref = (uint64_t)ret_copy;
15712         return ret_ref;
15713 }
15714
15715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
15716         LDKOutPoint outpoint_conv;
15717         outpoint_conv.inner = (void*)(outpoint & (~1));
15718         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
15719         outpoint_conv = OutPoint_clone(&outpoint_conv);
15720         LDKTxOut output_conv = *(LDKTxOut*)(((uint64_t)output) & ~1);
15721         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15722         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
15723         uint64_t ret_ref = (uint64_t)ret_copy;
15724         return ret_ref;
15725 }
15726
15727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
15728         LDKDelayedPaymentOutputDescriptor a_conv;
15729         a_conv.inner = (void*)(a & (~1));
15730         a_conv.is_owned = (a & 1) || (a == 0);
15731         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
15732         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15733         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
15734         uint64_t ret_ref = (uint64_t)ret_copy;
15735         return ret_ref;
15736 }
15737
15738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
15739         LDKStaticPaymentOutputDescriptor a_conv;
15740         a_conv.inner = (void*)(a & (~1));
15741         a_conv.is_owned = (a & 1) || (a == 0);
15742         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
15743         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
15744         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
15745         uint64_t ret_ref = (uint64_t)ret_copy;
15746         return ret_ref;
15747 }
15748
15749 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
15750         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
15751         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
15752         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
15753         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
15754         CVec_u8Z_free(ret_var);
15755         return ret_arr;
15756 }
15757
15758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
15759         LDKu8slice ser_ref;
15760         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
15761         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
15762         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15763         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
15764         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
15765         return (uint64_t)ret_conv;
15766 }
15767
15768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15769         if ((this_ptr & 1) != 0) return;
15770         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(((uint64_t)this_ptr) & ~1);
15771         FREE((void*)this_ptr);
15772         BaseSign_free(this_ptr_conv);
15773 }
15774
15775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15776         LDKSign* orig_conv = (LDKSign*)(((uint64_t)orig) & ~1);
15777         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
15778         *ret = Sign_clone(orig_conv);
15779         return (uint64_t)ret;
15780 }
15781
15782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15783         if ((this_ptr & 1) != 0) return;
15784         LDKSign this_ptr_conv = *(LDKSign*)(((uint64_t)this_ptr) & ~1);
15785         FREE((void*)this_ptr);
15786         Sign_free(this_ptr_conv);
15787 }
15788
15789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
15790         if ((this_ptr & 1) != 0) return;
15791         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
15792         FREE((void*)this_ptr);
15793         KeysInterface_free(this_ptr_conv);
15794 }
15795
15796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
15797         LDKInMemorySigner this_obj_conv;
15798         this_obj_conv.inner = (void*)(this_obj & (~1));
15799         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
15800         InMemorySigner_free(this_obj_conv);
15801 }
15802
15803 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15804         LDKInMemorySigner this_ptr_conv;
15805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15806         this_ptr_conv.is_owned = false;
15807         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15808         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
15809         return ret_arr;
15810 }
15811
15812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15813         LDKInMemorySigner this_ptr_conv;
15814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15815         this_ptr_conv.is_owned = false;
15816         LDKSecretKey val_ref;
15817         CHECK((*env)->GetArrayLength(env, val) == 32);
15818         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15819         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
15820 }
15821
15822 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15823         LDKInMemorySigner this_ptr_conv;
15824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15825         this_ptr_conv.is_owned = false;
15826         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15827         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
15828         return ret_arr;
15829 }
15830
15831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15832         LDKInMemorySigner this_ptr_conv;
15833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15834         this_ptr_conv.is_owned = false;
15835         LDKSecretKey val_ref;
15836         CHECK((*env)->GetArrayLength(env, val) == 32);
15837         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15838         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
15839 }
15840
15841 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15842         LDKInMemorySigner this_ptr_conv;
15843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15844         this_ptr_conv.is_owned = false;
15845         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15846         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
15847         return ret_arr;
15848 }
15849
15850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15851         LDKInMemorySigner this_ptr_conv;
15852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15853         this_ptr_conv.is_owned = false;
15854         LDKSecretKey val_ref;
15855         CHECK((*env)->GetArrayLength(env, val) == 32);
15856         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15857         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
15858 }
15859
15860 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15861         LDKInMemorySigner this_ptr_conv;
15862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15863         this_ptr_conv.is_owned = false;
15864         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15865         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
15866         return ret_arr;
15867 }
15868
15869 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) {
15870         LDKInMemorySigner this_ptr_conv;
15871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15872         this_ptr_conv.is_owned = false;
15873         LDKSecretKey val_ref;
15874         CHECK((*env)->GetArrayLength(env, val) == 32);
15875         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15876         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
15877 }
15878
15879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
15880         LDKInMemorySigner this_ptr_conv;
15881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15882         this_ptr_conv.is_owned = false;
15883         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15884         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
15885         return ret_arr;
15886 }
15887
15888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15889         LDKInMemorySigner this_ptr_conv;
15890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15891         this_ptr_conv.is_owned = false;
15892         LDKSecretKey val_ref;
15893         CHECK((*env)->GetArrayLength(env, val) == 32);
15894         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
15895         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
15896 }
15897
15898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
15899         LDKInMemorySigner this_ptr_conv;
15900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15901         this_ptr_conv.is_owned = false;
15902         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
15903         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
15904         return ret_arr;
15905 }
15906
15907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
15908         LDKInMemorySigner this_ptr_conv;
15909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15910         this_ptr_conv.is_owned = false;
15911         LDKThirtyTwoBytes val_ref;
15912         CHECK((*env)->GetArrayLength(env, val) == 32);
15913         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
15914         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
15915 }
15916
15917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15918         LDKInMemorySigner orig_conv;
15919         orig_conv.inner = (void*)(orig & (~1));
15920         orig_conv.is_owned = false;
15921         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
15922         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15923         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15924         uint64_t ret_ref = (uint64_t)ret_var.inner;
15925         if (ret_var.is_owned) {
15926                 ret_ref |= 1;
15927         }
15928         return ret_ref;
15929 }
15930
15931 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) {
15932         LDKSecretKey funding_key_ref;
15933         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
15934         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
15935         LDKSecretKey revocation_base_key_ref;
15936         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
15937         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
15938         LDKSecretKey payment_key_ref;
15939         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
15940         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
15941         LDKSecretKey delayed_payment_base_key_ref;
15942         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
15943         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
15944         LDKSecretKey htlc_base_key_ref;
15945         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
15946         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
15947         LDKThirtyTwoBytes commitment_seed_ref;
15948         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
15949         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
15950         LDKThirtyTwoBytes channel_keys_id_ref;
15951         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
15952         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
15953         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);
15954         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15955         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15956         uint64_t ret_ref = (uint64_t)ret_var.inner;
15957         if (ret_var.is_owned) {
15958                 ret_ref |= 1;
15959         }
15960         return ret_ref;
15961 }
15962
15963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
15964         LDKInMemorySigner this_arg_conv;
15965         this_arg_conv.inner = (void*)(this_arg & (~1));
15966         this_arg_conv.is_owned = false;
15967         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
15968         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15969         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15970         uint64_t ret_ref = (uint64_t)ret_var.inner;
15971         if (ret_var.is_owned) {
15972                 ret_ref |= 1;
15973         }
15974         return ret_ref;
15975 }
15976
15977 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
15978         LDKInMemorySigner this_arg_conv;
15979         this_arg_conv.inner = (void*)(this_arg & (~1));
15980         this_arg_conv.is_owned = false;
15981         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
15982         return ret_val;
15983 }
15984
15985 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
15986         LDKInMemorySigner this_arg_conv;
15987         this_arg_conv.inner = (void*)(this_arg & (~1));
15988         this_arg_conv.is_owned = false;
15989         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
15990         return ret_val;
15991 }
15992
15993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
15994         LDKInMemorySigner this_arg_conv;
15995         this_arg_conv.inner = (void*)(this_arg & (~1));
15996         this_arg_conv.is_owned = false;
15997         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
15998         return ret_val;
15999 }
16000
16001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
16002         LDKInMemorySigner this_arg_conv;
16003         this_arg_conv.inner = (void*)(this_arg & (~1));
16004         this_arg_conv.is_owned = false;
16005         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
16006         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16007         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16008         uint64_t ret_ref = (uint64_t)ret_var.inner;
16009         if (ret_var.is_owned) {
16010                 ret_ref |= 1;
16011         }
16012         return ret_ref;
16013 }
16014
16015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
16016         LDKInMemorySigner this_arg_conv;
16017         this_arg_conv.inner = (void*)(this_arg & (~1));
16018         this_arg_conv.is_owned = false;
16019         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
16020         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16021         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16022         uint64_t ret_ref = (uint64_t)ret_var.inner;
16023         if (ret_var.is_owned) {
16024                 ret_ref |= 1;
16025         }
16026         return ret_ref;
16027 }
16028
16029 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) {
16030         LDKInMemorySigner this_arg_conv;
16031         this_arg_conv.inner = (void*)(this_arg & (~1));
16032         this_arg_conv.is_owned = false;
16033         LDKTransaction spend_tx_ref;
16034         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
16035         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
16036         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
16037         spend_tx_ref.data_is_owned = true;
16038         LDKStaticPaymentOutputDescriptor descriptor_conv;
16039         descriptor_conv.inner = (void*)(descriptor & (~1));
16040         descriptor_conv.is_owned = false;
16041         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16042         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
16043         return (uint64_t)ret_conv;
16044 }
16045
16046 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) {
16047         LDKInMemorySigner this_arg_conv;
16048         this_arg_conv.inner = (void*)(this_arg & (~1));
16049         this_arg_conv.is_owned = false;
16050         LDKTransaction spend_tx_ref;
16051         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
16052         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
16053         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
16054         spend_tx_ref.data_is_owned = true;
16055         LDKDelayedPaymentOutputDescriptor descriptor_conv;
16056         descriptor_conv.inner = (void*)(descriptor & (~1));
16057         descriptor_conv.is_owned = false;
16058         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
16059         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
16060         return (uint64_t)ret_conv;
16061 }
16062
16063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
16064         LDKInMemorySigner this_arg_conv;
16065         this_arg_conv.inner = (void*)(this_arg & (~1));
16066         this_arg_conv.is_owned = false;
16067         LDKBaseSign* ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
16068         *ret = InMemorySigner_as_BaseSign(&this_arg_conv);
16069         return (uint64_t)ret;
16070 }
16071
16072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
16073         LDKInMemorySigner this_arg_conv;
16074         this_arg_conv.inner = (void*)(this_arg & (~1));
16075         this_arg_conv.is_owned = false;
16076         LDKSign* ret = MALLOC(sizeof(LDKSign), "LDKSign");
16077         *ret = InMemorySigner_as_Sign(&this_arg_conv);
16078         return (uint64_t)ret;
16079 }
16080
16081 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
16082         LDKInMemorySigner obj_conv;
16083         obj_conv.inner = (void*)(obj & (~1));
16084         obj_conv.is_owned = false;
16085         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
16086         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
16087         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
16088         CVec_u8Z_free(ret_var);
16089         return ret_arr;
16090 }
16091
16092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
16093         LDKu8slice ser_ref;
16094         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
16095         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
16096         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
16097         *ret_conv = InMemorySigner_read(ser_ref);
16098         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
16099         return (uint64_t)ret_conv;
16100 }
16101
16102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16103         LDKKeysManager this_obj_conv;
16104         this_obj_conv.inner = (void*)(this_obj & (~1));
16105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16106         KeysManager_free(this_obj_conv);
16107 }
16108
16109 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) {
16110         unsigned char seed_arr[32];
16111         CHECK((*env)->GetArrayLength(env, seed) == 32);
16112         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
16113         unsigned char (*seed_ref)[32] = &seed_arr;
16114         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
16115         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16116         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16117         uint64_t ret_ref = (uint64_t)ret_var.inner;
16118         if (ret_var.is_owned) {
16119                 ret_ref |= 1;
16120         }
16121         return ret_ref;
16122 }
16123
16124 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) {
16125         LDKKeysManager this_arg_conv;
16126         this_arg_conv.inner = (void*)(this_arg & (~1));
16127         this_arg_conv.is_owned = false;
16128         unsigned char params_arr[32];
16129         CHECK((*env)->GetArrayLength(env, params) == 32);
16130         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
16131         unsigned char (*params_ref)[32] = &params_arr;
16132         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
16133         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16134         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16135         uint64_t ret_ref = (uint64_t)ret_var.inner;
16136         if (ret_var.is_owned) {
16137                 ret_ref |= 1;
16138         }
16139         return ret_ref;
16140 }
16141
16142 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) {
16143         LDKKeysManager this_arg_conv;
16144         this_arg_conv.inner = (void*)(this_arg & (~1));
16145         this_arg_conv.is_owned = false;
16146         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
16147         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
16148         if (descriptors_constr.datalen > 0)
16149                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16150         else
16151                 descriptors_constr.data = NULL;
16152         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
16153         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
16154                 int64_t descriptors_conv_27 = descriptors_vals[b];
16155                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1);
16156                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
16157                 descriptors_constr.data[b] = descriptors_conv_27_conv;
16158         }
16159         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
16160         LDKCVec_TxOutZ outputs_constr;
16161         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
16162         if (outputs_constr.datalen > 0)
16163                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
16164         else
16165                 outputs_constr.data = NULL;
16166         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
16167         for (size_t h = 0; h < outputs_constr.datalen; h++) {
16168                 int64_t outputs_conv_7 = outputs_vals[h];
16169                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1);
16170                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
16171                 outputs_constr.data[h] = outputs_conv_7_conv;
16172         }
16173         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
16174         LDKCVec_u8Z change_destination_script_ref;
16175         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
16176         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
16177         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
16178         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
16179         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
16180         return (uint64_t)ret_conv;
16181 }
16182
16183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
16184         LDKKeysManager this_arg_conv;
16185         this_arg_conv.inner = (void*)(this_arg & (~1));
16186         this_arg_conv.is_owned = false;
16187         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
16188         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
16189         return (uint64_t)ret;
16190 }
16191
16192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16193         LDKChannelManager this_obj_conv;
16194         this_obj_conv.inner = (void*)(this_obj & (~1));
16195         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16196         ChannelManager_free(this_obj_conv);
16197 }
16198
16199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16200         LDKChainParameters this_obj_conv;
16201         this_obj_conv.inner = (void*)(this_obj & (~1));
16202         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16203         ChainParameters_free(this_obj_conv);
16204 }
16205
16206 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
16207         LDKChainParameters this_ptr_conv;
16208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16209         this_ptr_conv.is_owned = false;
16210         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
16211         return ret_conv;
16212 }
16213
16214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
16215         LDKChainParameters this_ptr_conv;
16216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16217         this_ptr_conv.is_owned = false;
16218         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
16219         ChainParameters_set_network(&this_ptr_conv, val_conv);
16220 }
16221
16222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
16223         LDKChainParameters this_ptr_conv;
16224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16225         this_ptr_conv.is_owned = false;
16226         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
16227         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16228         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16229         uint64_t ret_ref = (uint64_t)ret_var.inner;
16230         if (ret_var.is_owned) {
16231                 ret_ref |= 1;
16232         }
16233         return ret_ref;
16234 }
16235
16236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16237         LDKChainParameters this_ptr_conv;
16238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16239         this_ptr_conv.is_owned = false;
16240         LDKBestBlock val_conv;
16241         val_conv.inner = (void*)(val & (~1));
16242         val_conv.is_owned = (val & 1) || (val == 0);
16243         val_conv = BestBlock_clone(&val_conv);
16244         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
16245 }
16246
16247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
16248         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
16249         LDKBestBlock best_block_arg_conv;
16250         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
16251         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
16252         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
16253         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
16254         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16255         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16256         uint64_t ret_ref = (uint64_t)ret_var.inner;
16257         if (ret_var.is_owned) {
16258                 ret_ref |= 1;
16259         }
16260         return ret_ref;
16261 }
16262
16263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16264         LDKChainParameters orig_conv;
16265         orig_conv.inner = (void*)(orig & (~1));
16266         orig_conv.is_owned = false;
16267         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
16268         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16269         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16270         uint64_t ret_ref = (uint64_t)ret_var.inner;
16271         if (ret_var.is_owned) {
16272                 ret_ref |= 1;
16273         }
16274         return ret_ref;
16275 }
16276
16277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16278         LDKChannelCounterparty this_obj_conv;
16279         this_obj_conv.inner = (void*)(this_obj & (~1));
16280         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16281         ChannelCounterparty_free(this_obj_conv);
16282 }
16283
16284 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16285         LDKChannelCounterparty this_ptr_conv;
16286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16287         this_ptr_conv.is_owned = false;
16288         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
16289         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
16290         return ret_arr;
16291 }
16292
16293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16294         LDKChannelCounterparty this_ptr_conv;
16295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16296         this_ptr_conv.is_owned = false;
16297         LDKPublicKey val_ref;
16298         CHECK((*env)->GetArrayLength(env, val) == 33);
16299         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
16300         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
16301 }
16302
16303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
16304         LDKChannelCounterparty this_ptr_conv;
16305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16306         this_ptr_conv.is_owned = false;
16307         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
16308         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16309         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16310         uint64_t ret_ref = (uint64_t)ret_var.inner;
16311         if (ret_var.is_owned) {
16312                 ret_ref |= 1;
16313         }
16314         return ret_ref;
16315 }
16316
16317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16318         LDKChannelCounterparty this_ptr_conv;
16319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16320         this_ptr_conv.is_owned = false;
16321         LDKInitFeatures val_conv;
16322         val_conv.inner = (void*)(val & (~1));
16323         val_conv.is_owned = (val & 1) || (val == 0);
16324         val_conv = InitFeatures_clone(&val_conv);
16325         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
16326 }
16327
16328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
16329         LDKChannelCounterparty this_ptr_conv;
16330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16331         this_ptr_conv.is_owned = false;
16332         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
16333         return ret_val;
16334 }
16335
16336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16337         LDKChannelCounterparty this_ptr_conv;
16338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16339         this_ptr_conv.is_owned = false;
16340         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
16341 }
16342
16343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16344         LDKChannelCounterparty orig_conv;
16345         orig_conv.inner = (void*)(orig & (~1));
16346         orig_conv.is_owned = false;
16347         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
16348         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16349         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16350         uint64_t ret_ref = (uint64_t)ret_var.inner;
16351         if (ret_var.is_owned) {
16352                 ret_ref |= 1;
16353         }
16354         return ret_ref;
16355 }
16356
16357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
16358         LDKChannelDetails this_obj_conv;
16359         this_obj_conv.inner = (void*)(this_obj & (~1));
16360         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
16361         ChannelDetails_free(this_obj_conv);
16362 }
16363
16364 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16365         LDKChannelDetails this_ptr_conv;
16366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16367         this_ptr_conv.is_owned = false;
16368         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
16369         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
16370         return ret_arr;
16371 }
16372
16373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
16374         LDKChannelDetails this_ptr_conv;
16375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16376         this_ptr_conv.is_owned = false;
16377         LDKThirtyTwoBytes val_ref;
16378         CHECK((*env)->GetArrayLength(env, val) == 32);
16379         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
16380         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
16381 }
16382
16383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
16384         LDKChannelDetails this_ptr_conv;
16385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16386         this_ptr_conv.is_owned = false;
16387         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
16388         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16389         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16390         uint64_t ret_ref = (uint64_t)ret_var.inner;
16391         if (ret_var.is_owned) {
16392                 ret_ref |= 1;
16393         }
16394         return ret_ref;
16395 }
16396
16397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16398         LDKChannelDetails this_ptr_conv;
16399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16400         this_ptr_conv.is_owned = false;
16401         LDKChannelCounterparty val_conv;
16402         val_conv.inner = (void*)(val & (~1));
16403         val_conv.is_owned = (val & 1) || (val == 0);
16404         val_conv = ChannelCounterparty_clone(&val_conv);
16405         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
16406 }
16407
16408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
16409         LDKChannelDetails this_ptr_conv;
16410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16411         this_ptr_conv.is_owned = false;
16412         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
16413         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16414         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16415         uint64_t ret_ref = (uint64_t)ret_var.inner;
16416         if (ret_var.is_owned) {
16417                 ret_ref |= 1;
16418         }
16419         return ret_ref;
16420 }
16421
16422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16423         LDKChannelDetails this_ptr_conv;
16424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16425         this_ptr_conv.is_owned = false;
16426         LDKOutPoint val_conv;
16427         val_conv.inner = (void*)(val & (~1));
16428         val_conv.is_owned = (val & 1) || (val == 0);
16429         val_conv = OutPoint_clone(&val_conv);
16430         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
16431 }
16432
16433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16434         LDKChannelDetails this_ptr_conv;
16435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16436         this_ptr_conv.is_owned = false;
16437         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16438         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
16439         uint64_t ret_ref = (uint64_t)ret_copy;
16440         return ret_ref;
16441 }
16442
16443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16444         LDKChannelDetails this_ptr_conv;
16445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16446         this_ptr_conv.is_owned = false;
16447         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
16448         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
16449 }
16450
16451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
16452         LDKChannelDetails this_ptr_conv;
16453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16454         this_ptr_conv.is_owned = false;
16455         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
16456         return ret_val;
16457 }
16458
16459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16460         LDKChannelDetails this_ptr_conv;
16461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16462         this_ptr_conv.is_owned = false;
16463         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
16464 }
16465
16466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
16467         LDKChannelDetails this_ptr_conv;
16468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16469         this_ptr_conv.is_owned = false;
16470         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16471         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
16472         uint64_t ret_ref = (uint64_t)ret_copy;
16473         return ret_ref;
16474 }
16475
16476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16477         LDKChannelDetails this_ptr_conv;
16478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16479         this_ptr_conv.is_owned = false;
16480         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
16481         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
16482 }
16483
16484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
16485         LDKChannelDetails this_ptr_conv;
16486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16487         this_ptr_conv.is_owned = false;
16488         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
16489         return ret_val;
16490 }
16491
16492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16493         LDKChannelDetails this_ptr_conv;
16494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16495         this_ptr_conv.is_owned = false;
16496         ChannelDetails_set_user_id(&this_ptr_conv, val);
16497 }
16498
16499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16500         LDKChannelDetails this_ptr_conv;
16501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16502         this_ptr_conv.is_owned = false;
16503         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
16504         return ret_val;
16505 }
16506
16507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16508         LDKChannelDetails this_ptr_conv;
16509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16510         this_ptr_conv.is_owned = false;
16511         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
16512 }
16513
16514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
16515         LDKChannelDetails this_ptr_conv;
16516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16517         this_ptr_conv.is_owned = false;
16518         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
16519         return ret_val;
16520 }
16521
16522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16523         LDKChannelDetails this_ptr_conv;
16524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16525         this_ptr_conv.is_owned = false;
16526         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
16527 }
16528
16529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
16530         LDKChannelDetails this_ptr_conv;
16531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16532         this_ptr_conv.is_owned = false;
16533         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16534         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
16535         uint64_t ret_ref = (uint64_t)ret_copy;
16536         return ret_ref;
16537 }
16538
16539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
16540         LDKChannelDetails this_ptr_conv;
16541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16542         this_ptr_conv.is_owned = false;
16543         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
16544         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
16545 }
16546
16547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
16548         LDKChannelDetails this_ptr_conv;
16549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16550         this_ptr_conv.is_owned = false;
16551         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
16552         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
16553         uint64_t ret_ref = (uint64_t)ret_copy;
16554         return ret_ref;
16555 }
16556
16557 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) {
16558         LDKChannelDetails this_ptr_conv;
16559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16560         this_ptr_conv.is_owned = false;
16561         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(((uint64_t)val) & ~1);
16562         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
16563 }
16564
16565 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
16566         LDKChannelDetails this_ptr_conv;
16567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16568         this_ptr_conv.is_owned = false;
16569         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
16570         return ret_val;
16571 }
16572
16573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16574         LDKChannelDetails this_ptr_conv;
16575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16576         this_ptr_conv.is_owned = false;
16577         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
16578 }
16579
16580 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
16581         LDKChannelDetails this_ptr_conv;
16582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16583         this_ptr_conv.is_owned = false;
16584         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
16585         return ret_val;
16586 }
16587
16588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16589         LDKChannelDetails this_ptr_conv;
16590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16591         this_ptr_conv.is_owned = false;
16592         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
16593 }
16594
16595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
16596         LDKChannelDetails this_ptr_conv;
16597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16598         this_ptr_conv.is_owned = false;
16599         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
16600         return ret_val;
16601 }
16602
16603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16604         LDKChannelDetails this_ptr_conv;
16605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16606         this_ptr_conv.is_owned = false;
16607         ChannelDetails_set_is_usable(&this_ptr_conv, val);
16608 }
16609
16610 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
16611         LDKChannelDetails this_ptr_conv;
16612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16613         this_ptr_conv.is_owned = false;
16614         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
16615         return ret_val;
16616 }
16617
16618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
16619         LDKChannelDetails this_ptr_conv;
16620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
16621         this_ptr_conv.is_owned = false;
16622         ChannelDetails_set_is_public(&this_ptr_conv, val);
16623 }
16624
16625 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) {
16626         LDKThirtyTwoBytes channel_id_arg_ref;
16627         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
16628         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
16629         LDKChannelCounterparty counterparty_arg_conv;
16630         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
16631         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
16632         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
16633         LDKOutPoint funding_txo_arg_conv;
16634         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
16635         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
16636         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
16637         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1);
16638         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
16639         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1);
16640         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1);
16641         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);
16642         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16643         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16644         uint64_t ret_ref = (uint64_t)ret_var.inner;
16645         if (ret_var.is_owned) {
16646                 ret_ref |= 1;
16647         }
16648         return ret_ref;
16649 }
16650
16651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16652         LDKChannelDetails orig_conv;
16653         orig_conv.inner = (void*)(orig & (~1));
16654         orig_conv.is_owned = false;
16655         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
16656         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16657         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16658         uint64_t ret_ref = (uint64_t)ret_var.inner;
16659         if (ret_var.is_owned) {
16660                 ret_ref |= 1;
16661         }
16662         return ret_ref;
16663 }
16664
16665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
16666         if ((this_ptr & 1) != 0) return;
16667         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(((uint64_t)this_ptr) & ~1);
16668         FREE((void*)this_ptr);
16669         PaymentSendFailure_free(this_ptr_conv);
16670 }
16671
16672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16673         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
16674         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16675         *ret_copy = PaymentSendFailure_clone(orig_conv);
16676         uint64_t ret_ref = (uint64_t)ret_copy;
16677         return ret_ref;
16678 }
16679
16680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
16681         LDKAPIError a_conv = *(LDKAPIError*)(((uint64_t)a) & ~1);
16682         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16683         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
16684         uint64_t ret_ref = (uint64_t)ret_copy;
16685         return ret_ref;
16686 }
16687
16688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
16689         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
16690         a_constr.datalen = (*env)->GetArrayLength(env, a);
16691         if (a_constr.datalen > 0)
16692                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
16693         else
16694                 a_constr.data = NULL;
16695         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
16696         for (size_t w = 0; w < a_constr.datalen; w++) {
16697                 int64_t a_conv_22 = a_vals[w];
16698                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
16699                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
16700                 a_constr.data[w] = a_conv_22_conv;
16701         }
16702         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
16703         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16704         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
16705         uint64_t ret_ref = (uint64_t)ret_copy;
16706         return ret_ref;
16707 }
16708
16709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
16710         LDKCVec_APIErrorZ a_constr;
16711         a_constr.datalen = (*env)->GetArrayLength(env, a);
16712         if (a_constr.datalen > 0)
16713                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
16714         else
16715                 a_constr.data = NULL;
16716         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
16717         for (size_t k = 0; k < a_constr.datalen; k++) {
16718                 int64_t a_conv_10 = a_vals[k];
16719                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(((uint64_t)a_conv_10) & ~1);
16720                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
16721                 a_constr.data[k] = a_conv_10_conv;
16722         }
16723         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
16724         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16725         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
16726         uint64_t ret_ref = (uint64_t)ret_copy;
16727         return ret_ref;
16728 }
16729
16730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray a) {
16731         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
16732         a_constr.datalen = (*env)->GetArrayLength(env, a);
16733         if (a_constr.datalen > 0)
16734                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
16735         else
16736                 a_constr.data = NULL;
16737         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
16738         for (size_t w = 0; w < a_constr.datalen; w++) {
16739                 int64_t a_conv_22 = a_vals[w];
16740                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1);
16741                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
16742                 a_constr.data[w] = a_conv_22_conv;
16743         }
16744         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
16745         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
16746         *ret_copy = PaymentSendFailure_partial_failure(a_constr);
16747         uint64_t ret_ref = (uint64_t)ret_copy;
16748         return ret_ref;
16749 }
16750
16751 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) {
16752         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
16753         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
16754                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16755                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
16756         }
16757         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
16758         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
16759                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16760                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
16761         }
16762         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
16763         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
16764                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16765                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
16766         }
16767         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
16768         if (logger_conv.free == LDKLogger_JCalls_free) {
16769                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16770                 LDKLogger_JCalls_cloned(&logger_conv);
16771         }
16772         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
16773         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
16774                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16775                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
16776         }
16777         LDKUserConfig config_conv;
16778         config_conv.inner = (void*)(config & (~1));
16779         config_conv.is_owned = (config & 1) || (config == 0);
16780         config_conv = UserConfig_clone(&config_conv);
16781         LDKChainParameters params_conv;
16782         params_conv.inner = (void*)(params & (~1));
16783         params_conv.is_owned = (params & 1) || (params == 0);
16784         params_conv = ChainParameters_clone(&params_conv);
16785         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
16786         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16787         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16788         uint64_t ret_ref = (uint64_t)ret_var.inner;
16789         if (ret_var.is_owned) {
16790                 ret_ref |= 1;
16791         }
16792         return ret_ref;
16793 }
16794
16795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
16796         LDKChannelManager this_arg_conv;
16797         this_arg_conv.inner = (void*)(this_arg & (~1));
16798         this_arg_conv.is_owned = false;
16799         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
16800         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16801         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16802         uint64_t ret_ref = (uint64_t)ret_var.inner;
16803         if (ret_var.is_owned) {
16804                 ret_ref |= 1;
16805         }
16806         return ret_ref;
16807 }
16808
16809 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) {
16810         LDKChannelManager this_arg_conv;
16811         this_arg_conv.inner = (void*)(this_arg & (~1));
16812         this_arg_conv.is_owned = false;
16813         LDKPublicKey their_network_key_ref;
16814         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
16815         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
16816         LDKUserConfig override_config_conv;
16817         override_config_conv.inner = (void*)(override_config & (~1));
16818         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
16819         override_config_conv = UserConfig_clone(&override_config_conv);
16820         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16821         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
16822         return (uint64_t)ret_conv;
16823 }
16824
16825 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16826         LDKChannelManager this_arg_conv;
16827         this_arg_conv.inner = (void*)(this_arg & (~1));
16828         this_arg_conv.is_owned = false;
16829         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
16830         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16831         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16832         for (size_t q = 0; q < ret_var.datalen; q++) {
16833                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16834                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16835                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16836                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16837                 if (ret_conv_16_var.is_owned) {
16838                         ret_conv_16_ref |= 1;
16839                 }
16840                 ret_arr_ptr[q] = ret_conv_16_ref;
16841         }
16842         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16843         FREE(ret_var.data);
16844         return ret_arr;
16845 }
16846
16847 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16848         LDKChannelManager this_arg_conv;
16849         this_arg_conv.inner = (void*)(this_arg & (~1));
16850         this_arg_conv.is_owned = false;
16851         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
16852         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
16853         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
16854         for (size_t q = 0; q < ret_var.datalen; q++) {
16855                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
16856                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
16857                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
16858                 uint64_t ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
16859                 if (ret_conv_16_var.is_owned) {
16860                         ret_conv_16_ref |= 1;
16861                 }
16862                 ret_arr_ptr[q] = ret_conv_16_ref;
16863         }
16864         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
16865         FREE(ret_var.data);
16866         return ret_arr;
16867 }
16868
16869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
16870         LDKChannelManager this_arg_conv;
16871         this_arg_conv.inner = (void*)(this_arg & (~1));
16872         this_arg_conv.is_owned = false;
16873         unsigned char channel_id_arr[32];
16874         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16875         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
16876         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16877         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16878         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
16879         return (uint64_t)ret_conv;
16880 }
16881
16882 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) {
16883         LDKChannelManager this_arg_conv;
16884         this_arg_conv.inner = (void*)(this_arg & (~1));
16885         this_arg_conv.is_owned = false;
16886         unsigned char channel_id_arr[32];
16887         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
16888         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
16889         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
16890         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16891         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
16892         return (uint64_t)ret_conv;
16893 }
16894
16895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
16896         LDKChannelManager this_arg_conv;
16897         this_arg_conv.inner = (void*)(this_arg & (~1));
16898         this_arg_conv.is_owned = false;
16899         ChannelManager_force_close_all_channels(&this_arg_conv);
16900 }
16901
16902 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) {
16903         LDKChannelManager this_arg_conv;
16904         this_arg_conv.inner = (void*)(this_arg & (~1));
16905         this_arg_conv.is_owned = false;
16906         LDKRoute route_conv;
16907         route_conv.inner = (void*)(route & (~1));
16908         route_conv.is_owned = false;
16909         LDKThirtyTwoBytes payment_hash_ref;
16910         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16911         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
16912         LDKThirtyTwoBytes payment_secret_ref;
16913         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
16914         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
16915         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16916         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
16917         return (uint64_t)ret_conv;
16918 }
16919
16920 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) {
16921         LDKChannelManager this_arg_conv;
16922         this_arg_conv.inner = (void*)(this_arg & (~1));
16923         this_arg_conv.is_owned = false;
16924         unsigned char temporary_channel_id_arr[32];
16925         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
16926         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
16927         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
16928         LDKTransaction funding_transaction_ref;
16929         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
16930         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
16931         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
16932         funding_transaction_ref.data_is_owned = true;
16933         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16934         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
16935         return (uint64_t)ret_conv;
16936 }
16937
16938 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) {
16939         LDKChannelManager this_arg_conv;
16940         this_arg_conv.inner = (void*)(this_arg & (~1));
16941         this_arg_conv.is_owned = false;
16942         LDKThreeBytes rgb_ref;
16943         CHECK((*env)->GetArrayLength(env, rgb) == 3);
16944         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
16945         LDKThirtyTwoBytes alias_ref;
16946         CHECK((*env)->GetArrayLength(env, alias) == 32);
16947         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
16948         LDKCVec_NetAddressZ addresses_constr;
16949         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
16950         if (addresses_constr.datalen > 0)
16951                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16952         else
16953                 addresses_constr.data = NULL;
16954         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
16955         for (size_t m = 0; m < addresses_constr.datalen; m++) {
16956                 int64_t addresses_conv_12 = addresses_vals[m];
16957                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_conv_12) & ~1);
16958                 addresses_constr.data[m] = addresses_conv_12_conv;
16959         }
16960         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
16961         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
16962 }
16963
16964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
16965         LDKChannelManager this_arg_conv;
16966         this_arg_conv.inner = (void*)(this_arg & (~1));
16967         this_arg_conv.is_owned = false;
16968         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
16969 }
16970
16971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
16972         LDKChannelManager this_arg_conv;
16973         this_arg_conv.inner = (void*)(this_arg & (~1));
16974         this_arg_conv.is_owned = false;
16975         ChannelManager_timer_tick_occurred(&this_arg_conv);
16976 }
16977
16978 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
16979         LDKChannelManager this_arg_conv;
16980         this_arg_conv.inner = (void*)(this_arg & (~1));
16981         this_arg_conv.is_owned = false;
16982         unsigned char payment_hash_arr[32];
16983         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
16984         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
16985         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
16986         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
16987         return ret_val;
16988 }
16989
16990 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
16991         LDKChannelManager this_arg_conv;
16992         this_arg_conv.inner = (void*)(this_arg & (~1));
16993         this_arg_conv.is_owned = false;
16994         LDKThirtyTwoBytes payment_preimage_ref;
16995         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
16996         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
16997         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
16998         return ret_val;
16999 }
17000
17001 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
17002         LDKChannelManager this_arg_conv;
17003         this_arg_conv.inner = (void*)(this_arg & (~1));
17004         this_arg_conv.is_owned = false;
17005         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17006         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
17007         return ret_arr;
17008 }
17009
17010 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) {
17011         LDKChannelManager this_arg_conv;
17012         this_arg_conv.inner = (void*)(this_arg & (~1));
17013         this_arg_conv.is_owned = false;
17014         LDKOutPoint funding_txo_conv;
17015         funding_txo_conv.inner = (void*)(funding_txo & (~1));
17016         funding_txo_conv.is_owned = false;
17017         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
17018 }
17019
17020 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) {
17021         LDKChannelManager this_arg_conv;
17022         this_arg_conv.inner = (void*)(this_arg & (~1));
17023         this_arg_conv.is_owned = false;
17024         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
17025         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17026         *ret_ref = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
17027         return (uint64_t)ret_ref;
17028 }
17029
17030 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) {
17031         LDKChannelManager this_arg_conv;
17032         this_arg_conv.inner = (void*)(this_arg & (~1));
17033         this_arg_conv.is_owned = false;
17034         LDKThirtyTwoBytes payment_hash_ref;
17035         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
17036         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
17037         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1);
17038         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
17039         *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);
17040         return (uint64_t)ret_conv;
17041 }
17042
17043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17044         LDKChannelManager this_arg_conv;
17045         this_arg_conv.inner = (void*)(this_arg & (~1));
17046         this_arg_conv.is_owned = false;
17047         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
17048         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
17049         return (uint64_t)ret;
17050 }
17051
17052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
17053         LDKChannelManager this_arg_conv;
17054         this_arg_conv.inner = (void*)(this_arg & (~1));
17055         this_arg_conv.is_owned = false;
17056         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
17057         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
17058         return (uint64_t)ret;
17059 }
17060
17061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
17062         LDKChannelManager this_arg_conv;
17063         this_arg_conv.inner = (void*)(this_arg & (~1));
17064         this_arg_conv.is_owned = false;
17065         LDKListen* ret = MALLOC(sizeof(LDKListen), "LDKListen");
17066         *ret = ChannelManager_as_Listen(&this_arg_conv);
17067         return (uint64_t)ret;
17068 }
17069
17070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
17071         LDKChannelManager this_arg_conv;
17072         this_arg_conv.inner = (void*)(this_arg & (~1));
17073         this_arg_conv.is_owned = false;
17074         LDKConfirm* ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
17075         *ret = ChannelManager_as_Confirm(&this_arg_conv);
17076         return (uint64_t)ret;
17077 }
17078
17079 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) {
17080         LDKChannelManager this_arg_conv;
17081         this_arg_conv.inner = (void*)(this_arg & (~1));
17082         this_arg_conv.is_owned = false;
17083         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
17084         return ret_val;
17085 }
17086
17087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
17088         LDKChannelManager this_arg_conv;
17089         this_arg_conv.inner = (void*)(this_arg & (~1));
17090         this_arg_conv.is_owned = false;
17091         ChannelManager_await_persistable_update(&this_arg_conv);
17092 }
17093
17094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
17095         LDKChannelManager this_arg_conv;
17096         this_arg_conv.inner = (void*)(this_arg & (~1));
17097         this_arg_conv.is_owned = false;
17098         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
17099         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17100         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17101         uint64_t ret_ref = (uint64_t)ret_var.inner;
17102         if (ret_var.is_owned) {
17103                 ret_ref |= 1;
17104         }
17105         return ret_ref;
17106 }
17107
17108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
17109         LDKChannelManager this_arg_conv;
17110         this_arg_conv.inner = (void*)(this_arg & (~1));
17111         this_arg_conv.is_owned = false;
17112         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
17113         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
17114         return (uint64_t)ret;
17115 }
17116
17117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
17118         LDKChannelManager obj_conv;
17119         obj_conv.inner = (void*)(obj & (~1));
17120         obj_conv.is_owned = false;
17121         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
17122         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
17123         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
17124         CVec_u8Z_free(ret_var);
17125         return ret_arr;
17126 }
17127
17128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17129         LDKChannelManagerReadArgs this_obj_conv;
17130         this_obj_conv.inner = (void*)(this_obj & (~1));
17131         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17132         ChannelManagerReadArgs_free(this_obj_conv);
17133 }
17134
17135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
17136         LDKChannelManagerReadArgs this_ptr_conv;
17137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17138         this_ptr_conv.is_owned = false;
17139         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
17140         return ret_ret;
17141 }
17142
17143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17144         LDKChannelManagerReadArgs this_ptr_conv;
17145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17146         this_ptr_conv.is_owned = false;
17147         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
17148         if (val_conv.free == LDKKeysInterface_JCalls_free) {
17149                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17150                 LDKKeysInterface_JCalls_cloned(&val_conv);
17151         }
17152         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
17153 }
17154
17155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
17156         LDKChannelManagerReadArgs this_ptr_conv;
17157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17158         this_ptr_conv.is_owned = false;
17159         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
17160         return ret_ret;
17161 }
17162
17163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17164         LDKChannelManagerReadArgs this_ptr_conv;
17165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17166         this_ptr_conv.is_owned = false;
17167         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
17168         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
17169                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17170                 LDKFeeEstimator_JCalls_cloned(&val_conv);
17171         }
17172         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
17173 }
17174
17175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
17176         LDKChannelManagerReadArgs this_ptr_conv;
17177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17178         this_ptr_conv.is_owned = false;
17179         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
17180         return ret_ret;
17181 }
17182
17183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17184         LDKChannelManagerReadArgs this_ptr_conv;
17185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17186         this_ptr_conv.is_owned = false;
17187         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
17188         if (val_conv.free == LDKWatch_JCalls_free) {
17189                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17190                 LDKWatch_JCalls_cloned(&val_conv);
17191         }
17192         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
17193 }
17194
17195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
17196         LDKChannelManagerReadArgs this_ptr_conv;
17197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17198         this_ptr_conv.is_owned = false;
17199         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
17200         return ret_ret;
17201 }
17202
17203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17204         LDKChannelManagerReadArgs this_ptr_conv;
17205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17206         this_ptr_conv.is_owned = false;
17207         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
17208         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
17209                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17210                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
17211         }
17212         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
17213 }
17214
17215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
17216         LDKChannelManagerReadArgs this_ptr_conv;
17217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17218         this_ptr_conv.is_owned = false;
17219         uint64_t ret_ret = (uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
17220         return ret_ret;
17221 }
17222
17223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17224         LDKChannelManagerReadArgs this_ptr_conv;
17225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17226         this_ptr_conv.is_owned = false;
17227         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
17228         if (val_conv.free == LDKLogger_JCalls_free) {
17229                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17230                 LDKLogger_JCalls_cloned(&val_conv);
17231         }
17232         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
17233 }
17234
17235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
17236         LDKChannelManagerReadArgs this_ptr_conv;
17237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17238         this_ptr_conv.is_owned = false;
17239         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
17240         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17241         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17242         uint64_t ret_ref = (uint64_t)ret_var.inner;
17243         if (ret_var.is_owned) {
17244                 ret_ref |= 1;
17245         }
17246         return ret_ref;
17247 }
17248
17249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17250         LDKChannelManagerReadArgs this_ptr_conv;
17251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17252         this_ptr_conv.is_owned = false;
17253         LDKUserConfig val_conv;
17254         val_conv.inner = (void*)(val & (~1));
17255         val_conv.is_owned = (val & 1) || (val == 0);
17256         val_conv = UserConfig_clone(&val_conv);
17257         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
17258 }
17259
17260 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) {
17261         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
17262         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
17263                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17264                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
17265         }
17266         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
17267         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
17268                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17269                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
17270         }
17271         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
17272         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
17273                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17274                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
17275         }
17276         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
17277         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
17278                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17279                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
17280         }
17281         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
17282         if (logger_conv.free == LDKLogger_JCalls_free) {
17283                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17284                 LDKLogger_JCalls_cloned(&logger_conv);
17285         }
17286         LDKUserConfig default_config_conv;
17287         default_config_conv.inner = (void*)(default_config & (~1));
17288         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
17289         default_config_conv = UserConfig_clone(&default_config_conv);
17290         LDKCVec_ChannelMonitorZ channel_monitors_constr;
17291         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
17292         if (channel_monitors_constr.datalen > 0)
17293                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
17294         else
17295                 channel_monitors_constr.data = NULL;
17296         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
17297         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
17298                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
17299                 LDKChannelMonitor channel_monitors_conv_16_conv;
17300                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
17301                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
17302                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
17303         }
17304         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
17305         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);
17306         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17307         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17308         uint64_t ret_ref = (uint64_t)ret_var.inner;
17309         if (ret_var.is_owned) {
17310                 ret_ref |= 1;
17311         }
17312         return ret_ref;
17313 }
17314
17315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
17316         LDKu8slice ser_ref;
17317         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
17318         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
17319         LDKChannelManagerReadArgs arg_conv;
17320         arg_conv.inner = (void*)(arg & (~1));
17321         arg_conv.is_owned = (arg & 1) || (arg == 0);
17322         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
17323         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
17324         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
17325         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
17326         return (uint64_t)ret_conv;
17327 }
17328
17329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17330         LDKDecodeError this_obj_conv;
17331         this_obj_conv.inner = (void*)(this_obj & (~1));
17332         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17333         DecodeError_free(this_obj_conv);
17334 }
17335
17336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17337         LDKDecodeError orig_conv;
17338         orig_conv.inner = (void*)(orig & (~1));
17339         orig_conv.is_owned = false;
17340         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
17341         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17342         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17343         uint64_t ret_ref = (uint64_t)ret_var.inner;
17344         if (ret_var.is_owned) {
17345                 ret_ref |= 1;
17346         }
17347         return ret_ref;
17348 }
17349
17350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17351         LDKInit this_obj_conv;
17352         this_obj_conv.inner = (void*)(this_obj & (~1));
17353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17354         Init_free(this_obj_conv);
17355 }
17356
17357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
17358         LDKInit this_ptr_conv;
17359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17360         this_ptr_conv.is_owned = false;
17361         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
17362         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17363         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17364         uint64_t ret_ref = (uint64_t)ret_var.inner;
17365         if (ret_var.is_owned) {
17366                 ret_ref |= 1;
17367         }
17368         return ret_ref;
17369 }
17370
17371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17372         LDKInit this_ptr_conv;
17373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17374         this_ptr_conv.is_owned = false;
17375         LDKInitFeatures val_conv;
17376         val_conv.inner = (void*)(val & (~1));
17377         val_conv.is_owned = (val & 1) || (val == 0);
17378         val_conv = InitFeatures_clone(&val_conv);
17379         Init_set_features(&this_ptr_conv, val_conv);
17380 }
17381
17382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
17383         LDKInitFeatures features_arg_conv;
17384         features_arg_conv.inner = (void*)(features_arg & (~1));
17385         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
17386         features_arg_conv = InitFeatures_clone(&features_arg_conv);
17387         LDKInit ret_var = Init_new(features_arg_conv);
17388         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17389         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17390         uint64_t ret_ref = (uint64_t)ret_var.inner;
17391         if (ret_var.is_owned) {
17392                 ret_ref |= 1;
17393         }
17394         return ret_ref;
17395 }
17396
17397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17398         LDKInit orig_conv;
17399         orig_conv.inner = (void*)(orig & (~1));
17400         orig_conv.is_owned = false;
17401         LDKInit ret_var = Init_clone(&orig_conv);
17402         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17403         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17404         uint64_t ret_ref = (uint64_t)ret_var.inner;
17405         if (ret_var.is_owned) {
17406                 ret_ref |= 1;
17407         }
17408         return ret_ref;
17409 }
17410
17411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17412         LDKErrorMessage this_obj_conv;
17413         this_obj_conv.inner = (void*)(this_obj & (~1));
17414         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17415         ErrorMessage_free(this_obj_conv);
17416 }
17417
17418 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17419         LDKErrorMessage this_ptr_conv;
17420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17421         this_ptr_conv.is_owned = false;
17422         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17423         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
17424         return ret_arr;
17425 }
17426
17427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17428         LDKErrorMessage this_ptr_conv;
17429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17430         this_ptr_conv.is_owned = false;
17431         LDKThirtyTwoBytes val_ref;
17432         CHECK((*env)->GetArrayLength(env, val) == 32);
17433         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17434         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
17435 }
17436
17437 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
17438         LDKErrorMessage this_ptr_conv;
17439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17440         this_ptr_conv.is_owned = false;
17441         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
17442         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
17443         Str_free(ret_str);
17444         return ret_conv;
17445 }
17446
17447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
17448         LDKErrorMessage this_ptr_conv;
17449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17450         this_ptr_conv.is_owned = false;
17451         LDKStr val_conv = java_to_owned_str(env, val);
17452         ErrorMessage_set_data(&this_ptr_conv, val_conv);
17453 }
17454
17455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
17456         LDKThirtyTwoBytes channel_id_arg_ref;
17457         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
17458         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
17459         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
17460         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
17461         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17462         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17463         uint64_t ret_ref = (uint64_t)ret_var.inner;
17464         if (ret_var.is_owned) {
17465                 ret_ref |= 1;
17466         }
17467         return ret_ref;
17468 }
17469
17470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17471         LDKErrorMessage orig_conv;
17472         orig_conv.inner = (void*)(orig & (~1));
17473         orig_conv.is_owned = false;
17474         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
17475         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17476         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17477         uint64_t ret_ref = (uint64_t)ret_var.inner;
17478         if (ret_var.is_owned) {
17479                 ret_ref |= 1;
17480         }
17481         return ret_ref;
17482 }
17483
17484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17485         LDKPing this_obj_conv;
17486         this_obj_conv.inner = (void*)(this_obj & (~1));
17487         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17488         Ping_free(this_obj_conv);
17489 }
17490
17491 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17492         LDKPing this_ptr_conv;
17493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17494         this_ptr_conv.is_owned = false;
17495         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
17496         return ret_val;
17497 }
17498
17499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17500         LDKPing this_ptr_conv;
17501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17502         this_ptr_conv.is_owned = false;
17503         Ping_set_ponglen(&this_ptr_conv, val);
17504 }
17505
17506 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17507         LDKPing this_ptr_conv;
17508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17509         this_ptr_conv.is_owned = false;
17510         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
17511         return ret_val;
17512 }
17513
17514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17515         LDKPing this_ptr_conv;
17516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17517         this_ptr_conv.is_owned = false;
17518         Ping_set_byteslen(&this_ptr_conv, val);
17519 }
17520
17521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
17522         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
17523         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17524         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17525         uint64_t ret_ref = (uint64_t)ret_var.inner;
17526         if (ret_var.is_owned) {
17527                 ret_ref |= 1;
17528         }
17529         return ret_ref;
17530 }
17531
17532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17533         LDKPing orig_conv;
17534         orig_conv.inner = (void*)(orig & (~1));
17535         orig_conv.is_owned = false;
17536         LDKPing ret_var = Ping_clone(&orig_conv);
17537         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17538         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17539         uint64_t ret_ref = (uint64_t)ret_var.inner;
17540         if (ret_var.is_owned) {
17541                 ret_ref |= 1;
17542         }
17543         return ret_ref;
17544 }
17545
17546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17547         LDKPong this_obj_conv;
17548         this_obj_conv.inner = (void*)(this_obj & (~1));
17549         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17550         Pong_free(this_obj_conv);
17551 }
17552
17553 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
17554         LDKPong this_ptr_conv;
17555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17556         this_ptr_conv.is_owned = false;
17557         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
17558         return ret_val;
17559 }
17560
17561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17562         LDKPong this_ptr_conv;
17563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17564         this_ptr_conv.is_owned = false;
17565         Pong_set_byteslen(&this_ptr_conv, val);
17566 }
17567
17568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
17569         LDKPong ret_var = Pong_new(byteslen_arg);
17570         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17571         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17572         uint64_t ret_ref = (uint64_t)ret_var.inner;
17573         if (ret_var.is_owned) {
17574                 ret_ref |= 1;
17575         }
17576         return ret_ref;
17577 }
17578
17579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17580         LDKPong orig_conv;
17581         orig_conv.inner = (void*)(orig & (~1));
17582         orig_conv.is_owned = false;
17583         LDKPong ret_var = Pong_clone(&orig_conv);
17584         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17585         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17586         uint64_t ret_ref = (uint64_t)ret_var.inner;
17587         if (ret_var.is_owned) {
17588                 ret_ref |= 1;
17589         }
17590         return ret_ref;
17591 }
17592
17593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17594         LDKOpenChannel this_obj_conv;
17595         this_obj_conv.inner = (void*)(this_obj & (~1));
17596         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17597         OpenChannel_free(this_obj_conv);
17598 }
17599
17600 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
17601         LDKOpenChannel this_ptr_conv;
17602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17603         this_ptr_conv.is_owned = false;
17604         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17605         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
17606         return ret_arr;
17607 }
17608
17609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17610         LDKOpenChannel this_ptr_conv;
17611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17612         this_ptr_conv.is_owned = false;
17613         LDKThirtyTwoBytes val_ref;
17614         CHECK((*env)->GetArrayLength(env, val) == 32);
17615         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17616         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
17617 }
17618
17619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17620         LDKOpenChannel this_ptr_conv;
17621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17622         this_ptr_conv.is_owned = false;
17623         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17624         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
17625         return ret_arr;
17626 }
17627
17628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17629         LDKOpenChannel this_ptr_conv;
17630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17631         this_ptr_conv.is_owned = false;
17632         LDKThirtyTwoBytes val_ref;
17633         CHECK((*env)->GetArrayLength(env, val) == 32);
17634         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17635         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17636 }
17637
17638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17639         LDKOpenChannel this_ptr_conv;
17640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17641         this_ptr_conv.is_owned = false;
17642         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
17643         return ret_val;
17644 }
17645
17646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17647         LDKOpenChannel this_ptr_conv;
17648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17649         this_ptr_conv.is_owned = false;
17650         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
17651 }
17652
17653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17654         LDKOpenChannel this_ptr_conv;
17655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17656         this_ptr_conv.is_owned = false;
17657         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
17658         return ret_val;
17659 }
17660
17661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17662         LDKOpenChannel this_ptr_conv;
17663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17664         this_ptr_conv.is_owned = false;
17665         OpenChannel_set_push_msat(&this_ptr_conv, val);
17666 }
17667
17668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17669         LDKOpenChannel this_ptr_conv;
17670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17671         this_ptr_conv.is_owned = false;
17672         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
17673         return ret_val;
17674 }
17675
17676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17677         LDKOpenChannel this_ptr_conv;
17678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17679         this_ptr_conv.is_owned = false;
17680         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17681 }
17682
17683 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) {
17684         LDKOpenChannel this_ptr_conv;
17685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17686         this_ptr_conv.is_owned = false;
17687         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17688         return ret_val;
17689 }
17690
17691 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) {
17692         LDKOpenChannel this_ptr_conv;
17693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17694         this_ptr_conv.is_owned = false;
17695         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17696 }
17697
17698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17699         LDKOpenChannel this_ptr_conv;
17700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17701         this_ptr_conv.is_owned = false;
17702         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17703         return ret_val;
17704 }
17705
17706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17707         LDKOpenChannel this_ptr_conv;
17708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17709         this_ptr_conv.is_owned = false;
17710         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17711 }
17712
17713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17714         LDKOpenChannel this_ptr_conv;
17715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17716         this_ptr_conv.is_owned = false;
17717         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
17718         return ret_val;
17719 }
17720
17721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17722         LDKOpenChannel this_ptr_conv;
17723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17724         this_ptr_conv.is_owned = false;
17725         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
17726 }
17727
17728 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
17729         LDKOpenChannel this_ptr_conv;
17730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17731         this_ptr_conv.is_owned = false;
17732         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
17733         return ret_val;
17734 }
17735
17736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
17737         LDKOpenChannel this_ptr_conv;
17738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17739         this_ptr_conv.is_owned = false;
17740         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
17741 }
17742
17743 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
17744         LDKOpenChannel this_ptr_conv;
17745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17746         this_ptr_conv.is_owned = false;
17747         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
17748         return ret_val;
17749 }
17750
17751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17752         LDKOpenChannel this_ptr_conv;
17753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17754         this_ptr_conv.is_owned = false;
17755         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
17756 }
17757
17758 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
17759         LDKOpenChannel this_ptr_conv;
17760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17761         this_ptr_conv.is_owned = false;
17762         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
17763         return ret_val;
17764 }
17765
17766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
17767         LDKOpenChannel this_ptr_conv;
17768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17769         this_ptr_conv.is_owned = false;
17770         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
17771 }
17772
17773 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
17774         LDKOpenChannel this_ptr_conv;
17775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17776         this_ptr_conv.is_owned = false;
17777         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17778         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
17779         return ret_arr;
17780 }
17781
17782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17783         LDKOpenChannel this_ptr_conv;
17784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17785         this_ptr_conv.is_owned = false;
17786         LDKPublicKey val_ref;
17787         CHECK((*env)->GetArrayLength(env, val) == 33);
17788         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17789         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
17790 }
17791
17792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17793         LDKOpenChannel this_ptr_conv;
17794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17795         this_ptr_conv.is_owned = false;
17796         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17797         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
17798         return ret_arr;
17799 }
17800
17801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17802         LDKOpenChannel this_ptr_conv;
17803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17804         this_ptr_conv.is_owned = false;
17805         LDKPublicKey val_ref;
17806         CHECK((*env)->GetArrayLength(env, val) == 33);
17807         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17808         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
17809 }
17810
17811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17812         LDKOpenChannel this_ptr_conv;
17813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17814         this_ptr_conv.is_owned = false;
17815         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17816         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
17817         return ret_arr;
17818 }
17819
17820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17821         LDKOpenChannel this_ptr_conv;
17822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17823         this_ptr_conv.is_owned = false;
17824         LDKPublicKey val_ref;
17825         CHECK((*env)->GetArrayLength(env, val) == 33);
17826         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17827         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
17828 }
17829
17830 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17831         LDKOpenChannel this_ptr_conv;
17832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17833         this_ptr_conv.is_owned = false;
17834         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17835         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
17836         return ret_arr;
17837 }
17838
17839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17840         LDKOpenChannel this_ptr_conv;
17841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17842         this_ptr_conv.is_owned = false;
17843         LDKPublicKey val_ref;
17844         CHECK((*env)->GetArrayLength(env, val) == 33);
17845         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17846         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
17847 }
17848
17849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
17850         LDKOpenChannel this_ptr_conv;
17851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17852         this_ptr_conv.is_owned = false;
17853         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17854         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
17855         return ret_arr;
17856 }
17857
17858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17859         LDKOpenChannel this_ptr_conv;
17860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17861         this_ptr_conv.is_owned = false;
17862         LDKPublicKey val_ref;
17863         CHECK((*env)->GetArrayLength(env, val) == 33);
17864         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17865         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
17866 }
17867
17868 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
17869         LDKOpenChannel this_ptr_conv;
17870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17871         this_ptr_conv.is_owned = false;
17872         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
17873         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
17874         return ret_arr;
17875 }
17876
17877 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) {
17878         LDKOpenChannel this_ptr_conv;
17879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17880         this_ptr_conv.is_owned = false;
17881         LDKPublicKey val_ref;
17882         CHECK((*env)->GetArrayLength(env, val) == 33);
17883         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
17884         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
17885 }
17886
17887 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
17888         LDKOpenChannel this_ptr_conv;
17889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17890         this_ptr_conv.is_owned = false;
17891         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
17892         return ret_val;
17893 }
17894
17895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
17896         LDKOpenChannel this_ptr_conv;
17897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17898         this_ptr_conv.is_owned = false;
17899         OpenChannel_set_channel_flags(&this_ptr_conv, val);
17900 }
17901
17902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17903         LDKOpenChannel orig_conv;
17904         orig_conv.inner = (void*)(orig & (~1));
17905         orig_conv.is_owned = false;
17906         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
17907         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17908         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17909         uint64_t ret_ref = (uint64_t)ret_var.inner;
17910         if (ret_var.is_owned) {
17911                 ret_ref |= 1;
17912         }
17913         return ret_ref;
17914 }
17915
17916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
17917         LDKAcceptChannel this_obj_conv;
17918         this_obj_conv.inner = (void*)(this_obj & (~1));
17919         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17920         AcceptChannel_free(this_obj_conv);
17921 }
17922
17923 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
17924         LDKAcceptChannel this_ptr_conv;
17925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17926         this_ptr_conv.is_owned = false;
17927         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
17928         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
17929         return ret_arr;
17930 }
17931
17932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
17933         LDKAcceptChannel this_ptr_conv;
17934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17935         this_ptr_conv.is_owned = false;
17936         LDKThirtyTwoBytes val_ref;
17937         CHECK((*env)->GetArrayLength(env, val) == 32);
17938         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
17939         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
17940 }
17941
17942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17943         LDKAcceptChannel this_ptr_conv;
17944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17945         this_ptr_conv.is_owned = false;
17946         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
17947         return ret_val;
17948 }
17949
17950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17951         LDKAcceptChannel this_ptr_conv;
17952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17953         this_ptr_conv.is_owned = false;
17954         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
17955 }
17956
17957 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) {
17958         LDKAcceptChannel this_ptr_conv;
17959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17960         this_ptr_conv.is_owned = false;
17961         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
17962         return ret_val;
17963 }
17964
17965 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) {
17966         LDKAcceptChannel this_ptr_conv;
17967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17968         this_ptr_conv.is_owned = false;
17969         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17970 }
17971
17972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
17973         LDKAcceptChannel this_ptr_conv;
17974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17975         this_ptr_conv.is_owned = false;
17976         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
17977         return ret_val;
17978 }
17979
17980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17981         LDKAcceptChannel this_ptr_conv;
17982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17983         this_ptr_conv.is_owned = false;
17984         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
17985 }
17986
17987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
17988         LDKAcceptChannel this_ptr_conv;
17989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17990         this_ptr_conv.is_owned = false;
17991         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
17992         return ret_val;
17993 }
17994
17995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
17996         LDKAcceptChannel this_ptr_conv;
17997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17998         this_ptr_conv.is_owned = false;
17999         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
18000 }
18001
18002 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
18003         LDKAcceptChannel this_ptr_conv;
18004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18005         this_ptr_conv.is_owned = false;
18006         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
18007         return ret_val;
18008 }
18009
18010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18011         LDKAcceptChannel this_ptr_conv;
18012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18013         this_ptr_conv.is_owned = false;
18014         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
18015 }
18016
18017 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
18018         LDKAcceptChannel this_ptr_conv;
18019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18020         this_ptr_conv.is_owned = false;
18021         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
18022         return ret_val;
18023 }
18024
18025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18026         LDKAcceptChannel this_ptr_conv;
18027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18028         this_ptr_conv.is_owned = false;
18029         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
18030 }
18031
18032 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
18033         LDKAcceptChannel this_ptr_conv;
18034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18035         this_ptr_conv.is_owned = false;
18036         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
18037         return ret_val;
18038 }
18039
18040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18041         LDKAcceptChannel this_ptr_conv;
18042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18043         this_ptr_conv.is_owned = false;
18044         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
18045 }
18046
18047 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18048         LDKAcceptChannel this_ptr_conv;
18049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18050         this_ptr_conv.is_owned = false;
18051         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18052         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
18053         return ret_arr;
18054 }
18055
18056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18057         LDKAcceptChannel this_ptr_conv;
18058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18059         this_ptr_conv.is_owned = false;
18060         LDKPublicKey val_ref;
18061         CHECK((*env)->GetArrayLength(env, val) == 33);
18062         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18063         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
18064 }
18065
18066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18067         LDKAcceptChannel this_ptr_conv;
18068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18069         this_ptr_conv.is_owned = false;
18070         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18071         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
18072         return ret_arr;
18073 }
18074
18075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18076         LDKAcceptChannel this_ptr_conv;
18077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18078         this_ptr_conv.is_owned = false;
18079         LDKPublicKey val_ref;
18080         CHECK((*env)->GetArrayLength(env, val) == 33);
18081         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18082         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
18083 }
18084
18085 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18086         LDKAcceptChannel this_ptr_conv;
18087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18088         this_ptr_conv.is_owned = false;
18089         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18090         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
18091         return ret_arr;
18092 }
18093
18094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18095         LDKAcceptChannel this_ptr_conv;
18096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18097         this_ptr_conv.is_owned = false;
18098         LDKPublicKey val_ref;
18099         CHECK((*env)->GetArrayLength(env, val) == 33);
18100         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18101         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
18102 }
18103
18104 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18105         LDKAcceptChannel this_ptr_conv;
18106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18107         this_ptr_conv.is_owned = false;
18108         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18109         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
18110         return ret_arr;
18111 }
18112
18113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18114         LDKAcceptChannel this_ptr_conv;
18115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18116         this_ptr_conv.is_owned = false;
18117         LDKPublicKey val_ref;
18118         CHECK((*env)->GetArrayLength(env, val) == 33);
18119         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18120         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
18121 }
18122
18123 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
18124         LDKAcceptChannel this_ptr_conv;
18125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18126         this_ptr_conv.is_owned = false;
18127         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18128         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
18129         return ret_arr;
18130 }
18131
18132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18133         LDKAcceptChannel this_ptr_conv;
18134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18135         this_ptr_conv.is_owned = false;
18136         LDKPublicKey val_ref;
18137         CHECK((*env)->GetArrayLength(env, val) == 33);
18138         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18139         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
18140 }
18141
18142 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18143         LDKAcceptChannel this_ptr_conv;
18144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18145         this_ptr_conv.is_owned = false;
18146         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18147         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
18148         return ret_arr;
18149 }
18150
18151 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) {
18152         LDKAcceptChannel this_ptr_conv;
18153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18154         this_ptr_conv.is_owned = false;
18155         LDKPublicKey val_ref;
18156         CHECK((*env)->GetArrayLength(env, val) == 33);
18157         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18158         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
18159 }
18160
18161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18162         LDKAcceptChannel orig_conv;
18163         orig_conv.inner = (void*)(orig & (~1));
18164         orig_conv.is_owned = false;
18165         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
18166         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18167         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18168         uint64_t ret_ref = (uint64_t)ret_var.inner;
18169         if (ret_var.is_owned) {
18170                 ret_ref |= 1;
18171         }
18172         return ret_ref;
18173 }
18174
18175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18176         LDKFundingCreated this_obj_conv;
18177         this_obj_conv.inner = (void*)(this_obj & (~1));
18178         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18179         FundingCreated_free(this_obj_conv);
18180 }
18181
18182 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18183         LDKFundingCreated this_ptr_conv;
18184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18185         this_ptr_conv.is_owned = false;
18186         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18187         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
18188         return ret_arr;
18189 }
18190
18191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18192         LDKFundingCreated this_ptr_conv;
18193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18194         this_ptr_conv.is_owned = false;
18195         LDKThirtyTwoBytes val_ref;
18196         CHECK((*env)->GetArrayLength(env, val) == 32);
18197         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18198         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
18199 }
18200
18201 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
18202         LDKFundingCreated this_ptr_conv;
18203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18204         this_ptr_conv.is_owned = false;
18205         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18206         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
18207         return ret_arr;
18208 }
18209
18210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18211         LDKFundingCreated this_ptr_conv;
18212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18213         this_ptr_conv.is_owned = false;
18214         LDKThirtyTwoBytes val_ref;
18215         CHECK((*env)->GetArrayLength(env, val) == 32);
18216         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18217         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
18218 }
18219
18220 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
18221         LDKFundingCreated this_ptr_conv;
18222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18223         this_ptr_conv.is_owned = false;
18224         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
18225         return ret_val;
18226 }
18227
18228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18229         LDKFundingCreated this_ptr_conv;
18230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18231         this_ptr_conv.is_owned = false;
18232         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
18233 }
18234
18235 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18236         LDKFundingCreated this_ptr_conv;
18237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18238         this_ptr_conv.is_owned = false;
18239         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18240         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
18241         return ret_arr;
18242 }
18243
18244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18245         LDKFundingCreated this_ptr_conv;
18246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18247         this_ptr_conv.is_owned = false;
18248         LDKSignature val_ref;
18249         CHECK((*env)->GetArrayLength(env, val) == 64);
18250         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18251         FundingCreated_set_signature(&this_ptr_conv, val_ref);
18252 }
18253
18254 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) {
18255         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
18256         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
18257         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
18258         LDKThirtyTwoBytes funding_txid_arg_ref;
18259         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
18260         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
18261         LDKSignature signature_arg_ref;
18262         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18263         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18264         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
18265         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18266         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18267         uint64_t ret_ref = (uint64_t)ret_var.inner;
18268         if (ret_var.is_owned) {
18269                 ret_ref |= 1;
18270         }
18271         return ret_ref;
18272 }
18273
18274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18275         LDKFundingCreated orig_conv;
18276         orig_conv.inner = (void*)(orig & (~1));
18277         orig_conv.is_owned = false;
18278         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
18279         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18280         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18281         uint64_t ret_ref = (uint64_t)ret_var.inner;
18282         if (ret_var.is_owned) {
18283                 ret_ref |= 1;
18284         }
18285         return ret_ref;
18286 }
18287
18288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18289         LDKFundingSigned this_obj_conv;
18290         this_obj_conv.inner = (void*)(this_obj & (~1));
18291         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18292         FundingSigned_free(this_obj_conv);
18293 }
18294
18295 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18296         LDKFundingSigned this_ptr_conv;
18297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18298         this_ptr_conv.is_owned = false;
18299         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18300         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
18301         return ret_arr;
18302 }
18303
18304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18305         LDKFundingSigned this_ptr_conv;
18306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18307         this_ptr_conv.is_owned = false;
18308         LDKThirtyTwoBytes val_ref;
18309         CHECK((*env)->GetArrayLength(env, val) == 32);
18310         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18311         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
18312 }
18313
18314 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18315         LDKFundingSigned this_ptr_conv;
18316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18317         this_ptr_conv.is_owned = false;
18318         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18319         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
18320         return ret_arr;
18321 }
18322
18323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18324         LDKFundingSigned this_ptr_conv;
18325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18326         this_ptr_conv.is_owned = false;
18327         LDKSignature val_ref;
18328         CHECK((*env)->GetArrayLength(env, val) == 64);
18329         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18330         FundingSigned_set_signature(&this_ptr_conv, val_ref);
18331 }
18332
18333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
18334         LDKThirtyTwoBytes channel_id_arg_ref;
18335         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18336         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18337         LDKSignature signature_arg_ref;
18338         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18339         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18340         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
18341         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18342         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18343         uint64_t ret_ref = (uint64_t)ret_var.inner;
18344         if (ret_var.is_owned) {
18345                 ret_ref |= 1;
18346         }
18347         return ret_ref;
18348 }
18349
18350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18351         LDKFundingSigned orig_conv;
18352         orig_conv.inner = (void*)(orig & (~1));
18353         orig_conv.is_owned = false;
18354         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
18355         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18356         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18357         uint64_t ret_ref = (uint64_t)ret_var.inner;
18358         if (ret_var.is_owned) {
18359                 ret_ref |= 1;
18360         }
18361         return ret_ref;
18362 }
18363
18364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18365         LDKFundingLocked this_obj_conv;
18366         this_obj_conv.inner = (void*)(this_obj & (~1));
18367         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18368         FundingLocked_free(this_obj_conv);
18369 }
18370
18371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18372         LDKFundingLocked this_ptr_conv;
18373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18374         this_ptr_conv.is_owned = false;
18375         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18376         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
18377         return ret_arr;
18378 }
18379
18380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18381         LDKFundingLocked this_ptr_conv;
18382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18383         this_ptr_conv.is_owned = false;
18384         LDKThirtyTwoBytes val_ref;
18385         CHECK((*env)->GetArrayLength(env, val) == 32);
18386         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18387         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
18388 }
18389
18390 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
18391         LDKFundingLocked this_ptr_conv;
18392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18393         this_ptr_conv.is_owned = false;
18394         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
18395         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
18396         return ret_arr;
18397 }
18398
18399 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) {
18400         LDKFundingLocked this_ptr_conv;
18401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18402         this_ptr_conv.is_owned = false;
18403         LDKPublicKey val_ref;
18404         CHECK((*env)->GetArrayLength(env, val) == 33);
18405         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
18406         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
18407 }
18408
18409 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) {
18410         LDKThirtyTwoBytes channel_id_arg_ref;
18411         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18412         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18413         LDKPublicKey next_per_commitment_point_arg_ref;
18414         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
18415         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
18416         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
18417         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18418         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18419         uint64_t ret_ref = (uint64_t)ret_var.inner;
18420         if (ret_var.is_owned) {
18421                 ret_ref |= 1;
18422         }
18423         return ret_ref;
18424 }
18425
18426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18427         LDKFundingLocked orig_conv;
18428         orig_conv.inner = (void*)(orig & (~1));
18429         orig_conv.is_owned = false;
18430         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
18431         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18432         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18433         uint64_t ret_ref = (uint64_t)ret_var.inner;
18434         if (ret_var.is_owned) {
18435                 ret_ref |= 1;
18436         }
18437         return ret_ref;
18438 }
18439
18440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18441         LDKShutdown this_obj_conv;
18442         this_obj_conv.inner = (void*)(this_obj & (~1));
18443         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18444         Shutdown_free(this_obj_conv);
18445 }
18446
18447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18448         LDKShutdown this_ptr_conv;
18449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18450         this_ptr_conv.is_owned = false;
18451         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18452         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
18453         return ret_arr;
18454 }
18455
18456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18457         LDKShutdown this_ptr_conv;
18458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18459         this_ptr_conv.is_owned = false;
18460         LDKThirtyTwoBytes val_ref;
18461         CHECK((*env)->GetArrayLength(env, val) == 32);
18462         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18463         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
18464 }
18465
18466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
18467         LDKShutdown this_ptr_conv;
18468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18469         this_ptr_conv.is_owned = false;
18470         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
18471         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
18472         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
18473         return ret_arr;
18474 }
18475
18476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18477         LDKShutdown this_ptr_conv;
18478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18479         this_ptr_conv.is_owned = false;
18480         LDKCVec_u8Z val_ref;
18481         val_ref.datalen = (*env)->GetArrayLength(env, val);
18482         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
18483         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
18484         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
18485 }
18486
18487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
18488         LDKThirtyTwoBytes channel_id_arg_ref;
18489         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18490         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18491         LDKCVec_u8Z scriptpubkey_arg_ref;
18492         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
18493         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
18494         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
18495         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
18496         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18497         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18498         uint64_t ret_ref = (uint64_t)ret_var.inner;
18499         if (ret_var.is_owned) {
18500                 ret_ref |= 1;
18501         }
18502         return ret_ref;
18503 }
18504
18505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18506         LDKShutdown orig_conv;
18507         orig_conv.inner = (void*)(orig & (~1));
18508         orig_conv.is_owned = false;
18509         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
18510         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18511         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18512         uint64_t ret_ref = (uint64_t)ret_var.inner;
18513         if (ret_var.is_owned) {
18514                 ret_ref |= 1;
18515         }
18516         return ret_ref;
18517 }
18518
18519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18520         LDKClosingSigned this_obj_conv;
18521         this_obj_conv.inner = (void*)(this_obj & (~1));
18522         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18523         ClosingSigned_free(this_obj_conv);
18524 }
18525
18526 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18527         LDKClosingSigned this_ptr_conv;
18528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18529         this_ptr_conv.is_owned = false;
18530         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18531         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
18532         return ret_arr;
18533 }
18534
18535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18536         LDKClosingSigned this_ptr_conv;
18537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18538         this_ptr_conv.is_owned = false;
18539         LDKThirtyTwoBytes val_ref;
18540         CHECK((*env)->GetArrayLength(env, val) == 32);
18541         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18542         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
18543 }
18544
18545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
18546         LDKClosingSigned this_ptr_conv;
18547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18548         this_ptr_conv.is_owned = false;
18549         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
18550         return ret_val;
18551 }
18552
18553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18554         LDKClosingSigned this_ptr_conv;
18555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18556         this_ptr_conv.is_owned = false;
18557         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
18558 }
18559
18560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18561         LDKClosingSigned this_ptr_conv;
18562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18563         this_ptr_conv.is_owned = false;
18564         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18565         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
18566         return ret_arr;
18567 }
18568
18569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18570         LDKClosingSigned this_ptr_conv;
18571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18572         this_ptr_conv.is_owned = false;
18573         LDKSignature val_ref;
18574         CHECK((*env)->GetArrayLength(env, val) == 64);
18575         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18576         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
18577 }
18578
18579 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) {
18580         LDKThirtyTwoBytes channel_id_arg_ref;
18581         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18582         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18583         LDKSignature signature_arg_ref;
18584         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
18585         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
18586         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
18587         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18588         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18589         uint64_t ret_ref = (uint64_t)ret_var.inner;
18590         if (ret_var.is_owned) {
18591                 ret_ref |= 1;
18592         }
18593         return ret_ref;
18594 }
18595
18596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18597         LDKClosingSigned orig_conv;
18598         orig_conv.inner = (void*)(orig & (~1));
18599         orig_conv.is_owned = false;
18600         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
18601         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18602         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18603         uint64_t ret_ref = (uint64_t)ret_var.inner;
18604         if (ret_var.is_owned) {
18605                 ret_ref |= 1;
18606         }
18607         return ret_ref;
18608 }
18609
18610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18611         LDKUpdateAddHTLC this_obj_conv;
18612         this_obj_conv.inner = (void*)(this_obj & (~1));
18613         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18614         UpdateAddHTLC_free(this_obj_conv);
18615 }
18616
18617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18618         LDKUpdateAddHTLC this_ptr_conv;
18619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18620         this_ptr_conv.is_owned = false;
18621         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18622         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
18623         return ret_arr;
18624 }
18625
18626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18627         LDKUpdateAddHTLC this_ptr_conv;
18628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18629         this_ptr_conv.is_owned = false;
18630         LDKThirtyTwoBytes val_ref;
18631         CHECK((*env)->GetArrayLength(env, val) == 32);
18632         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18633         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
18634 }
18635
18636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18637         LDKUpdateAddHTLC this_ptr_conv;
18638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18639         this_ptr_conv.is_owned = false;
18640         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
18641         return ret_val;
18642 }
18643
18644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18645         LDKUpdateAddHTLC this_ptr_conv;
18646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18647         this_ptr_conv.is_owned = false;
18648         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
18649 }
18650
18651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
18652         LDKUpdateAddHTLC this_ptr_conv;
18653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18654         this_ptr_conv.is_owned = false;
18655         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
18656         return ret_val;
18657 }
18658
18659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18660         LDKUpdateAddHTLC this_ptr_conv;
18661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18662         this_ptr_conv.is_owned = false;
18663         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
18664 }
18665
18666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
18667         LDKUpdateAddHTLC this_ptr_conv;
18668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18669         this_ptr_conv.is_owned = false;
18670         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18671         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
18672         return ret_arr;
18673 }
18674
18675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18676         LDKUpdateAddHTLC this_ptr_conv;
18677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18678         this_ptr_conv.is_owned = false;
18679         LDKThirtyTwoBytes val_ref;
18680         CHECK((*env)->GetArrayLength(env, val) == 32);
18681         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18682         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
18683 }
18684
18685 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
18686         LDKUpdateAddHTLC this_ptr_conv;
18687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18688         this_ptr_conv.is_owned = false;
18689         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
18690         return ret_val;
18691 }
18692
18693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
18694         LDKUpdateAddHTLC this_ptr_conv;
18695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18696         this_ptr_conv.is_owned = false;
18697         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
18698 }
18699
18700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18701         LDKUpdateAddHTLC orig_conv;
18702         orig_conv.inner = (void*)(orig & (~1));
18703         orig_conv.is_owned = false;
18704         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
18705         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18706         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18707         uint64_t ret_ref = (uint64_t)ret_var.inner;
18708         if (ret_var.is_owned) {
18709                 ret_ref |= 1;
18710         }
18711         return ret_ref;
18712 }
18713
18714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18715         LDKUpdateFulfillHTLC this_obj_conv;
18716         this_obj_conv.inner = (void*)(this_obj & (~1));
18717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18718         UpdateFulfillHTLC_free(this_obj_conv);
18719 }
18720
18721 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18722         LDKUpdateFulfillHTLC this_ptr_conv;
18723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18724         this_ptr_conv.is_owned = false;
18725         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18726         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
18727         return ret_arr;
18728 }
18729
18730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18731         LDKUpdateFulfillHTLC this_ptr_conv;
18732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18733         this_ptr_conv.is_owned = false;
18734         LDKThirtyTwoBytes val_ref;
18735         CHECK((*env)->GetArrayLength(env, val) == 32);
18736         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18737         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
18738 }
18739
18740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18741         LDKUpdateFulfillHTLC this_ptr_conv;
18742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18743         this_ptr_conv.is_owned = false;
18744         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
18745         return ret_val;
18746 }
18747
18748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18749         LDKUpdateFulfillHTLC this_ptr_conv;
18750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18751         this_ptr_conv.is_owned = false;
18752         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
18753 }
18754
18755 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
18756         LDKUpdateFulfillHTLC this_ptr_conv;
18757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18758         this_ptr_conv.is_owned = false;
18759         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18760         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
18761         return ret_arr;
18762 }
18763
18764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18765         LDKUpdateFulfillHTLC this_ptr_conv;
18766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18767         this_ptr_conv.is_owned = false;
18768         LDKThirtyTwoBytes val_ref;
18769         CHECK((*env)->GetArrayLength(env, val) == 32);
18770         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18771         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
18772 }
18773
18774 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) {
18775         LDKThirtyTwoBytes channel_id_arg_ref;
18776         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18777         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18778         LDKThirtyTwoBytes payment_preimage_arg_ref;
18779         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
18780         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
18781         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
18782         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18783         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18784         uint64_t ret_ref = (uint64_t)ret_var.inner;
18785         if (ret_var.is_owned) {
18786                 ret_ref |= 1;
18787         }
18788         return ret_ref;
18789 }
18790
18791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18792         LDKUpdateFulfillHTLC orig_conv;
18793         orig_conv.inner = (void*)(orig & (~1));
18794         orig_conv.is_owned = false;
18795         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
18796         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18797         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18798         uint64_t ret_ref = (uint64_t)ret_var.inner;
18799         if (ret_var.is_owned) {
18800                 ret_ref |= 1;
18801         }
18802         return ret_ref;
18803 }
18804
18805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18806         LDKUpdateFailHTLC this_obj_conv;
18807         this_obj_conv.inner = (void*)(this_obj & (~1));
18808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18809         UpdateFailHTLC_free(this_obj_conv);
18810 }
18811
18812 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18813         LDKUpdateFailHTLC this_ptr_conv;
18814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18815         this_ptr_conv.is_owned = false;
18816         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18817         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
18818         return ret_arr;
18819 }
18820
18821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18822         LDKUpdateFailHTLC this_ptr_conv;
18823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18824         this_ptr_conv.is_owned = false;
18825         LDKThirtyTwoBytes val_ref;
18826         CHECK((*env)->GetArrayLength(env, val) == 32);
18827         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18828         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
18829 }
18830
18831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18832         LDKUpdateFailHTLC this_ptr_conv;
18833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18834         this_ptr_conv.is_owned = false;
18835         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
18836         return ret_val;
18837 }
18838
18839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18840         LDKUpdateFailHTLC this_ptr_conv;
18841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18842         this_ptr_conv.is_owned = false;
18843         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
18844 }
18845
18846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18847         LDKUpdateFailHTLC orig_conv;
18848         orig_conv.inner = (void*)(orig & (~1));
18849         orig_conv.is_owned = false;
18850         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
18851         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18852         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18853         uint64_t ret_ref = (uint64_t)ret_var.inner;
18854         if (ret_var.is_owned) {
18855                 ret_ref |= 1;
18856         }
18857         return ret_ref;
18858 }
18859
18860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18861         LDKUpdateFailMalformedHTLC this_obj_conv;
18862         this_obj_conv.inner = (void*)(this_obj & (~1));
18863         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18864         UpdateFailMalformedHTLC_free(this_obj_conv);
18865 }
18866
18867 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18868         LDKUpdateFailMalformedHTLC this_ptr_conv;
18869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18870         this_ptr_conv.is_owned = false;
18871         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18872         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
18873         return ret_arr;
18874 }
18875
18876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18877         LDKUpdateFailMalformedHTLC this_ptr_conv;
18878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18879         this_ptr_conv.is_owned = false;
18880         LDKThirtyTwoBytes val_ref;
18881         CHECK((*env)->GetArrayLength(env, val) == 32);
18882         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18883         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
18884 }
18885
18886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18887         LDKUpdateFailMalformedHTLC this_ptr_conv;
18888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18889         this_ptr_conv.is_owned = false;
18890         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
18891         return ret_val;
18892 }
18893
18894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
18895         LDKUpdateFailMalformedHTLC this_ptr_conv;
18896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18897         this_ptr_conv.is_owned = false;
18898         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
18899 }
18900
18901 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
18902         LDKUpdateFailMalformedHTLC this_ptr_conv;
18903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18904         this_ptr_conv.is_owned = false;
18905         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
18906         return ret_val;
18907 }
18908
18909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
18910         LDKUpdateFailMalformedHTLC this_ptr_conv;
18911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18912         this_ptr_conv.is_owned = false;
18913         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
18914 }
18915
18916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18917         LDKUpdateFailMalformedHTLC orig_conv;
18918         orig_conv.inner = (void*)(orig & (~1));
18919         orig_conv.is_owned = false;
18920         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
18921         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18922         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18923         uint64_t ret_ref = (uint64_t)ret_var.inner;
18924         if (ret_var.is_owned) {
18925                 ret_ref |= 1;
18926         }
18927         return ret_ref;
18928 }
18929
18930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
18931         LDKCommitmentSigned this_obj_conv;
18932         this_obj_conv.inner = (void*)(this_obj & (~1));
18933         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18934         CommitmentSigned_free(this_obj_conv);
18935 }
18936
18937 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
18938         LDKCommitmentSigned this_ptr_conv;
18939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18940         this_ptr_conv.is_owned = false;
18941         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
18942         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
18943         return ret_arr;
18944 }
18945
18946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18947         LDKCommitmentSigned this_ptr_conv;
18948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18949         this_ptr_conv.is_owned = false;
18950         LDKThirtyTwoBytes val_ref;
18951         CHECK((*env)->GetArrayLength(env, val) == 32);
18952         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
18953         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
18954 }
18955
18956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
18957         LDKCommitmentSigned this_ptr_conv;
18958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18959         this_ptr_conv.is_owned = false;
18960         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
18961         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
18962         return ret_arr;
18963 }
18964
18965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
18966         LDKCommitmentSigned this_ptr_conv;
18967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18968         this_ptr_conv.is_owned = false;
18969         LDKSignature val_ref;
18970         CHECK((*env)->GetArrayLength(env, val) == 64);
18971         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
18972         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
18973 }
18974
18975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
18976         LDKCommitmentSigned this_ptr_conv;
18977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18978         this_ptr_conv.is_owned = false;
18979         LDKCVec_SignatureZ val_constr;
18980         val_constr.datalen = (*env)->GetArrayLength(env, val);
18981         if (val_constr.datalen > 0)
18982                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18983         else
18984                 val_constr.data = NULL;
18985         for (size_t i = 0; i < val_constr.datalen; i++) {
18986                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
18987                 LDKSignature val_conv_8_ref;
18988                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
18989                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
18990                 val_constr.data[i] = val_conv_8_ref;
18991         }
18992         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
18993 }
18994
18995 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) {
18996         LDKThirtyTwoBytes channel_id_arg_ref;
18997         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
18998         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
18999         LDKSignature signature_arg_ref;
19000         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19001         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19002         LDKCVec_SignatureZ htlc_signatures_arg_constr;
19003         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
19004         if (htlc_signatures_arg_constr.datalen > 0)
19005                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19006         else
19007                 htlc_signatures_arg_constr.data = NULL;
19008         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
19009                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
19010                 LDKSignature htlc_signatures_arg_conv_8_ref;
19011                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
19012                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
19013                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
19014         }
19015         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
19016         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19017         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19018         uint64_t ret_ref = (uint64_t)ret_var.inner;
19019         if (ret_var.is_owned) {
19020                 ret_ref |= 1;
19021         }
19022         return ret_ref;
19023 }
19024
19025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19026         LDKCommitmentSigned orig_conv;
19027         orig_conv.inner = (void*)(orig & (~1));
19028         orig_conv.is_owned = false;
19029         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
19030         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19031         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19032         uint64_t ret_ref = (uint64_t)ret_var.inner;
19033         if (ret_var.is_owned) {
19034                 ret_ref |= 1;
19035         }
19036         return ret_ref;
19037 }
19038
19039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19040         LDKRevokeAndACK this_obj_conv;
19041         this_obj_conv.inner = (void*)(this_obj & (~1));
19042         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19043         RevokeAndACK_free(this_obj_conv);
19044 }
19045
19046 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19047         LDKRevokeAndACK this_ptr_conv;
19048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19049         this_ptr_conv.is_owned = false;
19050         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19051         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
19052         return ret_arr;
19053 }
19054
19055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19056         LDKRevokeAndACK this_ptr_conv;
19057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19058         this_ptr_conv.is_owned = false;
19059         LDKThirtyTwoBytes val_ref;
19060         CHECK((*env)->GetArrayLength(env, val) == 32);
19061         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19062         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
19063 }
19064
19065 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
19066         LDKRevokeAndACK this_ptr_conv;
19067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19068         this_ptr_conv.is_owned = false;
19069         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19070         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
19071         return ret_arr;
19072 }
19073
19074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19075         LDKRevokeAndACK this_ptr_conv;
19076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19077         this_ptr_conv.is_owned = false;
19078         LDKThirtyTwoBytes val_ref;
19079         CHECK((*env)->GetArrayLength(env, val) == 32);
19080         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19081         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
19082 }
19083
19084 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
19085         LDKRevokeAndACK this_ptr_conv;
19086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19087         this_ptr_conv.is_owned = false;
19088         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19089         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
19090         return ret_arr;
19091 }
19092
19093 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) {
19094         LDKRevokeAndACK this_ptr_conv;
19095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19096         this_ptr_conv.is_owned = false;
19097         LDKPublicKey val_ref;
19098         CHECK((*env)->GetArrayLength(env, val) == 33);
19099         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19100         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
19101 }
19102
19103 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) {
19104         LDKThirtyTwoBytes channel_id_arg_ref;
19105         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19106         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19107         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
19108         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
19109         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
19110         LDKPublicKey next_per_commitment_point_arg_ref;
19111         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
19112         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
19113         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
19114         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19115         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19116         uint64_t ret_ref = (uint64_t)ret_var.inner;
19117         if (ret_var.is_owned) {
19118                 ret_ref |= 1;
19119         }
19120         return ret_ref;
19121 }
19122
19123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19124         LDKRevokeAndACK orig_conv;
19125         orig_conv.inner = (void*)(orig & (~1));
19126         orig_conv.is_owned = false;
19127         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
19128         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19129         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19130         uint64_t ret_ref = (uint64_t)ret_var.inner;
19131         if (ret_var.is_owned) {
19132                 ret_ref |= 1;
19133         }
19134         return ret_ref;
19135 }
19136
19137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19138         LDKUpdateFee this_obj_conv;
19139         this_obj_conv.inner = (void*)(this_obj & (~1));
19140         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19141         UpdateFee_free(this_obj_conv);
19142 }
19143
19144 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19145         LDKUpdateFee this_ptr_conv;
19146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19147         this_ptr_conv.is_owned = false;
19148         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19149         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
19150         return ret_arr;
19151 }
19152
19153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19154         LDKUpdateFee this_ptr_conv;
19155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19156         this_ptr_conv.is_owned = false;
19157         LDKThirtyTwoBytes val_ref;
19158         CHECK((*env)->GetArrayLength(env, val) == 32);
19159         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19160         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
19161 }
19162
19163 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
19164         LDKUpdateFee this_ptr_conv;
19165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19166         this_ptr_conv.is_owned = false;
19167         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
19168         return ret_val;
19169 }
19170
19171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19172         LDKUpdateFee this_ptr_conv;
19173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19174         this_ptr_conv.is_owned = false;
19175         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
19176 }
19177
19178 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) {
19179         LDKThirtyTwoBytes channel_id_arg_ref;
19180         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19181         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19182         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
19183         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19184         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19185         uint64_t ret_ref = (uint64_t)ret_var.inner;
19186         if (ret_var.is_owned) {
19187                 ret_ref |= 1;
19188         }
19189         return ret_ref;
19190 }
19191
19192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19193         LDKUpdateFee orig_conv;
19194         orig_conv.inner = (void*)(orig & (~1));
19195         orig_conv.is_owned = false;
19196         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
19197         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19198         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19199         uint64_t ret_ref = (uint64_t)ret_var.inner;
19200         if (ret_var.is_owned) {
19201                 ret_ref |= 1;
19202         }
19203         return ret_ref;
19204 }
19205
19206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19207         LDKDataLossProtect this_obj_conv;
19208         this_obj_conv.inner = (void*)(this_obj & (~1));
19209         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19210         DataLossProtect_free(this_obj_conv);
19211 }
19212
19213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
19214         LDKDataLossProtect this_ptr_conv;
19215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19216         this_ptr_conv.is_owned = false;
19217         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19218         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
19219         return ret_arr;
19220 }
19221
19222 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) {
19223         LDKDataLossProtect this_ptr_conv;
19224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19225         this_ptr_conv.is_owned = false;
19226         LDKThirtyTwoBytes val_ref;
19227         CHECK((*env)->GetArrayLength(env, val) == 32);
19228         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19229         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
19230 }
19231
19232 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
19233         LDKDataLossProtect this_ptr_conv;
19234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19235         this_ptr_conv.is_owned = false;
19236         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19237         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
19238         return ret_arr;
19239 }
19240
19241 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) {
19242         LDKDataLossProtect this_ptr_conv;
19243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19244         this_ptr_conv.is_owned = false;
19245         LDKPublicKey val_ref;
19246         CHECK((*env)->GetArrayLength(env, val) == 33);
19247         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19248         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
19249 }
19250
19251 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) {
19252         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
19253         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
19254         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
19255         LDKPublicKey my_current_per_commitment_point_arg_ref;
19256         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
19257         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
19258         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
19259         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19260         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19261         uint64_t ret_ref = (uint64_t)ret_var.inner;
19262         if (ret_var.is_owned) {
19263                 ret_ref |= 1;
19264         }
19265         return ret_ref;
19266 }
19267
19268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19269         LDKDataLossProtect orig_conv;
19270         orig_conv.inner = (void*)(orig & (~1));
19271         orig_conv.is_owned = false;
19272         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
19273         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19274         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19275         uint64_t ret_ref = (uint64_t)ret_var.inner;
19276         if (ret_var.is_owned) {
19277                 ret_ref |= 1;
19278         }
19279         return ret_ref;
19280 }
19281
19282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19283         LDKChannelReestablish this_obj_conv;
19284         this_obj_conv.inner = (void*)(this_obj & (~1));
19285         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19286         ChannelReestablish_free(this_obj_conv);
19287 }
19288
19289 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19290         LDKChannelReestablish this_ptr_conv;
19291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19292         this_ptr_conv.is_owned = false;
19293         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19294         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
19295         return ret_arr;
19296 }
19297
19298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19299         LDKChannelReestablish this_ptr_conv;
19300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19301         this_ptr_conv.is_owned = false;
19302         LDKThirtyTwoBytes val_ref;
19303         CHECK((*env)->GetArrayLength(env, val) == 32);
19304         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19305         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
19306 }
19307
19308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
19309         LDKChannelReestablish this_ptr_conv;
19310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19311         this_ptr_conv.is_owned = false;
19312         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
19313         return ret_val;
19314 }
19315
19316 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) {
19317         LDKChannelReestablish this_ptr_conv;
19318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19319         this_ptr_conv.is_owned = false;
19320         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
19321 }
19322
19323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
19324         LDKChannelReestablish this_ptr_conv;
19325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19326         this_ptr_conv.is_owned = false;
19327         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
19328         return ret_val;
19329 }
19330
19331 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) {
19332         LDKChannelReestablish this_ptr_conv;
19333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19334         this_ptr_conv.is_owned = false;
19335         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
19336 }
19337
19338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19339         LDKChannelReestablish orig_conv;
19340         orig_conv.inner = (void*)(orig & (~1));
19341         orig_conv.is_owned = false;
19342         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
19343         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19344         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19345         uint64_t ret_ref = (uint64_t)ret_var.inner;
19346         if (ret_var.is_owned) {
19347                 ret_ref |= 1;
19348         }
19349         return ret_ref;
19350 }
19351
19352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19353         LDKAnnouncementSignatures this_obj_conv;
19354         this_obj_conv.inner = (void*)(this_obj & (~1));
19355         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19356         AnnouncementSignatures_free(this_obj_conv);
19357 }
19358
19359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19360         LDKAnnouncementSignatures this_ptr_conv;
19361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19362         this_ptr_conv.is_owned = false;
19363         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19364         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
19365         return ret_arr;
19366 }
19367
19368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19369         LDKAnnouncementSignatures this_ptr_conv;
19370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19371         this_ptr_conv.is_owned = false;
19372         LDKThirtyTwoBytes val_ref;
19373         CHECK((*env)->GetArrayLength(env, val) == 32);
19374         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19375         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
19376 }
19377
19378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19379         LDKAnnouncementSignatures this_ptr_conv;
19380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19381         this_ptr_conv.is_owned = false;
19382         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
19383         return ret_val;
19384 }
19385
19386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19387         LDKAnnouncementSignatures this_ptr_conv;
19388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19389         this_ptr_conv.is_owned = false;
19390         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
19391 }
19392
19393 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19394         LDKAnnouncementSignatures this_ptr_conv;
19395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19396         this_ptr_conv.is_owned = false;
19397         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19398         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
19399         return ret_arr;
19400 }
19401
19402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19403         LDKAnnouncementSignatures this_ptr_conv;
19404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19405         this_ptr_conv.is_owned = false;
19406         LDKSignature val_ref;
19407         CHECK((*env)->GetArrayLength(env, val) == 64);
19408         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19409         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
19410 }
19411
19412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19413         LDKAnnouncementSignatures this_ptr_conv;
19414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19415         this_ptr_conv.is_owned = false;
19416         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19417         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
19418         return ret_arr;
19419 }
19420
19421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19422         LDKAnnouncementSignatures this_ptr_conv;
19423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19424         this_ptr_conv.is_owned = false;
19425         LDKSignature val_ref;
19426         CHECK((*env)->GetArrayLength(env, val) == 64);
19427         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19428         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
19429 }
19430
19431 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) {
19432         LDKThirtyTwoBytes channel_id_arg_ref;
19433         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
19434         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
19435         LDKSignature node_signature_arg_ref;
19436         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
19437         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
19438         LDKSignature bitcoin_signature_arg_ref;
19439         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
19440         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
19441         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
19442         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19443         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19444         uint64_t ret_ref = (uint64_t)ret_var.inner;
19445         if (ret_var.is_owned) {
19446                 ret_ref |= 1;
19447         }
19448         return ret_ref;
19449 }
19450
19451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19452         LDKAnnouncementSignatures orig_conv;
19453         orig_conv.inner = (void*)(orig & (~1));
19454         orig_conv.is_owned = false;
19455         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
19456         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19457         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19458         uint64_t ret_ref = (uint64_t)ret_var.inner;
19459         if (ret_var.is_owned) {
19460                 ret_ref |= 1;
19461         }
19462         return ret_ref;
19463 }
19464
19465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19466         if ((this_ptr & 1) != 0) return;
19467         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
19468         FREE((void*)this_ptr);
19469         NetAddress_free(this_ptr_conv);
19470 }
19471
19472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19473         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
19474         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19475         *ret_copy = NetAddress_clone(orig_conv);
19476         uint64_t ret_ref = (uint64_t)ret_copy;
19477         return ret_ref;
19478 }
19479
19480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
19481         LDKFourBytes addr_ref;
19482         CHECK((*env)->GetArrayLength(env, addr) == 4);
19483         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
19484         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19485         *ret_copy = NetAddress_ipv4(addr_ref, port);
19486         uint64_t ret_ref = (uint64_t)ret_copy;
19487         return ret_ref;
19488 }
19489
19490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
19491         LDKSixteenBytes addr_ref;
19492         CHECK((*env)->GetArrayLength(env, addr) == 16);
19493         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
19494         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19495         *ret_copy = NetAddress_ipv6(addr_ref, port);
19496         uint64_t ret_ref = (uint64_t)ret_copy;
19497         return ret_ref;
19498 }
19499
19500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
19501         LDKTenBytes addr_ref;
19502         CHECK((*env)->GetArrayLength(env, addr) == 10);
19503         (*env)->GetByteArrayRegion(env, addr, 0, 10, addr_ref.data);
19504         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19505         *ret_copy = NetAddress_onion_v2(addr_ref, port);
19506         uint64_t ret_ref = (uint64_t)ret_copy;
19507         return ret_ref;
19508 }
19509
19510 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) {
19511         LDKThirtyTwoBytes ed25519_pubkey_ref;
19512         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
19513         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
19514         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
19515         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
19516         uint64_t ret_ref = (uint64_t)ret_copy;
19517         return ret_ref;
19518 }
19519
19520 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
19521         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
19522         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
19523         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19524         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19525         CVec_u8Z_free(ret_var);
19526         return ret_arr;
19527 }
19528
19529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Result_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19530         LDKu8slice ser_ref;
19531         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19532         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19533         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
19534         *ret_conv = Result_read(ser_ref);
19535         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19536         return (uint64_t)ret_conv;
19537 }
19538
19539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19540         LDKu8slice ser_ref;
19541         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19542         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19543         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
19544         *ret_conv = NetAddress_read(ser_ref);
19545         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19546         return (uint64_t)ret_conv;
19547 }
19548
19549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19550         LDKUnsignedNodeAnnouncement this_obj_conv;
19551         this_obj_conv.inner = (void*)(this_obj & (~1));
19552         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19553         UnsignedNodeAnnouncement_free(this_obj_conv);
19554 }
19555
19556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19557         LDKUnsignedNodeAnnouncement this_ptr_conv;
19558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19559         this_ptr_conv.is_owned = false;
19560         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
19561         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19562         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19563         uint64_t ret_ref = (uint64_t)ret_var.inner;
19564         if (ret_var.is_owned) {
19565                 ret_ref |= 1;
19566         }
19567         return ret_ref;
19568 }
19569
19570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19571         LDKUnsignedNodeAnnouncement this_ptr_conv;
19572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19573         this_ptr_conv.is_owned = false;
19574         LDKNodeFeatures val_conv;
19575         val_conv.inner = (void*)(val & (~1));
19576         val_conv.is_owned = (val & 1) || (val == 0);
19577         val_conv = NodeFeatures_clone(&val_conv);
19578         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
19579 }
19580
19581 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
19582         LDKUnsignedNodeAnnouncement this_ptr_conv;
19583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19584         this_ptr_conv.is_owned = false;
19585         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
19586         return ret_val;
19587 }
19588
19589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
19590         LDKUnsignedNodeAnnouncement this_ptr_conv;
19591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19592         this_ptr_conv.is_owned = false;
19593         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
19594 }
19595
19596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19597         LDKUnsignedNodeAnnouncement this_ptr_conv;
19598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19599         this_ptr_conv.is_owned = false;
19600         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19601         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
19602         return ret_arr;
19603 }
19604
19605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19606         LDKUnsignedNodeAnnouncement this_ptr_conv;
19607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19608         this_ptr_conv.is_owned = false;
19609         LDKPublicKey val_ref;
19610         CHECK((*env)->GetArrayLength(env, val) == 33);
19611         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19612         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
19613 }
19614
19615 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
19616         LDKUnsignedNodeAnnouncement this_ptr_conv;
19617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19618         this_ptr_conv.is_owned = false;
19619         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
19620         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
19621         return ret_arr;
19622 }
19623
19624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19625         LDKUnsignedNodeAnnouncement this_ptr_conv;
19626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19627         this_ptr_conv.is_owned = false;
19628         LDKThreeBytes val_ref;
19629         CHECK((*env)->GetArrayLength(env, val) == 3);
19630         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
19631         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
19632 }
19633
19634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
19635         LDKUnsignedNodeAnnouncement this_ptr_conv;
19636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19637         this_ptr_conv.is_owned = false;
19638         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19639         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
19640         return ret_arr;
19641 }
19642
19643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19644         LDKUnsignedNodeAnnouncement this_ptr_conv;
19645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19646         this_ptr_conv.is_owned = false;
19647         LDKThirtyTwoBytes val_ref;
19648         CHECK((*env)->GetArrayLength(env, val) == 32);
19649         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19650         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
19651 }
19652
19653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
19654         LDKUnsignedNodeAnnouncement this_ptr_conv;
19655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19656         this_ptr_conv.is_owned = false;
19657         LDKCVec_NetAddressZ val_constr;
19658         val_constr.datalen = (*env)->GetArrayLength(env, val);
19659         if (val_constr.datalen > 0)
19660                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19661         else
19662                 val_constr.data = NULL;
19663         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
19664         for (size_t m = 0; m < val_constr.datalen; m++) {
19665                 int64_t val_conv_12 = val_vals[m];
19666                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
19667                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
19668                 val_constr.data[m] = val_conv_12_conv;
19669         }
19670         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
19671         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
19672 }
19673
19674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19675         LDKUnsignedNodeAnnouncement orig_conv;
19676         orig_conv.inner = (void*)(orig & (~1));
19677         orig_conv.is_owned = false;
19678         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
19679         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19680         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19681         uint64_t ret_ref = (uint64_t)ret_var.inner;
19682         if (ret_var.is_owned) {
19683                 ret_ref |= 1;
19684         }
19685         return ret_ref;
19686 }
19687
19688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19689         LDKNodeAnnouncement this_obj_conv;
19690         this_obj_conv.inner = (void*)(this_obj & (~1));
19691         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19692         NodeAnnouncement_free(this_obj_conv);
19693 }
19694
19695 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
19696         LDKNodeAnnouncement this_ptr_conv;
19697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19698         this_ptr_conv.is_owned = false;
19699         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19700         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
19701         return ret_arr;
19702 }
19703
19704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19705         LDKNodeAnnouncement this_ptr_conv;
19706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19707         this_ptr_conv.is_owned = false;
19708         LDKSignature val_ref;
19709         CHECK((*env)->GetArrayLength(env, val) == 64);
19710         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19711         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
19712 }
19713
19714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
19715         LDKNodeAnnouncement this_ptr_conv;
19716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19717         this_ptr_conv.is_owned = false;
19718         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
19719         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19720         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19721         uint64_t ret_ref = (uint64_t)ret_var.inner;
19722         if (ret_var.is_owned) {
19723                 ret_ref |= 1;
19724         }
19725         return ret_ref;
19726 }
19727
19728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19729         LDKNodeAnnouncement this_ptr_conv;
19730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19731         this_ptr_conv.is_owned = false;
19732         LDKUnsignedNodeAnnouncement val_conv;
19733         val_conv.inner = (void*)(val & (~1));
19734         val_conv.is_owned = (val & 1) || (val == 0);
19735         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
19736         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
19737 }
19738
19739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
19740         LDKSignature signature_arg_ref;
19741         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
19742         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
19743         LDKUnsignedNodeAnnouncement contents_arg_conv;
19744         contents_arg_conv.inner = (void*)(contents_arg & (~1));
19745         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
19746         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
19747         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
19748         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19749         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19750         uint64_t ret_ref = (uint64_t)ret_var.inner;
19751         if (ret_var.is_owned) {
19752                 ret_ref |= 1;
19753         }
19754         return ret_ref;
19755 }
19756
19757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19758         LDKNodeAnnouncement orig_conv;
19759         orig_conv.inner = (void*)(orig & (~1));
19760         orig_conv.is_owned = false;
19761         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
19762         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19763         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19764         uint64_t ret_ref = (uint64_t)ret_var.inner;
19765         if (ret_var.is_owned) {
19766                 ret_ref |= 1;
19767         }
19768         return ret_ref;
19769 }
19770
19771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19772         LDKUnsignedChannelAnnouncement this_obj_conv;
19773         this_obj_conv.inner = (void*)(this_obj & (~1));
19774         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19775         UnsignedChannelAnnouncement_free(this_obj_conv);
19776 }
19777
19778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
19779         LDKUnsignedChannelAnnouncement this_ptr_conv;
19780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19781         this_ptr_conv.is_owned = false;
19782         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
19783         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19784         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19785         uint64_t ret_ref = (uint64_t)ret_var.inner;
19786         if (ret_var.is_owned) {
19787                 ret_ref |= 1;
19788         }
19789         return ret_ref;
19790 }
19791
19792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19793         LDKUnsignedChannelAnnouncement this_ptr_conv;
19794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19795         this_ptr_conv.is_owned = false;
19796         LDKChannelFeatures val_conv;
19797         val_conv.inner = (void*)(val & (~1));
19798         val_conv.is_owned = (val & 1) || (val == 0);
19799         val_conv = ChannelFeatures_clone(&val_conv);
19800         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
19801 }
19802
19803 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
19804         LDKUnsignedChannelAnnouncement this_ptr_conv;
19805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19806         this_ptr_conv.is_owned = false;
19807         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
19808         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
19809         return ret_arr;
19810 }
19811
19812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19813         LDKUnsignedChannelAnnouncement this_ptr_conv;
19814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19815         this_ptr_conv.is_owned = false;
19816         LDKThirtyTwoBytes val_ref;
19817         CHECK((*env)->GetArrayLength(env, val) == 32);
19818         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
19819         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
19820 }
19821
19822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
19823         LDKUnsignedChannelAnnouncement this_ptr_conv;
19824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19825         this_ptr_conv.is_owned = false;
19826         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
19827         return ret_val;
19828 }
19829
19830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
19831         LDKUnsignedChannelAnnouncement this_ptr_conv;
19832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19833         this_ptr_conv.is_owned = false;
19834         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
19835 }
19836
19837 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19838         LDKUnsignedChannelAnnouncement this_ptr_conv;
19839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19840         this_ptr_conv.is_owned = false;
19841         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19842         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
19843         return ret_arr;
19844 }
19845
19846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19847         LDKUnsignedChannelAnnouncement this_ptr_conv;
19848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19849         this_ptr_conv.is_owned = false;
19850         LDKPublicKey val_ref;
19851         CHECK((*env)->GetArrayLength(env, val) == 33);
19852         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19853         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
19854 }
19855
19856 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19857         LDKUnsignedChannelAnnouncement this_ptr_conv;
19858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19859         this_ptr_conv.is_owned = false;
19860         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19861         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
19862         return ret_arr;
19863 }
19864
19865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19866         LDKUnsignedChannelAnnouncement this_ptr_conv;
19867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19868         this_ptr_conv.is_owned = false;
19869         LDKPublicKey val_ref;
19870         CHECK((*env)->GetArrayLength(env, val) == 33);
19871         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19872         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
19873 }
19874
19875 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19876         LDKUnsignedChannelAnnouncement this_ptr_conv;
19877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19878         this_ptr_conv.is_owned = false;
19879         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19880         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
19881         return ret_arr;
19882 }
19883
19884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19885         LDKUnsignedChannelAnnouncement this_ptr_conv;
19886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19887         this_ptr_conv.is_owned = false;
19888         LDKPublicKey val_ref;
19889         CHECK((*env)->GetArrayLength(env, val) == 33);
19890         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19891         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
19892 }
19893
19894 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19895         LDKUnsignedChannelAnnouncement this_ptr_conv;
19896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19897         this_ptr_conv.is_owned = false;
19898         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
19899         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
19900         return ret_arr;
19901 }
19902
19903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19904         LDKUnsignedChannelAnnouncement this_ptr_conv;
19905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19906         this_ptr_conv.is_owned = false;
19907         LDKPublicKey val_ref;
19908         CHECK((*env)->GetArrayLength(env, val) == 33);
19909         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
19910         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
19911 }
19912
19913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19914         LDKUnsignedChannelAnnouncement orig_conv;
19915         orig_conv.inner = (void*)(orig & (~1));
19916         orig_conv.is_owned = false;
19917         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
19918         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19919         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19920         uint64_t ret_ref = (uint64_t)ret_var.inner;
19921         if (ret_var.is_owned) {
19922                 ret_ref |= 1;
19923         }
19924         return ret_ref;
19925 }
19926
19927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
19928         LDKChannelAnnouncement this_obj_conv;
19929         this_obj_conv.inner = (void*)(this_obj & (~1));
19930         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19931         ChannelAnnouncement_free(this_obj_conv);
19932 }
19933
19934 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19935         LDKChannelAnnouncement this_ptr_conv;
19936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19937         this_ptr_conv.is_owned = false;
19938         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19939         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
19940         return ret_arr;
19941 }
19942
19943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19944         LDKChannelAnnouncement this_ptr_conv;
19945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19946         this_ptr_conv.is_owned = false;
19947         LDKSignature val_ref;
19948         CHECK((*env)->GetArrayLength(env, val) == 64);
19949         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19950         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
19951 }
19952
19953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19954         LDKChannelAnnouncement this_ptr_conv;
19955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19956         this_ptr_conv.is_owned = false;
19957         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19958         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
19959         return ret_arr;
19960 }
19961
19962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19963         LDKChannelAnnouncement this_ptr_conv;
19964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19965         this_ptr_conv.is_owned = false;
19966         LDKSignature val_ref;
19967         CHECK((*env)->GetArrayLength(env, val) == 64);
19968         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19969         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
19970 }
19971
19972 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
19973         LDKChannelAnnouncement this_ptr_conv;
19974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19975         this_ptr_conv.is_owned = false;
19976         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19977         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
19978         return ret_arr;
19979 }
19980
19981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
19982         LDKChannelAnnouncement this_ptr_conv;
19983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19984         this_ptr_conv.is_owned = false;
19985         LDKSignature val_ref;
19986         CHECK((*env)->GetArrayLength(env, val) == 64);
19987         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
19988         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
19989 }
19990
19991 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
19992         LDKChannelAnnouncement this_ptr_conv;
19993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19994         this_ptr_conv.is_owned = false;
19995         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
19996         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
19997         return ret_arr;
19998 }
19999
20000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20001         LDKChannelAnnouncement this_ptr_conv;
20002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20003         this_ptr_conv.is_owned = false;
20004         LDKSignature val_ref;
20005         CHECK((*env)->GetArrayLength(env, val) == 64);
20006         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20007         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
20008 }
20009
20010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
20011         LDKChannelAnnouncement this_ptr_conv;
20012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20013         this_ptr_conv.is_owned = false;
20014         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
20015         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20016         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20017         uint64_t ret_ref = (uint64_t)ret_var.inner;
20018         if (ret_var.is_owned) {
20019                 ret_ref |= 1;
20020         }
20021         return ret_ref;
20022 }
20023
20024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20025         LDKChannelAnnouncement this_ptr_conv;
20026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20027         this_ptr_conv.is_owned = false;
20028         LDKUnsignedChannelAnnouncement val_conv;
20029         val_conv.inner = (void*)(val & (~1));
20030         val_conv.is_owned = (val & 1) || (val == 0);
20031         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
20032         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
20033 }
20034
20035 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) {
20036         LDKSignature node_signature_1_arg_ref;
20037         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
20038         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
20039         LDKSignature node_signature_2_arg_ref;
20040         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
20041         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
20042         LDKSignature bitcoin_signature_1_arg_ref;
20043         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
20044         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
20045         LDKSignature bitcoin_signature_2_arg_ref;
20046         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
20047         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
20048         LDKUnsignedChannelAnnouncement contents_arg_conv;
20049         contents_arg_conv.inner = (void*)(contents_arg & (~1));
20050         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
20051         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
20052         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);
20053         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20054         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20055         uint64_t ret_ref = (uint64_t)ret_var.inner;
20056         if (ret_var.is_owned) {
20057                 ret_ref |= 1;
20058         }
20059         return ret_ref;
20060 }
20061
20062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20063         LDKChannelAnnouncement orig_conv;
20064         orig_conv.inner = (void*)(orig & (~1));
20065         orig_conv.is_owned = false;
20066         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
20067         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20068         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20069         uint64_t ret_ref = (uint64_t)ret_var.inner;
20070         if (ret_var.is_owned) {
20071                 ret_ref |= 1;
20072         }
20073         return ret_ref;
20074 }
20075
20076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20077         LDKUnsignedChannelUpdate this_obj_conv;
20078         this_obj_conv.inner = (void*)(this_obj & (~1));
20079         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20080         UnsignedChannelUpdate_free(this_obj_conv);
20081 }
20082
20083 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20084         LDKUnsignedChannelUpdate this_ptr_conv;
20085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20086         this_ptr_conv.is_owned = false;
20087         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20088         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
20089         return ret_arr;
20090 }
20091
20092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20093         LDKUnsignedChannelUpdate this_ptr_conv;
20094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20095         this_ptr_conv.is_owned = false;
20096         LDKThirtyTwoBytes val_ref;
20097         CHECK((*env)->GetArrayLength(env, val) == 32);
20098         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20099         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
20100 }
20101
20102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
20103         LDKUnsignedChannelUpdate this_ptr_conv;
20104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20105         this_ptr_conv.is_owned = false;
20106         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
20107         return ret_val;
20108 }
20109
20110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20111         LDKUnsignedChannelUpdate this_ptr_conv;
20112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20113         this_ptr_conv.is_owned = false;
20114         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
20115 }
20116
20117 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
20118         LDKUnsignedChannelUpdate this_ptr_conv;
20119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20120         this_ptr_conv.is_owned = false;
20121         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
20122         return ret_val;
20123 }
20124
20125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20126         LDKUnsignedChannelUpdate this_ptr_conv;
20127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20128         this_ptr_conv.is_owned = false;
20129         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
20130 }
20131
20132 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
20133         LDKUnsignedChannelUpdate this_ptr_conv;
20134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20135         this_ptr_conv.is_owned = false;
20136         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
20137         return ret_val;
20138 }
20139
20140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
20141         LDKUnsignedChannelUpdate this_ptr_conv;
20142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20143         this_ptr_conv.is_owned = false;
20144         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
20145 }
20146
20147 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20148         LDKUnsignedChannelUpdate this_ptr_conv;
20149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20150         this_ptr_conv.is_owned = false;
20151         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
20152         return ret_val;
20153 }
20154
20155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20156         LDKUnsignedChannelUpdate this_ptr_conv;
20157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20158         this_ptr_conv.is_owned = false;
20159         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
20160 }
20161
20162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20163         LDKUnsignedChannelUpdate this_ptr_conv;
20164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20165         this_ptr_conv.is_owned = false;
20166         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
20167         return ret_val;
20168 }
20169
20170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20171         LDKUnsignedChannelUpdate this_ptr_conv;
20172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20173         this_ptr_conv.is_owned = false;
20174         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
20175 }
20176
20177 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20178         LDKUnsignedChannelUpdate this_ptr_conv;
20179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20180         this_ptr_conv.is_owned = false;
20181         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
20182         return ret_val;
20183 }
20184
20185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20186         LDKUnsignedChannelUpdate this_ptr_conv;
20187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20188         this_ptr_conv.is_owned = false;
20189         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
20190 }
20191
20192 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
20193         LDKUnsignedChannelUpdate this_ptr_conv;
20194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20195         this_ptr_conv.is_owned = false;
20196         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
20197         return ret_val;
20198 }
20199
20200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20201         LDKUnsignedChannelUpdate this_ptr_conv;
20202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20203         this_ptr_conv.is_owned = false;
20204         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
20205 }
20206
20207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20208         LDKUnsignedChannelUpdate orig_conv;
20209         orig_conv.inner = (void*)(orig & (~1));
20210         orig_conv.is_owned = false;
20211         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
20212         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20213         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20214         uint64_t ret_ref = (uint64_t)ret_var.inner;
20215         if (ret_var.is_owned) {
20216                 ret_ref |= 1;
20217         }
20218         return ret_ref;
20219 }
20220
20221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20222         LDKChannelUpdate this_obj_conv;
20223         this_obj_conv.inner = (void*)(this_obj & (~1));
20224         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20225         ChannelUpdate_free(this_obj_conv);
20226 }
20227
20228 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
20229         LDKChannelUpdate this_ptr_conv;
20230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20231         this_ptr_conv.is_owned = false;
20232         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
20233         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
20234         return ret_arr;
20235 }
20236
20237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20238         LDKChannelUpdate this_ptr_conv;
20239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20240         this_ptr_conv.is_owned = false;
20241         LDKSignature val_ref;
20242         CHECK((*env)->GetArrayLength(env, val) == 64);
20243         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
20244         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
20245 }
20246
20247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
20248         LDKChannelUpdate this_ptr_conv;
20249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20250         this_ptr_conv.is_owned = false;
20251         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
20252         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20253         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20254         uint64_t ret_ref = (uint64_t)ret_var.inner;
20255         if (ret_var.is_owned) {
20256                 ret_ref |= 1;
20257         }
20258         return ret_ref;
20259 }
20260
20261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20262         LDKChannelUpdate this_ptr_conv;
20263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20264         this_ptr_conv.is_owned = false;
20265         LDKUnsignedChannelUpdate val_conv;
20266         val_conv.inner = (void*)(val & (~1));
20267         val_conv.is_owned = (val & 1) || (val == 0);
20268         val_conv = UnsignedChannelUpdate_clone(&val_conv);
20269         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
20270 }
20271
20272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
20273         LDKSignature signature_arg_ref;
20274         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
20275         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
20276         LDKUnsignedChannelUpdate contents_arg_conv;
20277         contents_arg_conv.inner = (void*)(contents_arg & (~1));
20278         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
20279         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
20280         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
20281         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20282         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20283         uint64_t ret_ref = (uint64_t)ret_var.inner;
20284         if (ret_var.is_owned) {
20285                 ret_ref |= 1;
20286         }
20287         return ret_ref;
20288 }
20289
20290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20291         LDKChannelUpdate orig_conv;
20292         orig_conv.inner = (void*)(orig & (~1));
20293         orig_conv.is_owned = false;
20294         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
20295         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20296         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20297         uint64_t ret_ref = (uint64_t)ret_var.inner;
20298         if (ret_var.is_owned) {
20299                 ret_ref |= 1;
20300         }
20301         return ret_ref;
20302 }
20303
20304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20305         LDKQueryChannelRange this_obj_conv;
20306         this_obj_conv.inner = (void*)(this_obj & (~1));
20307         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20308         QueryChannelRange_free(this_obj_conv);
20309 }
20310
20311 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20312         LDKQueryChannelRange 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, 32);
20316         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
20317         return ret_arr;
20318 }
20319
20320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20321         LDKQueryChannelRange this_ptr_conv;
20322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20323         this_ptr_conv.is_owned = false;
20324         LDKThirtyTwoBytes val_ref;
20325         CHECK((*env)->GetArrayLength(env, val) == 32);
20326         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20327         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
20328 }
20329
20330 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
20331         LDKQueryChannelRange this_ptr_conv;
20332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20333         this_ptr_conv.is_owned = false;
20334         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
20335         return ret_val;
20336 }
20337
20338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20339         LDKQueryChannelRange this_ptr_conv;
20340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20341         this_ptr_conv.is_owned = false;
20342         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
20343 }
20344
20345 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
20346         LDKQueryChannelRange this_ptr_conv;
20347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20348         this_ptr_conv.is_owned = false;
20349         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
20350         return ret_val;
20351 }
20352
20353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20354         LDKQueryChannelRange this_ptr_conv;
20355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20356         this_ptr_conv.is_owned = false;
20357         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
20358 }
20359
20360 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) {
20361         LDKThirtyTwoBytes chain_hash_arg_ref;
20362         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20363         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20364         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
20365         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20366         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20367         uint64_t ret_ref = (uint64_t)ret_var.inner;
20368         if (ret_var.is_owned) {
20369                 ret_ref |= 1;
20370         }
20371         return ret_ref;
20372 }
20373
20374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20375         LDKQueryChannelRange orig_conv;
20376         orig_conv.inner = (void*)(orig & (~1));
20377         orig_conv.is_owned = false;
20378         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
20379         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20380         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20381         uint64_t ret_ref = (uint64_t)ret_var.inner;
20382         if (ret_var.is_owned) {
20383                 ret_ref |= 1;
20384         }
20385         return ret_ref;
20386 }
20387
20388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20389         LDKReplyChannelRange this_obj_conv;
20390         this_obj_conv.inner = (void*)(this_obj & (~1));
20391         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20392         ReplyChannelRange_free(this_obj_conv);
20393 }
20394
20395 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20396         LDKReplyChannelRange this_ptr_conv;
20397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20398         this_ptr_conv.is_owned = false;
20399         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20400         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
20401         return ret_arr;
20402 }
20403
20404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20405         LDKReplyChannelRange this_ptr_conv;
20406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20407         this_ptr_conv.is_owned = false;
20408         LDKThirtyTwoBytes val_ref;
20409         CHECK((*env)->GetArrayLength(env, val) == 32);
20410         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20411         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
20412 }
20413
20414 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
20415         LDKReplyChannelRange this_ptr_conv;
20416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20417         this_ptr_conv.is_owned = false;
20418         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
20419         return ret_val;
20420 }
20421
20422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20423         LDKReplyChannelRange this_ptr_conv;
20424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20425         this_ptr_conv.is_owned = false;
20426         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
20427 }
20428
20429 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
20430         LDKReplyChannelRange this_ptr_conv;
20431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20432         this_ptr_conv.is_owned = false;
20433         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
20434         return ret_val;
20435 }
20436
20437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20438         LDKReplyChannelRange this_ptr_conv;
20439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20440         this_ptr_conv.is_owned = false;
20441         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
20442 }
20443
20444 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
20445         LDKReplyChannelRange this_ptr_conv;
20446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20447         this_ptr_conv.is_owned = false;
20448         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
20449         return ret_val;
20450 }
20451
20452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20453         LDKReplyChannelRange this_ptr_conv;
20454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20455         this_ptr_conv.is_owned = false;
20456         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
20457 }
20458
20459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20460         LDKReplyChannelRange this_ptr_conv;
20461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20462         this_ptr_conv.is_owned = false;
20463         LDKCVec_u64Z val_constr;
20464         val_constr.datalen = (*env)->GetArrayLength(env, val);
20465         if (val_constr.datalen > 0)
20466                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20467         else
20468                 val_constr.data = NULL;
20469         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20470         for (size_t g = 0; g < val_constr.datalen; g++) {
20471                 int64_t val_conv_6 = val_vals[g];
20472                 val_constr.data[g] = val_conv_6;
20473         }
20474         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20475         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
20476 }
20477
20478 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) {
20479         LDKThirtyTwoBytes chain_hash_arg_ref;
20480         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20481         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20482         LDKCVec_u64Z short_channel_ids_arg_constr;
20483         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
20484         if (short_channel_ids_arg_constr.datalen > 0)
20485                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20486         else
20487                 short_channel_ids_arg_constr.data = NULL;
20488         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
20489         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
20490                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
20491                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
20492         }
20493         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
20494         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
20495         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20496         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20497         uint64_t ret_ref = (uint64_t)ret_var.inner;
20498         if (ret_var.is_owned) {
20499                 ret_ref |= 1;
20500         }
20501         return ret_ref;
20502 }
20503
20504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20505         LDKReplyChannelRange orig_conv;
20506         orig_conv.inner = (void*)(orig & (~1));
20507         orig_conv.is_owned = false;
20508         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
20509         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20510         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20511         uint64_t ret_ref = (uint64_t)ret_var.inner;
20512         if (ret_var.is_owned) {
20513                 ret_ref |= 1;
20514         }
20515         return ret_ref;
20516 }
20517
20518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20519         LDKQueryShortChannelIds this_obj_conv;
20520         this_obj_conv.inner = (void*)(this_obj & (~1));
20521         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20522         QueryShortChannelIds_free(this_obj_conv);
20523 }
20524
20525 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20526         LDKQueryShortChannelIds this_ptr_conv;
20527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20528         this_ptr_conv.is_owned = false;
20529         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20530         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
20531         return ret_arr;
20532 }
20533
20534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20535         LDKQueryShortChannelIds this_ptr_conv;
20536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20537         this_ptr_conv.is_owned = false;
20538         LDKThirtyTwoBytes val_ref;
20539         CHECK((*env)->GetArrayLength(env, val) == 32);
20540         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20541         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
20542 }
20543
20544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20545         LDKQueryShortChannelIds this_ptr_conv;
20546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20547         this_ptr_conv.is_owned = false;
20548         LDKCVec_u64Z val_constr;
20549         val_constr.datalen = (*env)->GetArrayLength(env, val);
20550         if (val_constr.datalen > 0)
20551                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20552         else
20553                 val_constr.data = NULL;
20554         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20555         for (size_t g = 0; g < val_constr.datalen; g++) {
20556                 int64_t val_conv_6 = val_vals[g];
20557                 val_constr.data[g] = val_conv_6;
20558         }
20559         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20560         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
20561 }
20562
20563 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) {
20564         LDKThirtyTwoBytes chain_hash_arg_ref;
20565         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20566         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20567         LDKCVec_u64Z short_channel_ids_arg_constr;
20568         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
20569         if (short_channel_ids_arg_constr.datalen > 0)
20570                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20571         else
20572                 short_channel_ids_arg_constr.data = NULL;
20573         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
20574         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
20575                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
20576                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
20577         }
20578         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
20579         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
20580         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20581         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20582         uint64_t ret_ref = (uint64_t)ret_var.inner;
20583         if (ret_var.is_owned) {
20584                 ret_ref |= 1;
20585         }
20586         return ret_ref;
20587 }
20588
20589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20590         LDKQueryShortChannelIds orig_conv;
20591         orig_conv.inner = (void*)(orig & (~1));
20592         orig_conv.is_owned = false;
20593         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
20594         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20595         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20596         uint64_t ret_ref = (uint64_t)ret_var.inner;
20597         if (ret_var.is_owned) {
20598                 ret_ref |= 1;
20599         }
20600         return ret_ref;
20601 }
20602
20603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20604         LDKReplyShortChannelIdsEnd this_obj_conv;
20605         this_obj_conv.inner = (void*)(this_obj & (~1));
20606         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20607         ReplyShortChannelIdsEnd_free(this_obj_conv);
20608 }
20609
20610 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20611         LDKReplyShortChannelIdsEnd this_ptr_conv;
20612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20613         this_ptr_conv.is_owned = false;
20614         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20615         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
20616         return ret_arr;
20617 }
20618
20619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20620         LDKReplyShortChannelIdsEnd this_ptr_conv;
20621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20622         this_ptr_conv.is_owned = false;
20623         LDKThirtyTwoBytes val_ref;
20624         CHECK((*env)->GetArrayLength(env, val) == 32);
20625         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20626         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
20627 }
20628
20629 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
20630         LDKReplyShortChannelIdsEnd this_ptr_conv;
20631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20632         this_ptr_conv.is_owned = false;
20633         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
20634         return ret_val;
20635 }
20636
20637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20638         LDKReplyShortChannelIdsEnd this_ptr_conv;
20639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20640         this_ptr_conv.is_owned = false;
20641         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
20642 }
20643
20644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
20645         LDKThirtyTwoBytes chain_hash_arg_ref;
20646         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20647         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20648         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
20649         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20650         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20651         uint64_t ret_ref = (uint64_t)ret_var.inner;
20652         if (ret_var.is_owned) {
20653                 ret_ref |= 1;
20654         }
20655         return ret_ref;
20656 }
20657
20658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20659         LDKReplyShortChannelIdsEnd orig_conv;
20660         orig_conv.inner = (void*)(orig & (~1));
20661         orig_conv.is_owned = false;
20662         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
20663         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20664         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20665         uint64_t ret_ref = (uint64_t)ret_var.inner;
20666         if (ret_var.is_owned) {
20667                 ret_ref |= 1;
20668         }
20669         return ret_ref;
20670 }
20671
20672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20673         LDKGossipTimestampFilter this_obj_conv;
20674         this_obj_conv.inner = (void*)(this_obj & (~1));
20675         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20676         GossipTimestampFilter_free(this_obj_conv);
20677 }
20678
20679 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
20680         LDKGossipTimestampFilter this_ptr_conv;
20681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20682         this_ptr_conv.is_owned = false;
20683         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
20684         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
20685         return ret_arr;
20686 }
20687
20688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
20689         LDKGossipTimestampFilter this_ptr_conv;
20690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20691         this_ptr_conv.is_owned = false;
20692         LDKThirtyTwoBytes val_ref;
20693         CHECK((*env)->GetArrayLength(env, val) == 32);
20694         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
20695         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
20696 }
20697
20698 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
20699         LDKGossipTimestampFilter this_ptr_conv;
20700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20701         this_ptr_conv.is_owned = false;
20702         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
20703         return ret_val;
20704 }
20705
20706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20707         LDKGossipTimestampFilter this_ptr_conv;
20708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20709         this_ptr_conv.is_owned = false;
20710         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
20711 }
20712
20713 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
20714         LDKGossipTimestampFilter this_ptr_conv;
20715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20716         this_ptr_conv.is_owned = false;
20717         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
20718         return ret_val;
20719 }
20720
20721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20722         LDKGossipTimestampFilter this_ptr_conv;
20723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20724         this_ptr_conv.is_owned = false;
20725         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
20726 }
20727
20728 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) {
20729         LDKThirtyTwoBytes chain_hash_arg_ref;
20730         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
20731         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
20732         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
20733         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20734         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20735         uint64_t ret_ref = (uint64_t)ret_var.inner;
20736         if (ret_var.is_owned) {
20737                 ret_ref |= 1;
20738         }
20739         return ret_ref;
20740 }
20741
20742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20743         LDKGossipTimestampFilter orig_conv;
20744         orig_conv.inner = (void*)(orig & (~1));
20745         orig_conv.is_owned = false;
20746         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
20747         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20748         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20749         uint64_t ret_ref = (uint64_t)ret_var.inner;
20750         if (ret_var.is_owned) {
20751                 ret_ref |= 1;
20752         }
20753         return ret_ref;
20754 }
20755
20756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20757         if ((this_ptr & 1) != 0) return;
20758         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
20759         FREE((void*)this_ptr);
20760         ErrorAction_free(this_ptr_conv);
20761 }
20762
20763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20764         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
20765         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20766         *ret_copy = ErrorAction_clone(orig_conv);
20767         uint64_t ret_ref = (uint64_t)ret_copy;
20768         return ret_ref;
20769 }
20770
20771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
20772         LDKErrorMessage msg_conv;
20773         msg_conv.inner = (void*)(msg & (~1));
20774         msg_conv.is_owned = (msg & 1) || (msg == 0);
20775         msg_conv = ErrorMessage_clone(&msg_conv);
20776         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20777         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
20778         uint64_t ret_ref = (uint64_t)ret_copy;
20779         return ret_ref;
20780 }
20781
20782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
20783         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20784         *ret_copy = ErrorAction_ignore_error();
20785         uint64_t ret_ref = (uint64_t)ret_copy;
20786         return ret_ref;
20787 }
20788
20789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
20790         LDKLevel a_conv = LDKLevel_from_java(env, a);
20791         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20792         *ret_copy = ErrorAction_ignore_and_log(a_conv);
20793         uint64_t ret_ref = (uint64_t)ret_copy;
20794         return ret_ref;
20795 }
20796
20797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
20798         LDKErrorMessage msg_conv;
20799         msg_conv.inner = (void*)(msg & (~1));
20800         msg_conv.is_owned = (msg & 1) || (msg == 0);
20801         msg_conv = ErrorMessage_clone(&msg_conv);
20802         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20803         *ret_copy = ErrorAction_send_error_message(msg_conv);
20804         uint64_t ret_ref = (uint64_t)ret_copy;
20805         return ret_ref;
20806 }
20807
20808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20809         LDKLightningError this_obj_conv;
20810         this_obj_conv.inner = (void*)(this_obj & (~1));
20811         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20812         LightningError_free(this_obj_conv);
20813 }
20814
20815 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
20816         LDKLightningError this_ptr_conv;
20817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20818         this_ptr_conv.is_owned = false;
20819         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
20820         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20821         Str_free(ret_str);
20822         return ret_conv;
20823 }
20824
20825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20826         LDKLightningError this_ptr_conv;
20827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20828         this_ptr_conv.is_owned = false;
20829         LDKStr val_conv = java_to_owned_str(env, val);
20830         LightningError_set_err(&this_ptr_conv, val_conv);
20831 }
20832
20833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
20834         LDKLightningError this_ptr_conv;
20835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20836         this_ptr_conv.is_owned = false;
20837         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
20838         *ret_copy = LightningError_get_action(&this_ptr_conv);
20839         uint64_t ret_ref = (uint64_t)ret_copy;
20840         return ret_ref;
20841 }
20842
20843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20844         LDKLightningError this_ptr_conv;
20845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20846         this_ptr_conv.is_owned = false;
20847         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
20848         LightningError_set_action(&this_ptr_conv, val_conv);
20849 }
20850
20851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
20852         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
20853         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
20854         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
20855         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20856         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20857         uint64_t ret_ref = (uint64_t)ret_var.inner;
20858         if (ret_var.is_owned) {
20859                 ret_ref |= 1;
20860         }
20861         return ret_ref;
20862 }
20863
20864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20865         LDKLightningError orig_conv;
20866         orig_conv.inner = (void*)(orig & (~1));
20867         orig_conv.is_owned = false;
20868         LDKLightningError ret_var = LightningError_clone(&orig_conv);
20869         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20870         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20871         uint64_t ret_ref = (uint64_t)ret_var.inner;
20872         if (ret_var.is_owned) {
20873                 ret_ref |= 1;
20874         }
20875         return ret_ref;
20876 }
20877
20878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20879         LDKCommitmentUpdate this_obj_conv;
20880         this_obj_conv.inner = (void*)(this_obj & (~1));
20881         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20882         CommitmentUpdate_free(this_obj_conv);
20883 }
20884
20885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20886         LDKCommitmentUpdate this_ptr_conv;
20887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20888         this_ptr_conv.is_owned = false;
20889         LDKCVec_UpdateAddHTLCZ val_constr;
20890         val_constr.datalen = (*env)->GetArrayLength(env, val);
20891         if (val_constr.datalen > 0)
20892                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
20893         else
20894                 val_constr.data = NULL;
20895         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20896         for (size_t p = 0; p < val_constr.datalen; p++) {
20897                 int64_t val_conv_15 = val_vals[p];
20898                 LDKUpdateAddHTLC val_conv_15_conv;
20899                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
20900                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
20901                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
20902                 val_constr.data[p] = val_conv_15_conv;
20903         }
20904         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20905         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
20906 }
20907
20908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20909         LDKCommitmentUpdate this_ptr_conv;
20910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20911         this_ptr_conv.is_owned = false;
20912         LDKCVec_UpdateFulfillHTLCZ val_constr;
20913         val_constr.datalen = (*env)->GetArrayLength(env, val);
20914         if (val_constr.datalen > 0)
20915                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
20916         else
20917                 val_constr.data = NULL;
20918         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20919         for (size_t t = 0; t < val_constr.datalen; t++) {
20920                 int64_t val_conv_19 = val_vals[t];
20921                 LDKUpdateFulfillHTLC val_conv_19_conv;
20922                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
20923                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
20924                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
20925                 val_constr.data[t] = val_conv_19_conv;
20926         }
20927         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20928         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
20929 }
20930
20931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
20932         LDKCommitmentUpdate this_ptr_conv;
20933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20934         this_ptr_conv.is_owned = false;
20935         LDKCVec_UpdateFailHTLCZ val_constr;
20936         val_constr.datalen = (*env)->GetArrayLength(env, val);
20937         if (val_constr.datalen > 0)
20938                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
20939         else
20940                 val_constr.data = NULL;
20941         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20942         for (size_t q = 0; q < val_constr.datalen; q++) {
20943                 int64_t val_conv_16 = val_vals[q];
20944                 LDKUpdateFailHTLC val_conv_16_conv;
20945                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
20946                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
20947                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
20948                 val_constr.data[q] = val_conv_16_conv;
20949         }
20950         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20951         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
20952 }
20953
20954 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) {
20955         LDKCommitmentUpdate this_ptr_conv;
20956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20957         this_ptr_conv.is_owned = false;
20958         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
20959         val_constr.datalen = (*env)->GetArrayLength(env, val);
20960         if (val_constr.datalen > 0)
20961                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
20962         else
20963                 val_constr.data = NULL;
20964         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
20965         for (size_t z = 0; z < val_constr.datalen; z++) {
20966                 int64_t val_conv_25 = val_vals[z];
20967                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
20968                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
20969                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
20970                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
20971                 val_constr.data[z] = val_conv_25_conv;
20972         }
20973         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
20974         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
20975 }
20976
20977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
20978         LDKCommitmentUpdate this_ptr_conv;
20979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20980         this_ptr_conv.is_owned = false;
20981         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
20982         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20983         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20984         uint64_t ret_ref = (uint64_t)ret_var.inner;
20985         if (ret_var.is_owned) {
20986                 ret_ref |= 1;
20987         }
20988         return ret_ref;
20989 }
20990
20991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20992         LDKCommitmentUpdate this_ptr_conv;
20993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20994         this_ptr_conv.is_owned = false;
20995         LDKUpdateFee val_conv;
20996         val_conv.inner = (void*)(val & (~1));
20997         val_conv.is_owned = (val & 1) || (val == 0);
20998         val_conv = UpdateFee_clone(&val_conv);
20999         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
21000 }
21001
21002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
21003         LDKCommitmentUpdate this_ptr_conv;
21004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21005         this_ptr_conv.is_owned = false;
21006         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
21007         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21008         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21009         uint64_t ret_ref = (uint64_t)ret_var.inner;
21010         if (ret_var.is_owned) {
21011                 ret_ref |= 1;
21012         }
21013         return ret_ref;
21014 }
21015
21016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21017         LDKCommitmentUpdate this_ptr_conv;
21018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21019         this_ptr_conv.is_owned = false;
21020         LDKCommitmentSigned val_conv;
21021         val_conv.inner = (void*)(val & (~1));
21022         val_conv.is_owned = (val & 1) || (val == 0);
21023         val_conv = CommitmentSigned_clone(&val_conv);
21024         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
21025 }
21026
21027 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) {
21028         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
21029         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
21030         if (update_add_htlcs_arg_constr.datalen > 0)
21031                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
21032         else
21033                 update_add_htlcs_arg_constr.data = NULL;
21034         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
21035         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
21036                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
21037                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
21038                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
21039                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
21040                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
21041                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
21042         }
21043         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
21044         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
21045         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
21046         if (update_fulfill_htlcs_arg_constr.datalen > 0)
21047                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
21048         else
21049                 update_fulfill_htlcs_arg_constr.data = NULL;
21050         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
21051         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
21052                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
21053                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
21054                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
21055                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
21056                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
21057                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
21058         }
21059         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
21060         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
21061         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
21062         if (update_fail_htlcs_arg_constr.datalen > 0)
21063                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
21064         else
21065                 update_fail_htlcs_arg_constr.data = NULL;
21066         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
21067         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
21068                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
21069                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
21070                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
21071                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
21072                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
21073                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
21074         }
21075         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
21076         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
21077         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
21078         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
21079                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
21080         else
21081                 update_fail_malformed_htlcs_arg_constr.data = NULL;
21082         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
21083         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
21084                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
21085                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
21086                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
21087                 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);
21088                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
21089                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
21090         }
21091         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
21092         LDKUpdateFee update_fee_arg_conv;
21093         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
21094         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
21095         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
21096         LDKCommitmentSigned commitment_signed_arg_conv;
21097         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
21098         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
21099         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
21100         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);
21101         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21102         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21103         uint64_t ret_ref = (uint64_t)ret_var.inner;
21104         if (ret_var.is_owned) {
21105                 ret_ref |= 1;
21106         }
21107         return ret_ref;
21108 }
21109
21110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21111         LDKCommitmentUpdate orig_conv;
21112         orig_conv.inner = (void*)(orig & (~1));
21113         orig_conv.is_owned = false;
21114         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
21115         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21116         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21117         uint64_t ret_ref = (uint64_t)ret_var.inner;
21118         if (ret_var.is_owned) {
21119                 ret_ref |= 1;
21120         }
21121         return ret_ref;
21122 }
21123
21124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21125         if ((this_ptr & 1) != 0) return;
21126         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
21127         FREE((void*)this_ptr);
21128         HTLCFailChannelUpdate_free(this_ptr_conv);
21129 }
21130
21131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21132         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
21133         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21134         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
21135         uint64_t ret_ref = (uint64_t)ret_copy;
21136         return ret_ref;
21137 }
21138
21139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
21140         LDKChannelUpdate msg_conv;
21141         msg_conv.inner = (void*)(msg & (~1));
21142         msg_conv.is_owned = (msg & 1) || (msg == 0);
21143         msg_conv = ChannelUpdate_clone(&msg_conv);
21144         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21145         *ret_copy = HTLCFailChannelUpdate_channel_update_message(msg_conv);
21146         uint64_t ret_ref = (uint64_t)ret_copy;
21147         return ret_ref;
21148 }
21149
21150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
21151         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21152         *ret_copy = HTLCFailChannelUpdate_channel_closed(short_channel_id, is_permanent);
21153         uint64_t ret_ref = (uint64_t)ret_copy;
21154         return ret_ref;
21155 }
21156
21157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCFailChannelUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
21158         LDKPublicKey node_id_ref;
21159         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21160         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21161         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
21162         *ret_copy = HTLCFailChannelUpdate_node_failure(node_id_ref, is_permanent);
21163         uint64_t ret_ref = (uint64_t)ret_copy;
21164         return ret_ref;
21165 }
21166
21167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21168         if ((this_ptr & 1) != 0) return;
21169         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
21170         FREE((void*)this_ptr);
21171         ChannelMessageHandler_free(this_ptr_conv);
21172 }
21173
21174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21175         if ((this_ptr & 1) != 0) return;
21176         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
21177         FREE((void*)this_ptr);
21178         RoutingMessageHandler_free(this_ptr_conv);
21179 }
21180
21181 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
21182         LDKAcceptChannel obj_conv;
21183         obj_conv.inner = (void*)(obj & (~1));
21184         obj_conv.is_owned = false;
21185         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
21186         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21187         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21188         CVec_u8Z_free(ret_var);
21189         return ret_arr;
21190 }
21191
21192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21193         LDKu8slice ser_ref;
21194         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21195         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21196         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21197         *ret_conv = AcceptChannel_read(ser_ref);
21198         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21199         return (uint64_t)ret_conv;
21200 }
21201
21202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
21203         LDKAnnouncementSignatures obj_conv;
21204         obj_conv.inner = (void*)(obj & (~1));
21205         obj_conv.is_owned = false;
21206         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
21207         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21208         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21209         CVec_u8Z_free(ret_var);
21210         return ret_arr;
21211 }
21212
21213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21214         LDKu8slice ser_ref;
21215         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21216         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21217         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21218         *ret_conv = AnnouncementSignatures_read(ser_ref);
21219         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21220         return (uint64_t)ret_conv;
21221 }
21222
21223 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
21224         LDKChannelReestablish obj_conv;
21225         obj_conv.inner = (void*)(obj & (~1));
21226         obj_conv.is_owned = false;
21227         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
21228         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21229         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21230         CVec_u8Z_free(ret_var);
21231         return ret_arr;
21232 }
21233
21234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21235         LDKu8slice ser_ref;
21236         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21237         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21238         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21239         *ret_conv = ChannelReestablish_read(ser_ref);
21240         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21241         return (uint64_t)ret_conv;
21242 }
21243
21244 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
21245         LDKClosingSigned obj_conv;
21246         obj_conv.inner = (void*)(obj & (~1));
21247         obj_conv.is_owned = false;
21248         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
21249         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21250         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21251         CVec_u8Z_free(ret_var);
21252         return ret_arr;
21253 }
21254
21255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21256         LDKu8slice ser_ref;
21257         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21258         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21259         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21260         *ret_conv = ClosingSigned_read(ser_ref);
21261         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21262         return (uint64_t)ret_conv;
21263 }
21264
21265 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
21266         LDKCommitmentSigned obj_conv;
21267         obj_conv.inner = (void*)(obj & (~1));
21268         obj_conv.is_owned = false;
21269         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
21270         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21271         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21272         CVec_u8Z_free(ret_var);
21273         return ret_arr;
21274 }
21275
21276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21277         LDKu8slice ser_ref;
21278         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21279         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21280         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21281         *ret_conv = CommitmentSigned_read(ser_ref);
21282         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21283         return (uint64_t)ret_conv;
21284 }
21285
21286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
21287         LDKFundingCreated obj_conv;
21288         obj_conv.inner = (void*)(obj & (~1));
21289         obj_conv.is_owned = false;
21290         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
21291         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21292         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21293         CVec_u8Z_free(ret_var);
21294         return ret_arr;
21295 }
21296
21297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21298         LDKu8slice ser_ref;
21299         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21300         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21301         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21302         *ret_conv = FundingCreated_read(ser_ref);
21303         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21304         return (uint64_t)ret_conv;
21305 }
21306
21307 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
21308         LDKFundingSigned obj_conv;
21309         obj_conv.inner = (void*)(obj & (~1));
21310         obj_conv.is_owned = false;
21311         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
21312         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21313         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21314         CVec_u8Z_free(ret_var);
21315         return ret_arr;
21316 }
21317
21318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21319         LDKu8slice ser_ref;
21320         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21321         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21322         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21323         *ret_conv = FundingSigned_read(ser_ref);
21324         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21325         return (uint64_t)ret_conv;
21326 }
21327
21328 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
21329         LDKFundingLocked obj_conv;
21330         obj_conv.inner = (void*)(obj & (~1));
21331         obj_conv.is_owned = false;
21332         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
21333         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21334         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21335         CVec_u8Z_free(ret_var);
21336         return ret_arr;
21337 }
21338
21339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21340         LDKu8slice ser_ref;
21341         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21342         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21343         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21344         *ret_conv = FundingLocked_read(ser_ref);
21345         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21346         return (uint64_t)ret_conv;
21347 }
21348
21349 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
21350         LDKInit obj_conv;
21351         obj_conv.inner = (void*)(obj & (~1));
21352         obj_conv.is_owned = false;
21353         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
21354         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21355         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21356         CVec_u8Z_free(ret_var);
21357         return ret_arr;
21358 }
21359
21360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21361         LDKu8slice ser_ref;
21362         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21363         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21364         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21365         *ret_conv = Init_read(ser_ref);
21366         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21367         return (uint64_t)ret_conv;
21368 }
21369
21370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
21371         LDKOpenChannel obj_conv;
21372         obj_conv.inner = (void*)(obj & (~1));
21373         obj_conv.is_owned = false;
21374         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
21375         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21376         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21377         CVec_u8Z_free(ret_var);
21378         return ret_arr;
21379 }
21380
21381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21382         LDKu8slice ser_ref;
21383         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21384         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21385         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21386         *ret_conv = OpenChannel_read(ser_ref);
21387         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21388         return (uint64_t)ret_conv;
21389 }
21390
21391 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
21392         LDKRevokeAndACK obj_conv;
21393         obj_conv.inner = (void*)(obj & (~1));
21394         obj_conv.is_owned = false;
21395         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
21396         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21397         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21398         CVec_u8Z_free(ret_var);
21399         return ret_arr;
21400 }
21401
21402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21403         LDKu8slice ser_ref;
21404         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21405         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21406         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21407         *ret_conv = RevokeAndACK_read(ser_ref);
21408         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21409         return (uint64_t)ret_conv;
21410 }
21411
21412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
21413         LDKShutdown obj_conv;
21414         obj_conv.inner = (void*)(obj & (~1));
21415         obj_conv.is_owned = false;
21416         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
21417         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21418         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21419         CVec_u8Z_free(ret_var);
21420         return ret_arr;
21421 }
21422
21423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21424         LDKu8slice ser_ref;
21425         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21426         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21427         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21428         *ret_conv = Shutdown_read(ser_ref);
21429         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21430         return (uint64_t)ret_conv;
21431 }
21432
21433 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21434         LDKUpdateFailHTLC obj_conv;
21435         obj_conv.inner = (void*)(obj & (~1));
21436         obj_conv.is_owned = false;
21437         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
21438         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21439         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21440         CVec_u8Z_free(ret_var);
21441         return ret_arr;
21442 }
21443
21444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21445         LDKu8slice ser_ref;
21446         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21447         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21448         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21449         *ret_conv = UpdateFailHTLC_read(ser_ref);
21450         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21451         return (uint64_t)ret_conv;
21452 }
21453
21454 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21455         LDKUpdateFailMalformedHTLC obj_conv;
21456         obj_conv.inner = (void*)(obj & (~1));
21457         obj_conv.is_owned = false;
21458         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
21459         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21460         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21461         CVec_u8Z_free(ret_var);
21462         return ret_arr;
21463 }
21464
21465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21466         LDKu8slice ser_ref;
21467         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21468         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21469         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21470         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
21471         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21472         return (uint64_t)ret_conv;
21473 }
21474
21475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
21476         LDKUpdateFee obj_conv;
21477         obj_conv.inner = (void*)(obj & (~1));
21478         obj_conv.is_owned = false;
21479         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
21480         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21481         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21482         CVec_u8Z_free(ret_var);
21483         return ret_arr;
21484 }
21485
21486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21487         LDKu8slice ser_ref;
21488         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21489         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21490         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21491         *ret_conv = UpdateFee_read(ser_ref);
21492         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21493         return (uint64_t)ret_conv;
21494 }
21495
21496 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21497         LDKUpdateFulfillHTLC obj_conv;
21498         obj_conv.inner = (void*)(obj & (~1));
21499         obj_conv.is_owned = false;
21500         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
21501         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21502         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21503         CVec_u8Z_free(ret_var);
21504         return ret_arr;
21505 }
21506
21507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21508         LDKu8slice ser_ref;
21509         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21510         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21511         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
21512         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
21513         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21514         return (uint64_t)ret_conv;
21515 }
21516
21517 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
21518         LDKUpdateAddHTLC obj_conv;
21519         obj_conv.inner = (void*)(obj & (~1));
21520         obj_conv.is_owned = false;
21521         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
21522         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21523         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21524         CVec_u8Z_free(ret_var);
21525         return ret_arr;
21526 }
21527
21528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21529         LDKu8slice ser_ref;
21530         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21531         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21532         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
21533         *ret_conv = UpdateAddHTLC_read(ser_ref);
21534         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21535         return (uint64_t)ret_conv;
21536 }
21537
21538 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
21539         LDKPing obj_conv;
21540         obj_conv.inner = (void*)(obj & (~1));
21541         obj_conv.is_owned = false;
21542         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
21543         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21544         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21545         CVec_u8Z_free(ret_var);
21546         return ret_arr;
21547 }
21548
21549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21550         LDKu8slice ser_ref;
21551         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21552         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21553         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
21554         *ret_conv = Ping_read(ser_ref);
21555         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21556         return (uint64_t)ret_conv;
21557 }
21558
21559 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
21560         LDKPong obj_conv;
21561         obj_conv.inner = (void*)(obj & (~1));
21562         obj_conv.is_owned = false;
21563         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
21564         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21565         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21566         CVec_u8Z_free(ret_var);
21567         return ret_arr;
21568 }
21569
21570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21571         LDKu8slice ser_ref;
21572         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21573         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21574         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
21575         *ret_conv = Pong_read(ser_ref);
21576         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21577         return (uint64_t)ret_conv;
21578 }
21579
21580 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21581         LDKUnsignedChannelAnnouncement obj_conv;
21582         obj_conv.inner = (void*)(obj & (~1));
21583         obj_conv.is_owned = false;
21584         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
21585         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21586         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21587         CVec_u8Z_free(ret_var);
21588         return ret_arr;
21589 }
21590
21591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21592         LDKu8slice ser_ref;
21593         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21594         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21595         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
21596         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
21597         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21598         return (uint64_t)ret_conv;
21599 }
21600
21601 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21602         LDKChannelAnnouncement obj_conv;
21603         obj_conv.inner = (void*)(obj & (~1));
21604         obj_conv.is_owned = false;
21605         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
21606         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21607         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21608         CVec_u8Z_free(ret_var);
21609         return ret_arr;
21610 }
21611
21612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21613         LDKu8slice ser_ref;
21614         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21615         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21616         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
21617         *ret_conv = ChannelAnnouncement_read(ser_ref);
21618         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21619         return (uint64_t)ret_conv;
21620 }
21621
21622 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
21623         LDKUnsignedChannelUpdate obj_conv;
21624         obj_conv.inner = (void*)(obj & (~1));
21625         obj_conv.is_owned = false;
21626         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
21627         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21628         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21629         CVec_u8Z_free(ret_var);
21630         return ret_arr;
21631 }
21632
21633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21634         LDKu8slice ser_ref;
21635         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21636         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21637         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
21638         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
21639         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21640         return (uint64_t)ret_conv;
21641 }
21642
21643 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
21644         LDKChannelUpdate obj_conv;
21645         obj_conv.inner = (void*)(obj & (~1));
21646         obj_conv.is_owned = false;
21647         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
21648         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21649         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21650         CVec_u8Z_free(ret_var);
21651         return ret_arr;
21652 }
21653
21654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21655         LDKu8slice ser_ref;
21656         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21657         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21658         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
21659         *ret_conv = ChannelUpdate_read(ser_ref);
21660         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21661         return (uint64_t)ret_conv;
21662 }
21663
21664 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
21665         LDKErrorMessage obj_conv;
21666         obj_conv.inner = (void*)(obj & (~1));
21667         obj_conv.is_owned = false;
21668         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
21669         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21670         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21671         CVec_u8Z_free(ret_var);
21672         return ret_arr;
21673 }
21674
21675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21676         LDKu8slice ser_ref;
21677         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21678         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21679         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
21680         *ret_conv = ErrorMessage_read(ser_ref);
21681         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21682         return (uint64_t)ret_conv;
21683 }
21684
21685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21686         LDKUnsignedNodeAnnouncement obj_conv;
21687         obj_conv.inner = (void*)(obj & (~1));
21688         obj_conv.is_owned = false;
21689         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
21690         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21691         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21692         CVec_u8Z_free(ret_var);
21693         return ret_arr;
21694 }
21695
21696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21697         LDKu8slice ser_ref;
21698         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21699         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21700         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
21701         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
21702         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21703         return (uint64_t)ret_conv;
21704 }
21705
21706 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
21707         LDKNodeAnnouncement obj_conv;
21708         obj_conv.inner = (void*)(obj & (~1));
21709         obj_conv.is_owned = false;
21710         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
21711         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21712         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21713         CVec_u8Z_free(ret_var);
21714         return ret_arr;
21715 }
21716
21717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21718         LDKu8slice ser_ref;
21719         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21720         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21721         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
21722         *ret_conv = NodeAnnouncement_read(ser_ref);
21723         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21724         return (uint64_t)ret_conv;
21725 }
21726
21727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21728         LDKu8slice ser_ref;
21729         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21730         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21731         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
21732         *ret_conv = QueryShortChannelIds_read(ser_ref);
21733         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21734         return (uint64_t)ret_conv;
21735 }
21736
21737 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
21738         LDKQueryShortChannelIds obj_conv;
21739         obj_conv.inner = (void*)(obj & (~1));
21740         obj_conv.is_owned = false;
21741         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
21742         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21743         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21744         CVec_u8Z_free(ret_var);
21745         return ret_arr;
21746 }
21747
21748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21749         LDKu8slice ser_ref;
21750         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21751         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21752         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
21753         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
21754         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21755         return (uint64_t)ret_conv;
21756 }
21757
21758 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
21759         LDKReplyShortChannelIdsEnd obj_conv;
21760         obj_conv.inner = (void*)(obj & (~1));
21761         obj_conv.is_owned = false;
21762         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
21763         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21764         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21765         CVec_u8Z_free(ret_var);
21766         return ret_arr;
21767 }
21768
21769 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
21770         LDKQueryChannelRange this_arg_conv;
21771         this_arg_conv.inner = (void*)(this_arg & (~1));
21772         this_arg_conv.is_owned = false;
21773         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
21774         return ret_val;
21775 }
21776
21777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21778         LDKu8slice ser_ref;
21779         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21780         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21781         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
21782         *ret_conv = QueryChannelRange_read(ser_ref);
21783         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21784         return (uint64_t)ret_conv;
21785 }
21786
21787 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21788         LDKQueryChannelRange obj_conv;
21789         obj_conv.inner = (void*)(obj & (~1));
21790         obj_conv.is_owned = false;
21791         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
21792         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21793         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21794         CVec_u8Z_free(ret_var);
21795         return ret_arr;
21796 }
21797
21798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21799         LDKu8slice ser_ref;
21800         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21801         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21802         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
21803         *ret_conv = ReplyChannelRange_read(ser_ref);
21804         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21805         return (uint64_t)ret_conv;
21806 }
21807
21808 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
21809         LDKReplyChannelRange obj_conv;
21810         obj_conv.inner = (void*)(obj & (~1));
21811         obj_conv.is_owned = false;
21812         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
21813         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21814         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21815         CVec_u8Z_free(ret_var);
21816         return ret_arr;
21817 }
21818
21819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21820         LDKu8slice ser_ref;
21821         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21822         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21823         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
21824         *ret_conv = GossipTimestampFilter_read(ser_ref);
21825         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21826         return (uint64_t)ret_conv;
21827 }
21828
21829 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
21830         LDKGossipTimestampFilter obj_conv;
21831         obj_conv.inner = (void*)(obj & (~1));
21832         obj_conv.is_owned = false;
21833         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
21834         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21835         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21836         CVec_u8Z_free(ret_var);
21837         return ret_arr;
21838 }
21839
21840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21841         LDKIgnoringMessageHandler this_obj_conv;
21842         this_obj_conv.inner = (void*)(this_obj & (~1));
21843         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21844         IgnoringMessageHandler_free(this_obj_conv);
21845 }
21846
21847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
21848         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
21849         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21850         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21851         uint64_t ret_ref = (uint64_t)ret_var.inner;
21852         if (ret_var.is_owned) {
21853                 ret_ref |= 1;
21854         }
21855         return ret_ref;
21856 }
21857
21858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21859         LDKIgnoringMessageHandler this_arg_conv;
21860         this_arg_conv.inner = (void*)(this_arg & (~1));
21861         this_arg_conv.is_owned = false;
21862         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21863         *ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21864         return (uint64_t)ret;
21865 }
21866
21867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
21868         LDKIgnoringMessageHandler this_arg_conv;
21869         this_arg_conv.inner = (void*)(this_arg & (~1));
21870         this_arg_conv.is_owned = false;
21871         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
21872         *ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
21873         return (uint64_t)ret;
21874 }
21875
21876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21877         LDKErroringMessageHandler this_obj_conv;
21878         this_obj_conv.inner = (void*)(this_obj & (~1));
21879         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21880         ErroringMessageHandler_free(this_obj_conv);
21881 }
21882
21883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
21884         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
21885         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21886         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21887         uint64_t ret_ref = (uint64_t)ret_var.inner;
21888         if (ret_var.is_owned) {
21889                 ret_ref |= 1;
21890         }
21891         return ret_ref;
21892 }
21893
21894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21895         LDKErroringMessageHandler this_arg_conv;
21896         this_arg_conv.inner = (void*)(this_arg & (~1));
21897         this_arg_conv.is_owned = false;
21898         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
21899         *ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
21900         return (uint64_t)ret;
21901 }
21902
21903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
21904         LDKErroringMessageHandler this_arg_conv;
21905         this_arg_conv.inner = (void*)(this_arg & (~1));
21906         this_arg_conv.is_owned = false;
21907         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
21908         *ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
21909         return (uint64_t)ret;
21910 }
21911
21912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21913         LDKMessageHandler this_obj_conv;
21914         this_obj_conv.inner = (void*)(this_obj & (~1));
21915         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21916         MessageHandler_free(this_obj_conv);
21917 }
21918
21919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
21920         LDKMessageHandler this_ptr_conv;
21921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21922         this_ptr_conv.is_owned = false;
21923         uint64_t ret_ret = (uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv);
21924         return ret_ret;
21925 }
21926
21927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21928         LDKMessageHandler this_ptr_conv;
21929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21930         this_ptr_conv.is_owned = false;
21931         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
21932         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
21933                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21934                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
21935         }
21936         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
21937 }
21938
21939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
21940         LDKMessageHandler this_ptr_conv;
21941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21942         this_ptr_conv.is_owned = false;
21943         uint64_t ret_ret = (uint64_t)MessageHandler_get_route_handler(&this_ptr_conv);
21944         return ret_ret;
21945 }
21946
21947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21948         LDKMessageHandler this_ptr_conv;
21949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21950         this_ptr_conv.is_owned = false;
21951         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
21952         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
21953                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21954                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
21955         }
21956         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
21957 }
21958
21959 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) {
21960         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
21961         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
21962                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21963                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
21964         }
21965         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
21966         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
21967                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21968                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
21969         }
21970         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
21971         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21972         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21973         uint64_t ret_ref = (uint64_t)ret_var.inner;
21974         if (ret_var.is_owned) {
21975                 ret_ref |= 1;
21976         }
21977         return ret_ref;
21978 }
21979
21980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21981         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)(((uint64_t)orig) & ~1);
21982         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
21983         *ret = SocketDescriptor_clone(orig_conv);
21984         return (uint64_t)ret;
21985 }
21986
21987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21988         if ((this_ptr & 1) != 0) return;
21989         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
21990         FREE((void*)this_ptr);
21991         SocketDescriptor_free(this_ptr_conv);
21992 }
21993
21994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21995         LDKPeerHandleError this_obj_conv;
21996         this_obj_conv.inner = (void*)(this_obj & (~1));
21997         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21998         PeerHandleError_free(this_obj_conv);
21999 }
22000
22001 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
22002         LDKPeerHandleError this_ptr_conv;
22003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22004         this_ptr_conv.is_owned = false;
22005         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
22006         return ret_val;
22007 }
22008
22009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22010         LDKPeerHandleError this_ptr_conv;
22011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22012         this_ptr_conv.is_owned = false;
22013         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
22014 }
22015
22016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
22017         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
22018         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22019         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22020         uint64_t ret_ref = (uint64_t)ret_var.inner;
22021         if (ret_var.is_owned) {
22022                 ret_ref |= 1;
22023         }
22024         return ret_ref;
22025 }
22026
22027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22028         LDKPeerHandleError orig_conv;
22029         orig_conv.inner = (void*)(orig & (~1));
22030         orig_conv.is_owned = false;
22031         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
22032         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22033         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22034         uint64_t ret_ref = (uint64_t)ret_var.inner;
22035         if (ret_var.is_owned) {
22036                 ret_ref |= 1;
22037         }
22038         return ret_ref;
22039 }
22040
22041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22042         LDKPeerManager this_obj_conv;
22043         this_obj_conv.inner = (void*)(this_obj & (~1));
22044         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22045         PeerManager_free(this_obj_conv);
22046 }
22047
22048 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) {
22049         LDKMessageHandler message_handler_conv;
22050         message_handler_conv.inner = (void*)(message_handler & (~1));
22051         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
22052         // Warning: we need a move here but no clone is available for LDKMessageHandler
22053         LDKSecretKey our_node_secret_ref;
22054         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
22055         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
22056         unsigned char ephemeral_random_data_arr[32];
22057         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
22058         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
22059         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
22060         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
22061         if (logger_conv.free == LDKLogger_JCalls_free) {
22062                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22063                 LDKLogger_JCalls_cloned(&logger_conv);
22064         }
22065         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
22066         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22067         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22068         uint64_t ret_ref = (uint64_t)ret_var.inner;
22069         if (ret_var.is_owned) {
22070                 ret_ref |= 1;
22071         }
22072         return ret_ref;
22073 }
22074
22075 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
22076         LDKPeerManager this_arg_conv;
22077         this_arg_conv.inner = (void*)(this_arg & (~1));
22078         this_arg_conv.is_owned = false;
22079         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
22080         jobjectArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
22081         ;
22082         for (size_t i = 0; i < ret_var.datalen; i++) {
22083                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
22084                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
22085                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
22086         }
22087         FREE(ret_var.data);
22088         return ret_arr;
22089 }
22090
22091 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) {
22092         LDKPeerManager this_arg_conv;
22093         this_arg_conv.inner = (void*)(this_arg & (~1));
22094         this_arg_conv.is_owned = false;
22095         LDKPublicKey their_node_id_ref;
22096         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
22097         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
22098         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22099         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
22100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22101                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
22102         }
22103         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22104         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
22105         return (uint64_t)ret_conv;
22106 }
22107
22108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
22109         LDKPeerManager this_arg_conv;
22110         this_arg_conv.inner = (void*)(this_arg & (~1));
22111         this_arg_conv.is_owned = false;
22112         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22113         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
22114                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22115                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
22116         }
22117         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22118         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
22119         return (uint64_t)ret_conv;
22120 }
22121
22122 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) {
22123         LDKPeerManager this_arg_conv;
22124         this_arg_conv.inner = (void*)(this_arg & (~1));
22125         this_arg_conv.is_owned = false;
22126         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22127         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22128         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
22129         return (uint64_t)ret_conv;
22130 }
22131
22132 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) {
22133         LDKPeerManager this_arg_conv;
22134         this_arg_conv.inner = (void*)(this_arg & (~1));
22135         this_arg_conv.is_owned = false;
22136         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)peer_descriptor) & ~1);
22137         LDKu8slice data_ref;
22138         data_ref.datalen = (*env)->GetArrayLength(env, data);
22139         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
22140         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22141         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
22142         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
22143         return (uint64_t)ret_conv;
22144 }
22145
22146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
22147         LDKPeerManager this_arg_conv;
22148         this_arg_conv.inner = (void*)(this_arg & (~1));
22149         this_arg_conv.is_owned = false;
22150         PeerManager_process_events(&this_arg_conv);
22151 }
22152
22153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
22154         LDKPeerManager this_arg_conv;
22155         this_arg_conv.inner = (void*)(this_arg & (~1));
22156         this_arg_conv.is_owned = false;
22157         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
22158         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
22159 }
22160
22161 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) {
22162         LDKPeerManager this_arg_conv;
22163         this_arg_conv.inner = (void*)(this_arg & (~1));
22164         this_arg_conv.is_owned = false;
22165         LDKPublicKey node_id_ref;
22166         CHECK((*env)->GetArrayLength(env, node_id) == 33);
22167         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
22168         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
22169 }
22170
22171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
22172         LDKPeerManager this_arg_conv;
22173         this_arg_conv.inner = (void*)(this_arg & (~1));
22174         this_arg_conv.is_owned = false;
22175         PeerManager_timer_tick_occurred(&this_arg_conv);
22176 }
22177
22178 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
22179         unsigned char commitment_seed_arr[32];
22180         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
22181         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
22182         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
22183         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22184         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
22185         return ret_arr;
22186 }
22187
22188 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) {
22189         LDKPublicKey per_commitment_point_ref;
22190         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22191         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22192         unsigned char base_secret_arr[32];
22193         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
22194         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
22195         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
22196         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
22197         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
22198         return (uint64_t)ret_conv;
22199 }
22200
22201 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) {
22202         LDKPublicKey per_commitment_point_ref;
22203         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22204         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22205         LDKPublicKey base_point_ref;
22206         CHECK((*env)->GetArrayLength(env, base_point) == 33);
22207         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
22208         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22209         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
22210         return (uint64_t)ret_conv;
22211 }
22212
22213 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) {
22214         unsigned char per_commitment_secret_arr[32];
22215         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
22216         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
22217         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
22218         unsigned char countersignatory_revocation_base_secret_arr[32];
22219         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
22220         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
22221         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
22222         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
22223         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
22224         return (uint64_t)ret_conv;
22225 }
22226
22227 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) {
22228         LDKPublicKey per_commitment_point_ref;
22229         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22230         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22231         LDKPublicKey countersignatory_revocation_base_point_ref;
22232         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
22233         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
22234         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22235         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
22236         return (uint64_t)ret_conv;
22237 }
22238
22239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22240         LDKTxCreationKeys this_obj_conv;
22241         this_obj_conv.inner = (void*)(this_obj & (~1));
22242         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22243         TxCreationKeys_free(this_obj_conv);
22244 }
22245
22246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22247         LDKTxCreationKeys this_ptr_conv;
22248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22249         this_ptr_conv.is_owned = false;
22250         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22251         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
22252         return ret_arr;
22253 }
22254
22255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22256         LDKTxCreationKeys this_ptr_conv;
22257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22258         this_ptr_conv.is_owned = false;
22259         LDKPublicKey val_ref;
22260         CHECK((*env)->GetArrayLength(env, val) == 33);
22261         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22262         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
22263 }
22264
22265 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22266         LDKTxCreationKeys this_ptr_conv;
22267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22268         this_ptr_conv.is_owned = false;
22269         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22270         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
22271         return ret_arr;
22272 }
22273
22274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22275         LDKTxCreationKeys this_ptr_conv;
22276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22277         this_ptr_conv.is_owned = false;
22278         LDKPublicKey val_ref;
22279         CHECK((*env)->GetArrayLength(env, val) == 33);
22280         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22281         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
22282 }
22283
22284 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22285         LDKTxCreationKeys this_ptr_conv;
22286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22287         this_ptr_conv.is_owned = false;
22288         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22289         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
22290         return ret_arr;
22291 }
22292
22293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22294         LDKTxCreationKeys this_ptr_conv;
22295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22296         this_ptr_conv.is_owned = false;
22297         LDKPublicKey val_ref;
22298         CHECK((*env)->GetArrayLength(env, val) == 33);
22299         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22300         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
22301 }
22302
22303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22304         LDKTxCreationKeys this_ptr_conv;
22305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22306         this_ptr_conv.is_owned = false;
22307         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22308         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
22309         return ret_arr;
22310 }
22311
22312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22313         LDKTxCreationKeys this_ptr_conv;
22314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22315         this_ptr_conv.is_owned = false;
22316         LDKPublicKey val_ref;
22317         CHECK((*env)->GetArrayLength(env, val) == 33);
22318         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22319         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
22320 }
22321
22322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
22323         LDKTxCreationKeys this_ptr_conv;
22324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22325         this_ptr_conv.is_owned = false;
22326         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22327         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
22328         return ret_arr;
22329 }
22330
22331 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) {
22332         LDKTxCreationKeys this_ptr_conv;
22333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22334         this_ptr_conv.is_owned = false;
22335         LDKPublicKey val_ref;
22336         CHECK((*env)->GetArrayLength(env, val) == 33);
22337         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22338         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
22339 }
22340
22341 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) {
22342         LDKPublicKey per_commitment_point_arg_ref;
22343         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
22344         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
22345         LDKPublicKey revocation_key_arg_ref;
22346         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
22347         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
22348         LDKPublicKey broadcaster_htlc_key_arg_ref;
22349         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
22350         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
22351         LDKPublicKey countersignatory_htlc_key_arg_ref;
22352         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
22353         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
22354         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
22355         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
22356         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
22357         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);
22358         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22359         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22360         uint64_t ret_ref = (uint64_t)ret_var.inner;
22361         if (ret_var.is_owned) {
22362                 ret_ref |= 1;
22363         }
22364         return ret_ref;
22365 }
22366
22367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22368         LDKTxCreationKeys orig_conv;
22369         orig_conv.inner = (void*)(orig & (~1));
22370         orig_conv.is_owned = false;
22371         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
22372         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22373         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22374         uint64_t ret_ref = (uint64_t)ret_var.inner;
22375         if (ret_var.is_owned) {
22376                 ret_ref |= 1;
22377         }
22378         return ret_ref;
22379 }
22380
22381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
22382         LDKTxCreationKeys obj_conv;
22383         obj_conv.inner = (void*)(obj & (~1));
22384         obj_conv.is_owned = false;
22385         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
22386         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22387         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22388         CVec_u8Z_free(ret_var);
22389         return ret_arr;
22390 }
22391
22392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22393         LDKu8slice ser_ref;
22394         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22395         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22396         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
22397         *ret_conv = TxCreationKeys_read(ser_ref);
22398         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22399         return (uint64_t)ret_conv;
22400 }
22401
22402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22403         LDKChannelPublicKeys this_obj_conv;
22404         this_obj_conv.inner = (void*)(this_obj & (~1));
22405         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22406         ChannelPublicKeys_free(this_obj_conv);
22407 }
22408
22409 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
22410         LDKChannelPublicKeys this_ptr_conv;
22411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22412         this_ptr_conv.is_owned = false;
22413         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22414         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
22415         return ret_arr;
22416 }
22417
22418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22419         LDKChannelPublicKeys this_ptr_conv;
22420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22421         this_ptr_conv.is_owned = false;
22422         LDKPublicKey val_ref;
22423         CHECK((*env)->GetArrayLength(env, val) == 33);
22424         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22425         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
22426 }
22427
22428 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22429         LDKChannelPublicKeys this_ptr_conv;
22430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22431         this_ptr_conv.is_owned = false;
22432         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22433         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
22434         return ret_arr;
22435 }
22436
22437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22438         LDKChannelPublicKeys this_ptr_conv;
22439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22440         this_ptr_conv.is_owned = false;
22441         LDKPublicKey val_ref;
22442         CHECK((*env)->GetArrayLength(env, val) == 33);
22443         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22444         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
22445 }
22446
22447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22448         LDKChannelPublicKeys this_ptr_conv;
22449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22450         this_ptr_conv.is_owned = false;
22451         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22452         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
22453         return ret_arr;
22454 }
22455
22456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22457         LDKChannelPublicKeys this_ptr_conv;
22458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22459         this_ptr_conv.is_owned = false;
22460         LDKPublicKey val_ref;
22461         CHECK((*env)->GetArrayLength(env, val) == 33);
22462         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22463         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
22464 }
22465
22466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22467         LDKChannelPublicKeys this_ptr_conv;
22468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22469         this_ptr_conv.is_owned = false;
22470         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22471         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
22472         return ret_arr;
22473 }
22474
22475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22476         LDKChannelPublicKeys this_ptr_conv;
22477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22478         this_ptr_conv.is_owned = false;
22479         LDKPublicKey val_ref;
22480         CHECK((*env)->GetArrayLength(env, val) == 33);
22481         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22482         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
22483 }
22484
22485 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22486         LDKChannelPublicKeys this_ptr_conv;
22487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22488         this_ptr_conv.is_owned = false;
22489         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22490         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
22491         return ret_arr;
22492 }
22493
22494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22495         LDKChannelPublicKeys this_ptr_conv;
22496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22497         this_ptr_conv.is_owned = false;
22498         LDKPublicKey val_ref;
22499         CHECK((*env)->GetArrayLength(env, val) == 33);
22500         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22501         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
22502 }
22503
22504 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) {
22505         LDKPublicKey funding_pubkey_arg_ref;
22506         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
22507         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
22508         LDKPublicKey revocation_basepoint_arg_ref;
22509         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
22510         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
22511         LDKPublicKey payment_point_arg_ref;
22512         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
22513         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
22514         LDKPublicKey delayed_payment_basepoint_arg_ref;
22515         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
22516         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
22517         LDKPublicKey htlc_basepoint_arg_ref;
22518         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
22519         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
22520         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);
22521         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22522         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22523         uint64_t ret_ref = (uint64_t)ret_var.inner;
22524         if (ret_var.is_owned) {
22525                 ret_ref |= 1;
22526         }
22527         return ret_ref;
22528 }
22529
22530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22531         LDKChannelPublicKeys orig_conv;
22532         orig_conv.inner = (void*)(orig & (~1));
22533         orig_conv.is_owned = false;
22534         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
22535         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22536         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22537         uint64_t ret_ref = (uint64_t)ret_var.inner;
22538         if (ret_var.is_owned) {
22539                 ret_ref |= 1;
22540         }
22541         return ret_ref;
22542 }
22543
22544 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
22545         LDKChannelPublicKeys obj_conv;
22546         obj_conv.inner = (void*)(obj & (~1));
22547         obj_conv.is_owned = false;
22548         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
22549         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22550         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22551         CVec_u8Z_free(ret_var);
22552         return ret_arr;
22553 }
22554
22555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22556         LDKu8slice ser_ref;
22557         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22558         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22559         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
22560         *ret_conv = ChannelPublicKeys_read(ser_ref);
22561         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22562         return (uint64_t)ret_conv;
22563 }
22564
22565 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) {
22566         LDKPublicKey per_commitment_point_ref;
22567         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22568         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22569         LDKPublicKey broadcaster_delayed_payment_base_ref;
22570         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
22571         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
22572         LDKPublicKey broadcaster_htlc_base_ref;
22573         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
22574         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
22575         LDKPublicKey countersignatory_revocation_base_ref;
22576         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
22577         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
22578         LDKPublicKey countersignatory_htlc_base_ref;
22579         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
22580         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
22581         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
22582         *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);
22583         return (uint64_t)ret_conv;
22584 }
22585
22586 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) {
22587         LDKPublicKey per_commitment_point_ref;
22588         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
22589         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
22590         LDKChannelPublicKeys broadcaster_keys_conv;
22591         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
22592         broadcaster_keys_conv.is_owned = false;
22593         LDKChannelPublicKeys countersignatory_keys_conv;
22594         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
22595         countersignatory_keys_conv.is_owned = false;
22596         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
22597         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
22598         return (uint64_t)ret_conv;
22599 }
22600
22601 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) {
22602         LDKPublicKey revocation_key_ref;
22603         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
22604         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
22605         LDKPublicKey broadcaster_delayed_payment_key_ref;
22606         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
22607         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
22608         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
22609         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22610         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22611         CVec_u8Z_free(ret_var);
22612         return ret_arr;
22613 }
22614
22615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22616         LDKHTLCOutputInCommitment this_obj_conv;
22617         this_obj_conv.inner = (void*)(this_obj & (~1));
22618         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22619         HTLCOutputInCommitment_free(this_obj_conv);
22620 }
22621
22622 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
22623         LDKHTLCOutputInCommitment this_ptr_conv;
22624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22625         this_ptr_conv.is_owned = false;
22626         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
22627         return ret_val;
22628 }
22629
22630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22631         LDKHTLCOutputInCommitment this_ptr_conv;
22632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22633         this_ptr_conv.is_owned = false;
22634         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
22635 }
22636
22637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22638         LDKHTLCOutputInCommitment this_ptr_conv;
22639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22640         this_ptr_conv.is_owned = false;
22641         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
22642         return ret_val;
22643 }
22644
22645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22646         LDKHTLCOutputInCommitment this_ptr_conv;
22647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22648         this_ptr_conv.is_owned = false;
22649         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
22650 }
22651
22652 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
22653         LDKHTLCOutputInCommitment this_ptr_conv;
22654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22655         this_ptr_conv.is_owned = false;
22656         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
22657         return ret_val;
22658 }
22659
22660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22661         LDKHTLCOutputInCommitment this_ptr_conv;
22662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22663         this_ptr_conv.is_owned = false;
22664         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
22665 }
22666
22667 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
22668         LDKHTLCOutputInCommitment this_ptr_conv;
22669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22670         this_ptr_conv.is_owned = false;
22671         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22672         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
22673         return ret_arr;
22674 }
22675
22676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22677         LDKHTLCOutputInCommitment this_ptr_conv;
22678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22679         this_ptr_conv.is_owned = false;
22680         LDKThirtyTwoBytes val_ref;
22681         CHECK((*env)->GetArrayLength(env, val) == 32);
22682         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22683         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
22684 }
22685
22686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
22687         LDKHTLCOutputInCommitment this_ptr_conv;
22688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22689         this_ptr_conv.is_owned = false;
22690         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
22691         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
22692         uint64_t ret_ref = (uint64_t)ret_copy;
22693         return ret_ref;
22694 }
22695
22696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22697         LDKHTLCOutputInCommitment this_ptr_conv;
22698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22699         this_ptr_conv.is_owned = false;
22700         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(((uint64_t)val) & ~1);
22701         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
22702 }
22703
22704 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) {
22705         LDKThirtyTwoBytes payment_hash_arg_ref;
22706         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
22707         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
22708         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1);
22709         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
22710         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22711         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22712         uint64_t ret_ref = (uint64_t)ret_var.inner;
22713         if (ret_var.is_owned) {
22714                 ret_ref |= 1;
22715         }
22716         return ret_ref;
22717 }
22718
22719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22720         LDKHTLCOutputInCommitment orig_conv;
22721         orig_conv.inner = (void*)(orig & (~1));
22722         orig_conv.is_owned = false;
22723         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
22724         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22725         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22726         uint64_t ret_ref = (uint64_t)ret_var.inner;
22727         if (ret_var.is_owned) {
22728                 ret_ref |= 1;
22729         }
22730         return ret_ref;
22731 }
22732
22733 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
22734         LDKHTLCOutputInCommitment obj_conv;
22735         obj_conv.inner = (void*)(obj & (~1));
22736         obj_conv.is_owned = false;
22737         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
22738         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22739         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22740         CVec_u8Z_free(ret_var);
22741         return ret_arr;
22742 }
22743
22744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22745         LDKu8slice ser_ref;
22746         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22747         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22748         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
22749         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
22750         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22751         return (uint64_t)ret_conv;
22752 }
22753
22754 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
22755         LDKHTLCOutputInCommitment htlc_conv;
22756         htlc_conv.inner = (void*)(htlc & (~1));
22757         htlc_conv.is_owned = false;
22758         LDKTxCreationKeys keys_conv;
22759         keys_conv.inner = (void*)(keys & (~1));
22760         keys_conv.is_owned = false;
22761         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
22762         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22763         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22764         CVec_u8Z_free(ret_var);
22765         return ret_arr;
22766 }
22767
22768 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
22769         LDKPublicKey broadcaster_ref;
22770         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
22771         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
22772         LDKPublicKey countersignatory_ref;
22773         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
22774         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
22775         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
22776         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22777         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22778         CVec_u8Z_free(ret_var);
22779         return ret_arr;
22780 }
22781
22782 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) {
22783         unsigned char commitment_txid_arr[32];
22784         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
22785         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
22786         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
22787         LDKHTLCOutputInCommitment htlc_conv;
22788         htlc_conv.inner = (void*)(htlc & (~1));
22789         htlc_conv.is_owned = false;
22790         LDKPublicKey broadcaster_delayed_payment_key_ref;
22791         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
22792         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
22793         LDKPublicKey revocation_key_ref;
22794         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
22795         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
22796         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
22797         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22798         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22799         Transaction_free(ret_var);
22800         return ret_arr;
22801 }
22802
22803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22804         LDKChannelTransactionParameters this_obj_conv;
22805         this_obj_conv.inner = (void*)(this_obj & (~1));
22806         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22807         ChannelTransactionParameters_free(this_obj_conv);
22808 }
22809
22810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
22811         LDKChannelTransactionParameters this_ptr_conv;
22812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22813         this_ptr_conv.is_owned = false;
22814         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
22815         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22816         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22817         uint64_t ret_ref = (uint64_t)ret_var.inner;
22818         if (ret_var.is_owned) {
22819                 ret_ref |= 1;
22820         }
22821         return ret_ref;
22822 }
22823
22824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22825         LDKChannelTransactionParameters this_ptr_conv;
22826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22827         this_ptr_conv.is_owned = false;
22828         LDKChannelPublicKeys val_conv;
22829         val_conv.inner = (void*)(val & (~1));
22830         val_conv.is_owned = (val & 1) || (val == 0);
22831         val_conv = ChannelPublicKeys_clone(&val_conv);
22832         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
22833 }
22834
22835 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22836         LDKChannelTransactionParameters this_ptr_conv;
22837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22838         this_ptr_conv.is_owned = false;
22839         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
22840         return ret_val;
22841 }
22842
22843 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) {
22844         LDKChannelTransactionParameters this_ptr_conv;
22845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22846         this_ptr_conv.is_owned = false;
22847         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
22848 }
22849
22850 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
22851         LDKChannelTransactionParameters this_ptr_conv;
22852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22853         this_ptr_conv.is_owned = false;
22854         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
22855         return ret_val;
22856 }
22857
22858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22859         LDKChannelTransactionParameters this_ptr_conv;
22860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22861         this_ptr_conv.is_owned = false;
22862         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
22863 }
22864
22865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
22866         LDKChannelTransactionParameters this_ptr_conv;
22867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22868         this_ptr_conv.is_owned = false;
22869         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
22870         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22871         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22872         uint64_t ret_ref = (uint64_t)ret_var.inner;
22873         if (ret_var.is_owned) {
22874                 ret_ref |= 1;
22875         }
22876         return ret_ref;
22877 }
22878
22879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22880         LDKChannelTransactionParameters this_ptr_conv;
22881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22882         this_ptr_conv.is_owned = false;
22883         LDKCounterpartyChannelTransactionParameters val_conv;
22884         val_conv.inner = (void*)(val & (~1));
22885         val_conv.is_owned = (val & 1) || (val == 0);
22886         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
22887         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
22888 }
22889
22890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22891         LDKChannelTransactionParameters this_ptr_conv;
22892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22893         this_ptr_conv.is_owned = false;
22894         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
22895         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22896         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22897         uint64_t ret_ref = (uint64_t)ret_var.inner;
22898         if (ret_var.is_owned) {
22899                 ret_ref |= 1;
22900         }
22901         return ret_ref;
22902 }
22903
22904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22905         LDKChannelTransactionParameters this_ptr_conv;
22906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22907         this_ptr_conv.is_owned = false;
22908         LDKOutPoint val_conv;
22909         val_conv.inner = (void*)(val & (~1));
22910         val_conv.is_owned = (val & 1) || (val == 0);
22911         val_conv = OutPoint_clone(&val_conv);
22912         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
22913 }
22914
22915 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) {
22916         LDKChannelPublicKeys holder_pubkeys_arg_conv;
22917         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
22918         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
22919         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
22920         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
22921         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
22922         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
22923         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
22924         LDKOutPoint funding_outpoint_arg_conv;
22925         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
22926         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
22927         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
22928         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);
22929         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22930         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22931         uint64_t ret_ref = (uint64_t)ret_var.inner;
22932         if (ret_var.is_owned) {
22933                 ret_ref |= 1;
22934         }
22935         return ret_ref;
22936 }
22937
22938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22939         LDKChannelTransactionParameters orig_conv;
22940         orig_conv.inner = (void*)(orig & (~1));
22941         orig_conv.is_owned = false;
22942         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
22943         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22944         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22945         uint64_t ret_ref = (uint64_t)ret_var.inner;
22946         if (ret_var.is_owned) {
22947                 ret_ref |= 1;
22948         }
22949         return ret_ref;
22950 }
22951
22952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22953         LDKCounterpartyChannelTransactionParameters this_obj_conv;
22954         this_obj_conv.inner = (void*)(this_obj & (~1));
22955         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22956         CounterpartyChannelTransactionParameters_free(this_obj_conv);
22957 }
22958
22959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
22960         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22962         this_ptr_conv.is_owned = false;
22963         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
22964         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22965         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22966         uint64_t ret_ref = (uint64_t)ret_var.inner;
22967         if (ret_var.is_owned) {
22968                 ret_ref |= 1;
22969         }
22970         return ret_ref;
22971 }
22972
22973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22974         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22976         this_ptr_conv.is_owned = false;
22977         LDKChannelPublicKeys val_conv;
22978         val_conv.inner = (void*)(val & (~1));
22979         val_conv.is_owned = (val & 1) || (val == 0);
22980         val_conv = ChannelPublicKeys_clone(&val_conv);
22981         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
22982 }
22983
22984 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22985         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22987         this_ptr_conv.is_owned = false;
22988         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
22989         return ret_val;
22990 }
22991
22992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22993         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
22994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22995         this_ptr_conv.is_owned = false;
22996         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
22997 }
22998
22999 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) {
23000         LDKChannelPublicKeys pubkeys_arg_conv;
23001         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
23002         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
23003         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
23004         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
23005         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23006         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23007         uint64_t ret_ref = (uint64_t)ret_var.inner;
23008         if (ret_var.is_owned) {
23009                 ret_ref |= 1;
23010         }
23011         return ret_ref;
23012 }
23013
23014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23015         LDKCounterpartyChannelTransactionParameters orig_conv;
23016         orig_conv.inner = (void*)(orig & (~1));
23017         orig_conv.is_owned = false;
23018         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
23019         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23020         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23021         uint64_t ret_ref = (uint64_t)ret_var.inner;
23022         if (ret_var.is_owned) {
23023                 ret_ref |= 1;
23024         }
23025         return ret_ref;
23026 }
23027
23028 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
23029         LDKChannelTransactionParameters this_arg_conv;
23030         this_arg_conv.inner = (void*)(this_arg & (~1));
23031         this_arg_conv.is_owned = false;
23032         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
23033         return ret_val;
23034 }
23035
23036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
23037         LDKChannelTransactionParameters this_arg_conv;
23038         this_arg_conv.inner = (void*)(this_arg & (~1));
23039         this_arg_conv.is_owned = false;
23040         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
23041         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23042         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23043         uint64_t ret_ref = (uint64_t)ret_var.inner;
23044         if (ret_var.is_owned) {
23045                 ret_ref |= 1;
23046         }
23047         return ret_ref;
23048 }
23049
23050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
23051         LDKChannelTransactionParameters this_arg_conv;
23052         this_arg_conv.inner = (void*)(this_arg & (~1));
23053         this_arg_conv.is_owned = false;
23054         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
23055         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23056         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23057         uint64_t ret_ref = (uint64_t)ret_var.inner;
23058         if (ret_var.is_owned) {
23059                 ret_ref |= 1;
23060         }
23061         return ret_ref;
23062 }
23063
23064 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
23065         LDKCounterpartyChannelTransactionParameters obj_conv;
23066         obj_conv.inner = (void*)(obj & (~1));
23067         obj_conv.is_owned = false;
23068         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
23069         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23070         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23071         CVec_u8Z_free(ret_var);
23072         return ret_arr;
23073 }
23074
23075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23076         LDKu8slice ser_ref;
23077         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23078         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23079         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
23080         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
23081         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23082         return (uint64_t)ret_conv;
23083 }
23084
23085 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
23086         LDKChannelTransactionParameters obj_conv;
23087         obj_conv.inner = (void*)(obj & (~1));
23088         obj_conv.is_owned = false;
23089         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
23090         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23091         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23092         CVec_u8Z_free(ret_var);
23093         return ret_arr;
23094 }
23095
23096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23097         LDKu8slice ser_ref;
23098         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23099         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23100         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
23101         *ret_conv = ChannelTransactionParameters_read(ser_ref);
23102         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23103         return (uint64_t)ret_conv;
23104 }
23105
23106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23107         LDKDirectedChannelTransactionParameters this_obj_conv;
23108         this_obj_conv.inner = (void*)(this_obj & (~1));
23109         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23110         DirectedChannelTransactionParameters_free(this_obj_conv);
23111 }
23112
23113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
23114         LDKDirectedChannelTransactionParameters this_arg_conv;
23115         this_arg_conv.inner = (void*)(this_arg & (~1));
23116         this_arg_conv.is_owned = false;
23117         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
23118         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23119         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23120         uint64_t ret_ref = (uint64_t)ret_var.inner;
23121         if (ret_var.is_owned) {
23122                 ret_ref |= 1;
23123         }
23124         return ret_ref;
23125 }
23126
23127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
23128         LDKDirectedChannelTransactionParameters this_arg_conv;
23129         this_arg_conv.inner = (void*)(this_arg & (~1));
23130         this_arg_conv.is_owned = false;
23131         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
23132         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23133         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23134         uint64_t ret_ref = (uint64_t)ret_var.inner;
23135         if (ret_var.is_owned) {
23136                 ret_ref |= 1;
23137         }
23138         return ret_ref;
23139 }
23140
23141 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
23142         LDKDirectedChannelTransactionParameters this_arg_conv;
23143         this_arg_conv.inner = (void*)(this_arg & (~1));
23144         this_arg_conv.is_owned = false;
23145         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
23146         return ret_val;
23147 }
23148
23149 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
23150         LDKDirectedChannelTransactionParameters this_arg_conv;
23151         this_arg_conv.inner = (void*)(this_arg & (~1));
23152         this_arg_conv.is_owned = false;
23153         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
23154         return ret_val;
23155 }
23156
23157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
23158         LDKDirectedChannelTransactionParameters this_arg_conv;
23159         this_arg_conv.inner = (void*)(this_arg & (~1));
23160         this_arg_conv.is_owned = false;
23161         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
23162         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23163         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23164         uint64_t ret_ref = (uint64_t)ret_var.inner;
23165         if (ret_var.is_owned) {
23166                 ret_ref |= 1;
23167         }
23168         return ret_ref;
23169 }
23170
23171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23172         LDKHolderCommitmentTransaction this_obj_conv;
23173         this_obj_conv.inner = (void*)(this_obj & (~1));
23174         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23175         HolderCommitmentTransaction_free(this_obj_conv);
23176 }
23177
23178 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
23179         LDKHolderCommitmentTransaction this_ptr_conv;
23180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23181         this_ptr_conv.is_owned = false;
23182         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23183         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
23184         return ret_arr;
23185 }
23186
23187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23188         LDKHolderCommitmentTransaction this_ptr_conv;
23189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23190         this_ptr_conv.is_owned = false;
23191         LDKSignature val_ref;
23192         CHECK((*env)->GetArrayLength(env, val) == 64);
23193         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
23194         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
23195 }
23196
23197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
23198         LDKHolderCommitmentTransaction this_ptr_conv;
23199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23200         this_ptr_conv.is_owned = false;
23201         LDKCVec_SignatureZ val_constr;
23202         val_constr.datalen = (*env)->GetArrayLength(env, val);
23203         if (val_constr.datalen > 0)
23204                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
23205         else
23206                 val_constr.data = NULL;
23207         for (size_t i = 0; i < val_constr.datalen; i++) {
23208                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
23209                 LDKSignature val_conv_8_ref;
23210                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
23211                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
23212                 val_constr.data[i] = val_conv_8_ref;
23213         }
23214         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
23215 }
23216
23217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23218         LDKHolderCommitmentTransaction orig_conv;
23219         orig_conv.inner = (void*)(orig & (~1));
23220         orig_conv.is_owned = false;
23221         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
23222         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23223         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23224         uint64_t ret_ref = (uint64_t)ret_var.inner;
23225         if (ret_var.is_owned) {
23226                 ret_ref |= 1;
23227         }
23228         return ret_ref;
23229 }
23230
23231 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
23232         LDKHolderCommitmentTransaction obj_conv;
23233         obj_conv.inner = (void*)(obj & (~1));
23234         obj_conv.is_owned = false;
23235         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
23236         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23237         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23238         CVec_u8Z_free(ret_var);
23239         return ret_arr;
23240 }
23241
23242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23243         LDKu8slice ser_ref;
23244         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23245         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23246         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
23247         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
23248         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23249         return (uint64_t)ret_conv;
23250 }
23251
23252 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) {
23253         LDKCommitmentTransaction commitment_tx_conv;
23254         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
23255         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
23256         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
23257         LDKSignature counterparty_sig_ref;
23258         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
23259         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
23260         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
23261         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
23262         if (counterparty_htlc_sigs_constr.datalen > 0)
23263                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
23264         else
23265                 counterparty_htlc_sigs_constr.data = NULL;
23266         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
23267                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
23268                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
23269                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
23270                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
23271                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
23272         }
23273         LDKPublicKey holder_funding_key_ref;
23274         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
23275         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
23276         LDKPublicKey counterparty_funding_key_ref;
23277         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
23278         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
23279         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
23280         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23281         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23282         uint64_t ret_ref = (uint64_t)ret_var.inner;
23283         if (ret_var.is_owned) {
23284                 ret_ref |= 1;
23285         }
23286         return ret_ref;
23287 }
23288
23289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23290         LDKBuiltCommitmentTransaction this_obj_conv;
23291         this_obj_conv.inner = (void*)(this_obj & (~1));
23292         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23293         BuiltCommitmentTransaction_free(this_obj_conv);
23294 }
23295
23296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
23297         LDKBuiltCommitmentTransaction this_ptr_conv;
23298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23299         this_ptr_conv.is_owned = false;
23300         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
23301         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23302         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23303         Transaction_free(ret_var);
23304         return ret_arr;
23305 }
23306
23307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23308         LDKBuiltCommitmentTransaction this_ptr_conv;
23309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23310         this_ptr_conv.is_owned = false;
23311         LDKTransaction val_ref;
23312         val_ref.datalen = (*env)->GetArrayLength(env, val);
23313         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
23314         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
23315         val_ref.data_is_owned = true;
23316         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
23317 }
23318
23319 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
23320         LDKBuiltCommitmentTransaction this_ptr_conv;
23321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23322         this_ptr_conv.is_owned = false;
23323         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23324         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
23325         return ret_arr;
23326 }
23327
23328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23329         LDKBuiltCommitmentTransaction this_ptr_conv;
23330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23331         this_ptr_conv.is_owned = false;
23332         LDKThirtyTwoBytes val_ref;
23333         CHECK((*env)->GetArrayLength(env, val) == 32);
23334         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23335         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
23336 }
23337
23338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
23339         LDKTransaction transaction_arg_ref;
23340         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
23341         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
23342         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
23343         transaction_arg_ref.data_is_owned = true;
23344         LDKThirtyTwoBytes txid_arg_ref;
23345         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
23346         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
23347         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
23348         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23349         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23350         uint64_t ret_ref = (uint64_t)ret_var.inner;
23351         if (ret_var.is_owned) {
23352                 ret_ref |= 1;
23353         }
23354         return ret_ref;
23355 }
23356
23357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23358         LDKBuiltCommitmentTransaction orig_conv;
23359         orig_conv.inner = (void*)(orig & (~1));
23360         orig_conv.is_owned = false;
23361         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
23362         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23363         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23364         uint64_t ret_ref = (uint64_t)ret_var.inner;
23365         if (ret_var.is_owned) {
23366                 ret_ref |= 1;
23367         }
23368         return ret_ref;
23369 }
23370
23371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
23372         LDKBuiltCommitmentTransaction obj_conv;
23373         obj_conv.inner = (void*)(obj & (~1));
23374         obj_conv.is_owned = false;
23375         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
23376         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23377         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23378         CVec_u8Z_free(ret_var);
23379         return ret_arr;
23380 }
23381
23382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23383         LDKu8slice ser_ref;
23384         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23385         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23386         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
23387         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
23388         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23389         return (uint64_t)ret_conv;
23390 }
23391
23392 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) {
23393         LDKBuiltCommitmentTransaction this_arg_conv;
23394         this_arg_conv.inner = (void*)(this_arg & (~1));
23395         this_arg_conv.is_owned = false;
23396         LDKu8slice funding_redeemscript_ref;
23397         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
23398         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
23399         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23400         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
23401         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
23402         return ret_arr;
23403 }
23404
23405 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) {
23406         LDKBuiltCommitmentTransaction this_arg_conv;
23407         this_arg_conv.inner = (void*)(this_arg & (~1));
23408         this_arg_conv.is_owned = false;
23409         unsigned char funding_key_arr[32];
23410         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
23411         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
23412         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
23413         LDKu8slice funding_redeemscript_ref;
23414         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
23415         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
23416         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
23417         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
23418         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
23419         return ret_arr;
23420 }
23421
23422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23423         LDKCommitmentTransaction this_obj_conv;
23424         this_obj_conv.inner = (void*)(this_obj & (~1));
23425         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23426         CommitmentTransaction_free(this_obj_conv);
23427 }
23428
23429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23430         LDKCommitmentTransaction orig_conv;
23431         orig_conv.inner = (void*)(orig & (~1));
23432         orig_conv.is_owned = false;
23433         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
23434         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23435         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23436         uint64_t ret_ref = (uint64_t)ret_var.inner;
23437         if (ret_var.is_owned) {
23438                 ret_ref |= 1;
23439         }
23440         return ret_ref;
23441 }
23442
23443 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
23444         LDKCommitmentTransaction obj_conv;
23445         obj_conv.inner = (void*)(obj & (~1));
23446         obj_conv.is_owned = false;
23447         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
23448         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23449         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23450         CVec_u8Z_free(ret_var);
23451         return ret_arr;
23452 }
23453
23454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23455         LDKu8slice ser_ref;
23456         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23457         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23458         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
23459         *ret_conv = CommitmentTransaction_read(ser_ref);
23460         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23461         return (uint64_t)ret_conv;
23462 }
23463
23464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
23465         LDKCommitmentTransaction this_arg_conv;
23466         this_arg_conv.inner = (void*)(this_arg & (~1));
23467         this_arg_conv.is_owned = false;
23468         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
23469         return ret_val;
23470 }
23471
23472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
23473         LDKCommitmentTransaction this_arg_conv;
23474         this_arg_conv.inner = (void*)(this_arg & (~1));
23475         this_arg_conv.is_owned = false;
23476         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
23477         return ret_val;
23478 }
23479
23480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
23481         LDKCommitmentTransaction this_arg_conv;
23482         this_arg_conv.inner = (void*)(this_arg & (~1));
23483         this_arg_conv.is_owned = false;
23484         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
23485         return ret_val;
23486 }
23487
23488 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
23489         LDKCommitmentTransaction this_arg_conv;
23490         this_arg_conv.inner = (void*)(this_arg & (~1));
23491         this_arg_conv.is_owned = false;
23492         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
23493         return ret_val;
23494 }
23495
23496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
23497         LDKCommitmentTransaction this_arg_conv;
23498         this_arg_conv.inner = (void*)(this_arg & (~1));
23499         this_arg_conv.is_owned = false;
23500         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
23501         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23502         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23503         uint64_t ret_ref = (uint64_t)ret_var.inner;
23504         if (ret_var.is_owned) {
23505                 ret_ref |= 1;
23506         }
23507         return ret_ref;
23508 }
23509
23510 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) {
23511         LDKCommitmentTransaction this_arg_conv;
23512         this_arg_conv.inner = (void*)(this_arg & (~1));
23513         this_arg_conv.is_owned = false;
23514         LDKDirectedChannelTransactionParameters channel_parameters_conv;
23515         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
23516         channel_parameters_conv.is_owned = false;
23517         LDKChannelPublicKeys broadcaster_keys_conv;
23518         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
23519         broadcaster_keys_conv.is_owned = false;
23520         LDKChannelPublicKeys countersignatory_keys_conv;
23521         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
23522         countersignatory_keys_conv.is_owned = false;
23523         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
23524         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
23525         return (uint64_t)ret_conv;
23526 }
23527
23528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23529         LDKTrustedCommitmentTransaction this_obj_conv;
23530         this_obj_conv.inner = (void*)(this_obj & (~1));
23531         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23532         TrustedCommitmentTransaction_free(this_obj_conv);
23533 }
23534
23535 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
23536         LDKTrustedCommitmentTransaction this_arg_conv;
23537         this_arg_conv.inner = (void*)(this_arg & (~1));
23538         this_arg_conv.is_owned = false;
23539         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23540         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
23541         return ret_arr;
23542 }
23543
23544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
23545         LDKTrustedCommitmentTransaction this_arg_conv;
23546         this_arg_conv.inner = (void*)(this_arg & (~1));
23547         this_arg_conv.is_owned = false;
23548         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
23549         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23550         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23551         uint64_t ret_ref = (uint64_t)ret_var.inner;
23552         if (ret_var.is_owned) {
23553                 ret_ref |= 1;
23554         }
23555         return ret_ref;
23556 }
23557
23558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
23559         LDKTrustedCommitmentTransaction this_arg_conv;
23560         this_arg_conv.inner = (void*)(this_arg & (~1));
23561         this_arg_conv.is_owned = false;
23562         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
23563         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23564         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23565         uint64_t ret_ref = (uint64_t)ret_var.inner;
23566         if (ret_var.is_owned) {
23567                 ret_ref |= 1;
23568         }
23569         return ret_ref;
23570 }
23571
23572 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) {
23573         LDKTrustedCommitmentTransaction this_arg_conv;
23574         this_arg_conv.inner = (void*)(this_arg & (~1));
23575         this_arg_conv.is_owned = false;
23576         unsigned char htlc_base_key_arr[32];
23577         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
23578         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
23579         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
23580         LDKDirectedChannelTransactionParameters channel_parameters_conv;
23581         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
23582         channel_parameters_conv.is_owned = false;
23583         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
23584         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
23585         return (uint64_t)ret_conv;
23586 }
23587
23588 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) {
23589         LDKPublicKey broadcaster_payment_basepoint_ref;
23590         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
23591         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
23592         LDKPublicKey countersignatory_payment_basepoint_ref;
23593         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
23594         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
23595         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
23596         return ret_val;
23597 }
23598
23599 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23600         LDKInitFeatures a_conv;
23601         a_conv.inner = (void*)(a & (~1));
23602         a_conv.is_owned = false;
23603         LDKInitFeatures b_conv;
23604         b_conv.inner = (void*)(b & (~1));
23605         b_conv.is_owned = false;
23606         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
23607         return ret_val;
23608 }
23609
23610 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23611         LDKNodeFeatures a_conv;
23612         a_conv.inner = (void*)(a & (~1));
23613         a_conv.is_owned = false;
23614         LDKNodeFeatures b_conv;
23615         b_conv.inner = (void*)(b & (~1));
23616         b_conv.is_owned = false;
23617         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
23618         return ret_val;
23619 }
23620
23621 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23622         LDKChannelFeatures a_conv;
23623         a_conv.inner = (void*)(a & (~1));
23624         a_conv.is_owned = false;
23625         LDKChannelFeatures b_conv;
23626         b_conv.inner = (void*)(b & (~1));
23627         b_conv.is_owned = false;
23628         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
23629         return ret_val;
23630 }
23631
23632 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23633         LDKInvoiceFeatures a_conv;
23634         a_conv.inner = (void*)(a & (~1));
23635         a_conv.is_owned = false;
23636         LDKInvoiceFeatures b_conv;
23637         b_conv.inner = (void*)(b & (~1));
23638         b_conv.is_owned = false;
23639         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
23640         return ret_val;
23641 }
23642
23643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23644         LDKInitFeatures orig_conv;
23645         orig_conv.inner = (void*)(orig & (~1));
23646         orig_conv.is_owned = false;
23647         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
23648         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23649         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23650         uint64_t ret_ref = (uint64_t)ret_var.inner;
23651         if (ret_var.is_owned) {
23652                 ret_ref |= 1;
23653         }
23654         return ret_ref;
23655 }
23656
23657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23658         LDKNodeFeatures orig_conv;
23659         orig_conv.inner = (void*)(orig & (~1));
23660         orig_conv.is_owned = false;
23661         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
23662         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23663         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23664         uint64_t ret_ref = (uint64_t)ret_var.inner;
23665         if (ret_var.is_owned) {
23666                 ret_ref |= 1;
23667         }
23668         return ret_ref;
23669 }
23670
23671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23672         LDKChannelFeatures orig_conv;
23673         orig_conv.inner = (void*)(orig & (~1));
23674         orig_conv.is_owned = false;
23675         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
23676         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23677         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23678         uint64_t ret_ref = (uint64_t)ret_var.inner;
23679         if (ret_var.is_owned) {
23680                 ret_ref |= 1;
23681         }
23682         return ret_ref;
23683 }
23684
23685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23686         LDKInvoiceFeatures orig_conv;
23687         orig_conv.inner = (void*)(orig & (~1));
23688         orig_conv.is_owned = false;
23689         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
23690         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23691         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23692         uint64_t ret_ref = (uint64_t)ret_var.inner;
23693         if (ret_var.is_owned) {
23694                 ret_ref |= 1;
23695         }
23696         return ret_ref;
23697 }
23698
23699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23700         LDKInitFeatures this_obj_conv;
23701         this_obj_conv.inner = (void*)(this_obj & (~1));
23702         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23703         InitFeatures_free(this_obj_conv);
23704 }
23705
23706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23707         LDKNodeFeatures this_obj_conv;
23708         this_obj_conv.inner = (void*)(this_obj & (~1));
23709         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23710         NodeFeatures_free(this_obj_conv);
23711 }
23712
23713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23714         LDKChannelFeatures this_obj_conv;
23715         this_obj_conv.inner = (void*)(this_obj & (~1));
23716         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23717         ChannelFeatures_free(this_obj_conv);
23718 }
23719
23720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23721         LDKInvoiceFeatures this_obj_conv;
23722         this_obj_conv.inner = (void*)(this_obj & (~1));
23723         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23724         InvoiceFeatures_free(this_obj_conv);
23725 }
23726
23727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
23728         LDKInitFeatures ret_var = InitFeatures_empty();
23729         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23730         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23731         uint64_t ret_ref = (uint64_t)ret_var.inner;
23732         if (ret_var.is_owned) {
23733                 ret_ref |= 1;
23734         }
23735         return ret_ref;
23736 }
23737
23738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
23739         LDKInitFeatures ret_var = InitFeatures_known();
23740         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23741         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23742         uint64_t ret_ref = (uint64_t)ret_var.inner;
23743         if (ret_var.is_owned) {
23744                 ret_ref |= 1;
23745         }
23746         return ret_ref;
23747 }
23748
23749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
23750         LDKNodeFeatures ret_var = NodeFeatures_empty();
23751         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23752         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23753         uint64_t ret_ref = (uint64_t)ret_var.inner;
23754         if (ret_var.is_owned) {
23755                 ret_ref |= 1;
23756         }
23757         return ret_ref;
23758 }
23759
23760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
23761         LDKNodeFeatures ret_var = NodeFeatures_known();
23762         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23763         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23764         uint64_t ret_ref = (uint64_t)ret_var.inner;
23765         if (ret_var.is_owned) {
23766                 ret_ref |= 1;
23767         }
23768         return ret_ref;
23769 }
23770
23771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
23772         LDKChannelFeatures ret_var = ChannelFeatures_empty();
23773         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23774         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23775         uint64_t ret_ref = (uint64_t)ret_var.inner;
23776         if (ret_var.is_owned) {
23777                 ret_ref |= 1;
23778         }
23779         return ret_ref;
23780 }
23781
23782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
23783         LDKChannelFeatures ret_var = ChannelFeatures_known();
23784         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23785         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23786         uint64_t ret_ref = (uint64_t)ret_var.inner;
23787         if (ret_var.is_owned) {
23788                 ret_ref |= 1;
23789         }
23790         return ret_ref;
23791 }
23792
23793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
23794         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
23795         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23796         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23797         uint64_t ret_ref = (uint64_t)ret_var.inner;
23798         if (ret_var.is_owned) {
23799                 ret_ref |= 1;
23800         }
23801         return ret_ref;
23802 }
23803
23804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
23805         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
23806         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23807         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23808         uint64_t ret_ref = (uint64_t)ret_var.inner;
23809         if (ret_var.is_owned) {
23810                 ret_ref |= 1;
23811         }
23812         return ret_ref;
23813 }
23814
23815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23816         LDKInitFeatures this_arg_conv;
23817         this_arg_conv.inner = (void*)(this_arg & (~1));
23818         this_arg_conv.is_owned = false;
23819         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
23820         return ret_val;
23821 }
23822
23823 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23824         LDKNodeFeatures this_arg_conv;
23825         this_arg_conv.inner = (void*)(this_arg & (~1));
23826         this_arg_conv.is_owned = false;
23827         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
23828         return ret_val;
23829 }
23830
23831 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
23832         LDKInvoiceFeatures this_arg_conv;
23833         this_arg_conv.inner = (void*)(this_arg & (~1));
23834         this_arg_conv.is_owned = false;
23835         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
23836         return ret_val;
23837 }
23838
23839 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23840         LDKInitFeatures obj_conv;
23841         obj_conv.inner = (void*)(obj & (~1));
23842         obj_conv.is_owned = false;
23843         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
23844         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23845         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23846         CVec_u8Z_free(ret_var);
23847         return ret_arr;
23848 }
23849
23850 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23851         LDKNodeFeatures obj_conv;
23852         obj_conv.inner = (void*)(obj & (~1));
23853         obj_conv.is_owned = false;
23854         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
23855         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23856         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23857         CVec_u8Z_free(ret_var);
23858         return ret_arr;
23859 }
23860
23861 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23862         LDKChannelFeatures obj_conv;
23863         obj_conv.inner = (void*)(obj & (~1));
23864         obj_conv.is_owned = false;
23865         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
23866         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23867         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23868         CVec_u8Z_free(ret_var);
23869         return ret_arr;
23870 }
23871
23872 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
23873         LDKInvoiceFeatures obj_conv;
23874         obj_conv.inner = (void*)(obj & (~1));
23875         obj_conv.is_owned = false;
23876         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
23877         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23878         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23879         CVec_u8Z_free(ret_var);
23880         return ret_arr;
23881 }
23882
23883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23884         LDKu8slice ser_ref;
23885         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23886         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23887         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
23888         *ret_conv = InitFeatures_read(ser_ref);
23889         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23890         return (uint64_t)ret_conv;
23891 }
23892
23893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23894         LDKu8slice ser_ref;
23895         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23896         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23897         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
23898         *ret_conv = NodeFeatures_read(ser_ref);
23899         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23900         return (uint64_t)ret_conv;
23901 }
23902
23903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23904         LDKu8slice ser_ref;
23905         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23906         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23907         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
23908         *ret_conv = ChannelFeatures_read(ser_ref);
23909         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23910         return (uint64_t)ret_conv;
23911 }
23912
23913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23914         LDKu8slice ser_ref;
23915         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23916         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23917         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
23918         *ret_conv = InvoiceFeatures_read(ser_ref);
23919         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23920         return (uint64_t)ret_conv;
23921 }
23922
23923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23924         LDKRouteHop this_obj_conv;
23925         this_obj_conv.inner = (void*)(this_obj & (~1));
23926         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23927         RouteHop_free(this_obj_conv);
23928 }
23929
23930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
23931         LDKRouteHop this_ptr_conv;
23932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23933         this_ptr_conv.is_owned = false;
23934         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23935         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
23936         return ret_arr;
23937 }
23938
23939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23940         LDKRouteHop this_ptr_conv;
23941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23942         this_ptr_conv.is_owned = false;
23943         LDKPublicKey val_ref;
23944         CHECK((*env)->GetArrayLength(env, val) == 33);
23945         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23946         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
23947 }
23948
23949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23950         LDKRouteHop this_ptr_conv;
23951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23952         this_ptr_conv.is_owned = false;
23953         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
23954         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23955         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23956         uint64_t ret_ref = (uint64_t)ret_var.inner;
23957         if (ret_var.is_owned) {
23958                 ret_ref |= 1;
23959         }
23960         return ret_ref;
23961 }
23962
23963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23964         LDKRouteHop this_ptr_conv;
23965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23966         this_ptr_conv.is_owned = false;
23967         LDKNodeFeatures val_conv;
23968         val_conv.inner = (void*)(val & (~1));
23969         val_conv.is_owned = (val & 1) || (val == 0);
23970         val_conv = NodeFeatures_clone(&val_conv);
23971         RouteHop_set_node_features(&this_ptr_conv, val_conv);
23972 }
23973
23974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23975         LDKRouteHop this_ptr_conv;
23976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23977         this_ptr_conv.is_owned = false;
23978         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
23979         return ret_val;
23980 }
23981
23982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23983         LDKRouteHop this_ptr_conv;
23984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23985         this_ptr_conv.is_owned = false;
23986         RouteHop_set_short_channel_id(&this_ptr_conv, val);
23987 }
23988
23989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23990         LDKRouteHop this_ptr_conv;
23991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23992         this_ptr_conv.is_owned = false;
23993         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
23994         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23995         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23996         uint64_t ret_ref = (uint64_t)ret_var.inner;
23997         if (ret_var.is_owned) {
23998                 ret_ref |= 1;
23999         }
24000         return ret_ref;
24001 }
24002
24003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24004         LDKRouteHop this_ptr_conv;
24005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24006         this_ptr_conv.is_owned = false;
24007         LDKChannelFeatures val_conv;
24008         val_conv.inner = (void*)(val & (~1));
24009         val_conv.is_owned = (val & 1) || (val == 0);
24010         val_conv = ChannelFeatures_clone(&val_conv);
24011         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
24012 }
24013
24014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24015         LDKRouteHop this_ptr_conv;
24016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24017         this_ptr_conv.is_owned = false;
24018         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
24019         return ret_val;
24020 }
24021
24022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24023         LDKRouteHop this_ptr_conv;
24024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24025         this_ptr_conv.is_owned = false;
24026         RouteHop_set_fee_msat(&this_ptr_conv, val);
24027 }
24028
24029 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24030         LDKRouteHop this_ptr_conv;
24031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24032         this_ptr_conv.is_owned = false;
24033         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
24034         return ret_val;
24035 }
24036
24037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24038         LDKRouteHop this_ptr_conv;
24039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24040         this_ptr_conv.is_owned = false;
24041         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
24042 }
24043
24044 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) {
24045         LDKPublicKey pubkey_arg_ref;
24046         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
24047         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
24048         LDKNodeFeatures node_features_arg_conv;
24049         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
24050         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
24051         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
24052         LDKChannelFeatures channel_features_arg_conv;
24053         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
24054         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
24055         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
24056         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);
24057         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24058         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24059         uint64_t ret_ref = (uint64_t)ret_var.inner;
24060         if (ret_var.is_owned) {
24061                 ret_ref |= 1;
24062         }
24063         return ret_ref;
24064 }
24065
24066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24067         LDKRouteHop orig_conv;
24068         orig_conv.inner = (void*)(orig & (~1));
24069         orig_conv.is_owned = false;
24070         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
24071         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24072         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24073         uint64_t ret_ref = (uint64_t)ret_var.inner;
24074         if (ret_var.is_owned) {
24075                 ret_ref |= 1;
24076         }
24077         return ret_ref;
24078 }
24079
24080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
24081         LDKRouteHop obj_conv;
24082         obj_conv.inner = (void*)(obj & (~1));
24083         obj_conv.is_owned = false;
24084         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
24085         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24086         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24087         CVec_u8Z_free(ret_var);
24088         return ret_arr;
24089 }
24090
24091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24092         LDKu8slice ser_ref;
24093         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24094         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24095         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
24096         *ret_conv = RouteHop_read(ser_ref);
24097         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24098         return (uint64_t)ret_conv;
24099 }
24100
24101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24102         LDKRoute this_obj_conv;
24103         this_obj_conv.inner = (void*)(this_obj & (~1));
24104         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24105         Route_free(this_obj_conv);
24106 }
24107
24108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
24109         LDKRoute this_ptr_conv;
24110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24111         this_ptr_conv.is_owned = false;
24112         LDKCVec_CVec_RouteHopZZ val_constr;
24113         val_constr.datalen = (*env)->GetArrayLength(env, val);
24114         if (val_constr.datalen > 0)
24115                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
24116         else
24117                 val_constr.data = NULL;
24118         for (size_t m = 0; m < val_constr.datalen; m++) {
24119                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
24120                 LDKCVec_RouteHopZ val_conv_12_constr;
24121                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
24122                 if (val_conv_12_constr.datalen > 0)
24123                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24124                 else
24125                         val_conv_12_constr.data = NULL;
24126                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
24127                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
24128                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
24129                         LDKRouteHop val_conv_12_conv_10_conv;
24130                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
24131                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
24132                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
24133                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
24134                 }
24135                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
24136                 val_constr.data[m] = val_conv_12_constr;
24137         }
24138         Route_set_paths(&this_ptr_conv, val_constr);
24139 }
24140
24141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg) {
24142         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
24143         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
24144         if (paths_arg_constr.datalen > 0)
24145                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
24146         else
24147                 paths_arg_constr.data = NULL;
24148         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
24149                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
24150                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
24151                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
24152                 if (paths_arg_conv_12_constr.datalen > 0)
24153                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24154                 else
24155                         paths_arg_conv_12_constr.data = NULL;
24156                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
24157                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
24158                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
24159                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
24160                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
24161                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
24162                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
24163                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
24164                 }
24165                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
24166                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
24167         }
24168         LDKRoute ret_var = Route_new(paths_arg_constr);
24169         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24170         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24171         uint64_t ret_ref = (uint64_t)ret_var.inner;
24172         if (ret_var.is_owned) {
24173                 ret_ref |= 1;
24174         }
24175         return ret_ref;
24176 }
24177
24178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24179         LDKRoute orig_conv;
24180         orig_conv.inner = (void*)(orig & (~1));
24181         orig_conv.is_owned = false;
24182         LDKRoute ret_var = Route_clone(&orig_conv);
24183         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24184         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24185         uint64_t ret_ref = (uint64_t)ret_var.inner;
24186         if (ret_var.is_owned) {
24187                 ret_ref |= 1;
24188         }
24189         return ret_ref;
24190 }
24191
24192 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
24193         LDKRoute obj_conv;
24194         obj_conv.inner = (void*)(obj & (~1));
24195         obj_conv.is_owned = false;
24196         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
24197         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24198         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24199         CVec_u8Z_free(ret_var);
24200         return ret_arr;
24201 }
24202
24203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24204         LDKu8slice ser_ref;
24205         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24206         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24207         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
24208         *ret_conv = Route_read(ser_ref);
24209         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24210         return (uint64_t)ret_conv;
24211 }
24212
24213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24214         LDKRouteHint this_obj_conv;
24215         this_obj_conv.inner = (void*)(this_obj & (~1));
24216         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24217         RouteHint_free(this_obj_conv);
24218 }
24219
24220 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24221         LDKRouteHint a_conv;
24222         a_conv.inner = (void*)(a & (~1));
24223         a_conv.is_owned = false;
24224         LDKRouteHint b_conv;
24225         b_conv.inner = (void*)(b & (~1));
24226         b_conv.is_owned = false;
24227         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
24228         return ret_val;
24229 }
24230
24231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24232         LDKRouteHint orig_conv;
24233         orig_conv.inner = (void*)(orig & (~1));
24234         orig_conv.is_owned = false;
24235         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
24236         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24237         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24238         uint64_t ret_ref = (uint64_t)ret_var.inner;
24239         if (ret_var.is_owned) {
24240                 ret_ref |= 1;
24241         }
24242         return ret_ref;
24243 }
24244
24245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24246         LDKRouteHintHop this_obj_conv;
24247         this_obj_conv.inner = (void*)(this_obj & (~1));
24248         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24249         RouteHintHop_free(this_obj_conv);
24250 }
24251
24252 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24253         LDKRouteHintHop this_ptr_conv;
24254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24255         this_ptr_conv.is_owned = false;
24256         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24257         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
24258         return ret_arr;
24259 }
24260
24261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24262         LDKRouteHintHop this_ptr_conv;
24263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24264         this_ptr_conv.is_owned = false;
24265         LDKPublicKey val_ref;
24266         CHECK((*env)->GetArrayLength(env, val) == 33);
24267         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24268         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
24269 }
24270
24271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24272         LDKRouteHintHop this_ptr_conv;
24273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24274         this_ptr_conv.is_owned = false;
24275         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
24276         return ret_val;
24277 }
24278
24279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24280         LDKRouteHintHop this_ptr_conv;
24281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24282         this_ptr_conv.is_owned = false;
24283         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
24284 }
24285
24286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24287         LDKRouteHintHop this_ptr_conv;
24288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24289         this_ptr_conv.is_owned = false;
24290         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
24291         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24292         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24293         uint64_t ret_ref = (uint64_t)ret_var.inner;
24294         if (ret_var.is_owned) {
24295                 ret_ref |= 1;
24296         }
24297         return ret_ref;
24298 }
24299
24300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24301         LDKRouteHintHop this_ptr_conv;
24302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24303         this_ptr_conv.is_owned = false;
24304         LDKRoutingFees val_conv;
24305         val_conv.inner = (void*)(val & (~1));
24306         val_conv.is_owned = (val & 1) || (val == 0);
24307         val_conv = RoutingFees_clone(&val_conv);
24308         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
24309 }
24310
24311 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24312         LDKRouteHintHop this_ptr_conv;
24313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24314         this_ptr_conv.is_owned = false;
24315         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
24316         return ret_val;
24317 }
24318
24319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24320         LDKRouteHintHop this_ptr_conv;
24321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24322         this_ptr_conv.is_owned = false;
24323         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
24324 }
24325
24326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24327         LDKRouteHintHop this_ptr_conv;
24328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24329         this_ptr_conv.is_owned = false;
24330         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24331         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
24332         uint64_t ret_ref = (uint64_t)ret_copy;
24333         return ret_ref;
24334 }
24335
24336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24337         LDKRouteHintHop this_ptr_conv;
24338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24339         this_ptr_conv.is_owned = false;
24340         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24341         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
24342 }
24343
24344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24345         LDKRouteHintHop this_ptr_conv;
24346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24347         this_ptr_conv.is_owned = false;
24348         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24349         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
24350         uint64_t ret_ref = (uint64_t)ret_copy;
24351         return ret_ref;
24352 }
24353
24354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24355         LDKRouteHintHop this_ptr_conv;
24356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24357         this_ptr_conv.is_owned = false;
24358         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24359         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
24360 }
24361
24362 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) {
24363         LDKPublicKey src_node_id_arg_ref;
24364         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
24365         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
24366         LDKRoutingFees fees_arg_conv;
24367         fees_arg_conv.inner = (void*)(fees_arg & (~1));
24368         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
24369         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
24370         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
24371         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
24372         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);
24373         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24374         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24375         uint64_t ret_ref = (uint64_t)ret_var.inner;
24376         if (ret_var.is_owned) {
24377                 ret_ref |= 1;
24378         }
24379         return ret_ref;
24380 }
24381
24382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24383         LDKRouteHintHop a_conv;
24384         a_conv.inner = (void*)(a & (~1));
24385         a_conv.is_owned = false;
24386         LDKRouteHintHop b_conv;
24387         b_conv.inner = (void*)(b & (~1));
24388         b_conv.is_owned = false;
24389         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
24390         return ret_val;
24391 }
24392
24393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24394         LDKRouteHintHop orig_conv;
24395         orig_conv.inner = (void*)(orig & (~1));
24396         orig_conv.is_owned = false;
24397         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
24398         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24399         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24400         uint64_t ret_ref = (uint64_t)ret_var.inner;
24401         if (ret_var.is_owned) {
24402                 ret_ref |= 1;
24403         }
24404         return ret_ref;
24405 }
24406
24407 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) {
24408         LDKPublicKey our_node_id_ref;
24409         CHECK((*env)->GetArrayLength(env, our_node_id) == 33);
24410         (*env)->GetByteArrayRegion(env, our_node_id, 0, 33, our_node_id_ref.compressed_form);
24411         LDKNetworkGraph network_conv;
24412         network_conv.inner = (void*)(network & (~1));
24413         network_conv.is_owned = false;
24414         LDKPublicKey payee_ref;
24415         CHECK((*env)->GetArrayLength(env, payee) == 33);
24416         (*env)->GetByteArrayRegion(env, payee, 0, 33, payee_ref.compressed_form);
24417         LDKInvoiceFeatures payee_features_conv;
24418         payee_features_conv.inner = (void*)(payee_features & (~1));
24419         payee_features_conv.is_owned = (payee_features & 1) || (payee_features == 0);
24420         payee_features_conv = InvoiceFeatures_clone(&payee_features_conv);
24421         LDKCVec_ChannelDetailsZ first_hops_constr;
24422         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
24423         if (first_hops != NULL) {
24424                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
24425                 if (first_hops_constr.datalen > 0)
24426                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
24427                 else
24428                         first_hops_constr.data = NULL;
24429                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
24430                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
24431                         int64_t first_hops_conv_16 = first_hops_vals[q];
24432                         LDKChannelDetails first_hops_conv_16_conv;
24433                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
24434                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
24435                         first_hops_constr.data[q] = first_hops_conv_16_conv;
24436                 }
24437                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
24438                 first_hops_ptr = &first_hops_constr;
24439         }
24440         LDKCVec_RouteHintZ last_hops_constr;
24441         last_hops_constr.datalen = (*env)->GetArrayLength(env, last_hops);
24442         if (last_hops_constr.datalen > 0)
24443                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
24444         else
24445                 last_hops_constr.data = NULL;
24446         int64_t* last_hops_vals = (*env)->GetLongArrayElements (env, last_hops, NULL);
24447         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
24448                 int64_t last_hops_conv_11 = last_hops_vals[l];
24449                 LDKRouteHint last_hops_conv_11_conv;
24450                 last_hops_conv_11_conv.inner = (void*)(last_hops_conv_11 & (~1));
24451                 last_hops_conv_11_conv.is_owned = (last_hops_conv_11 & 1) || (last_hops_conv_11 == 0);
24452                 last_hops_conv_11_conv = RouteHint_clone(&last_hops_conv_11_conv);
24453                 last_hops_constr.data[l] = last_hops_conv_11_conv;
24454         }
24455         (*env)->ReleaseLongArrayElements(env, last_hops, last_hops_vals, 0);
24456         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24457         if (logger_conv.free == LDKLogger_JCalls_free) {
24458                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24459                 LDKLogger_JCalls_cloned(&logger_conv);
24460         }
24461         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
24462         *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);
24463         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
24464         return (uint64_t)ret_conv;
24465 }
24466
24467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24468         LDKNetworkGraph this_obj_conv;
24469         this_obj_conv.inner = (void*)(this_obj & (~1));
24470         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24471         NetworkGraph_free(this_obj_conv);
24472 }
24473
24474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24475         LDKNetworkGraph orig_conv;
24476         orig_conv.inner = (void*)(orig & (~1));
24477         orig_conv.is_owned = false;
24478         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
24479         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24480         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24481         uint64_t ret_ref = (uint64_t)ret_var.inner;
24482         if (ret_var.is_owned) {
24483                 ret_ref |= 1;
24484         }
24485         return ret_ref;
24486 }
24487
24488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24489         LDKLockedNetworkGraph this_obj_conv;
24490         this_obj_conv.inner = (void*)(this_obj & (~1));
24491         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24492         LockedNetworkGraph_free(this_obj_conv);
24493 }
24494
24495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24496         LDKNetGraphMsgHandler this_obj_conv;
24497         this_obj_conv.inner = (void*)(this_obj & (~1));
24498         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24499         NetGraphMsgHandler_free(this_obj_conv);
24500 }
24501
24502 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) {
24503         LDKThirtyTwoBytes genesis_hash_ref;
24504         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
24505         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
24506         LDKAccess *chain_access_conv_ptr = NULL;
24507         if (chain_access != 0) {
24508                 LDKAccess chain_access_conv;
24509                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24510                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24511                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24512                         LDKAccess_JCalls_cloned(&chain_access_conv);
24513                 }
24514                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24515                 *chain_access_conv_ptr = chain_access_conv;
24516         }
24517         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24518         if (logger_conv.free == LDKLogger_JCalls_free) {
24519                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24520                 LDKLogger_JCalls_cloned(&logger_conv);
24521         }
24522         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv_ptr, logger_conv);
24523         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24524         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24525         uint64_t ret_ref = (uint64_t)ret_var.inner;
24526         if (ret_var.is_owned) {
24527                 ret_ref |= 1;
24528         }
24529         return ret_ref;
24530 }
24531
24532 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) {
24533         LDKAccess *chain_access_conv_ptr = NULL;
24534         if (chain_access != 0) {
24535                 LDKAccess chain_access_conv;
24536                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24537                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24538                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24539                         LDKAccess_JCalls_cloned(&chain_access_conv);
24540                 }
24541                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24542                 *chain_access_conv_ptr = chain_access_conv;
24543         }
24544         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
24545         if (logger_conv.free == LDKLogger_JCalls_free) {
24546                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24547                 LDKLogger_JCalls_cloned(&logger_conv);
24548         }
24549         LDKNetworkGraph network_graph_conv;
24550         network_graph_conv.inner = (void*)(network_graph & (~1));
24551         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
24552         network_graph_conv = NetworkGraph_clone(&network_graph_conv);
24553         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv_ptr, logger_conv, network_graph_conv);
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 void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
24564         LDKNetGraphMsgHandler this_arg_conv;
24565         this_arg_conv.inner = (void*)(this_arg & (~1));
24566         this_arg_conv.is_owned = false;
24567         LDKAccess *chain_access_conv_ptr = NULL;
24568         if (chain_access != 0) {
24569                 LDKAccess chain_access_conv;
24570                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
24571                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
24572                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24573                         LDKAccess_JCalls_cloned(&chain_access_conv);
24574                 }
24575                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
24576                 *chain_access_conv_ptr = chain_access_conv;
24577         }
24578         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv_ptr);
24579 }
24580
24581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1read_1locked_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
24582         LDKNetGraphMsgHandler this_arg_conv;
24583         this_arg_conv.inner = (void*)(this_arg & (~1));
24584         this_arg_conv.is_owned = false;
24585         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
24586         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24587         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24588         uint64_t ret_ref = (uint64_t)ret_var.inner;
24589         if (ret_var.is_owned) {
24590                 ret_ref |= 1;
24591         }
24592         return ret_ref;
24593 }
24594
24595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockedNetworkGraph_1graph(JNIEnv *env, jclass clz, int64_t this_arg) {
24596         LDKLockedNetworkGraph this_arg_conv;
24597         this_arg_conv.inner = (void*)(this_arg & (~1));
24598         this_arg_conv.is_owned = false;
24599         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
24600         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24601         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24602         uint64_t ret_ref = (uint64_t)ret_var.inner;
24603         if (ret_var.is_owned) {
24604                 ret_ref |= 1;
24605         }
24606         return ret_ref;
24607 }
24608
24609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
24610         LDKNetGraphMsgHandler this_arg_conv;
24611         this_arg_conv.inner = (void*)(this_arg & (~1));
24612         this_arg_conv.is_owned = false;
24613         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
24614         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
24615         return (uint64_t)ret;
24616 }
24617
24618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
24619         LDKNetGraphMsgHandler this_arg_conv;
24620         this_arg_conv.inner = (void*)(this_arg & (~1));
24621         this_arg_conv.is_owned = false;
24622         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
24623         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
24624         return (uint64_t)ret;
24625 }
24626
24627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24628         LDKDirectionalChannelInfo this_obj_conv;
24629         this_obj_conv.inner = (void*)(this_obj & (~1));
24630         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24631         DirectionalChannelInfo_free(this_obj_conv);
24632 }
24633
24634 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
24635         LDKDirectionalChannelInfo this_ptr_conv;
24636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24637         this_ptr_conv.is_owned = false;
24638         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
24639         return ret_val;
24640 }
24641
24642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24643         LDKDirectionalChannelInfo this_ptr_conv;
24644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24645         this_ptr_conv.is_owned = false;
24646         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
24647 }
24648
24649 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
24650         LDKDirectionalChannelInfo this_ptr_conv;
24651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24652         this_ptr_conv.is_owned = false;
24653         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
24654         return ret_val;
24655 }
24656
24657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24658         LDKDirectionalChannelInfo this_ptr_conv;
24659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24660         this_ptr_conv.is_owned = false;
24661         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
24662 }
24663
24664 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24665         LDKDirectionalChannelInfo this_ptr_conv;
24666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24667         this_ptr_conv.is_owned = false;
24668         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
24669         return ret_val;
24670 }
24671
24672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24673         LDKDirectionalChannelInfo this_ptr_conv;
24674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24675         this_ptr_conv.is_owned = false;
24676         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
24677 }
24678
24679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24680         LDKDirectionalChannelInfo this_ptr_conv;
24681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24682         this_ptr_conv.is_owned = false;
24683         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
24684         return ret_val;
24685 }
24686
24687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24688         LDKDirectionalChannelInfo this_ptr_conv;
24689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24690         this_ptr_conv.is_owned = false;
24691         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
24692 }
24693
24694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24695         LDKDirectionalChannelInfo this_ptr_conv;
24696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24697         this_ptr_conv.is_owned = false;
24698         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24699         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
24700         uint64_t ret_ref = (uint64_t)ret_copy;
24701         return ret_ref;
24702 }
24703
24704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24705         LDKDirectionalChannelInfo this_ptr_conv;
24706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24707         this_ptr_conv.is_owned = false;
24708         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24709         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
24710 }
24711
24712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
24713         LDKDirectionalChannelInfo this_ptr_conv;
24714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24715         this_ptr_conv.is_owned = false;
24716         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
24717         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24718         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24719         uint64_t ret_ref = (uint64_t)ret_var.inner;
24720         if (ret_var.is_owned) {
24721                 ret_ref |= 1;
24722         }
24723         return ret_ref;
24724 }
24725
24726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24727         LDKDirectionalChannelInfo this_ptr_conv;
24728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24729         this_ptr_conv.is_owned = false;
24730         LDKRoutingFees val_conv;
24731         val_conv.inner = (void*)(val & (~1));
24732         val_conv.is_owned = (val & 1) || (val == 0);
24733         val_conv = RoutingFees_clone(&val_conv);
24734         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
24735 }
24736
24737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24738         LDKDirectionalChannelInfo this_ptr_conv;
24739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24740         this_ptr_conv.is_owned = false;
24741         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
24742         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24743         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24744         uint64_t ret_ref = (uint64_t)ret_var.inner;
24745         if (ret_var.is_owned) {
24746                 ret_ref |= 1;
24747         }
24748         return ret_ref;
24749 }
24750
24751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24752         LDKDirectionalChannelInfo this_ptr_conv;
24753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24754         this_ptr_conv.is_owned = false;
24755         LDKChannelUpdate val_conv;
24756         val_conv.inner = (void*)(val & (~1));
24757         val_conv.is_owned = (val & 1) || (val == 0);
24758         val_conv = ChannelUpdate_clone(&val_conv);
24759         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
24760 }
24761
24762 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) {
24763         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
24764         LDKRoutingFees fees_arg_conv;
24765         fees_arg_conv.inner = (void*)(fees_arg & (~1));
24766         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
24767         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
24768         LDKChannelUpdate last_update_message_arg_conv;
24769         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
24770         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
24771         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
24772         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);
24773         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24774         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24775         uint64_t ret_ref = (uint64_t)ret_var.inner;
24776         if (ret_var.is_owned) {
24777                 ret_ref |= 1;
24778         }
24779         return ret_ref;
24780 }
24781
24782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24783         LDKDirectionalChannelInfo orig_conv;
24784         orig_conv.inner = (void*)(orig & (~1));
24785         orig_conv.is_owned = false;
24786         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
24787         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24788         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24789         uint64_t ret_ref = (uint64_t)ret_var.inner;
24790         if (ret_var.is_owned) {
24791                 ret_ref |= 1;
24792         }
24793         return ret_ref;
24794 }
24795
24796 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
24797         LDKDirectionalChannelInfo obj_conv;
24798         obj_conv.inner = (void*)(obj & (~1));
24799         obj_conv.is_owned = false;
24800         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
24801         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24802         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24803         CVec_u8Z_free(ret_var);
24804         return ret_arr;
24805 }
24806
24807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24808         LDKu8slice ser_ref;
24809         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24810         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24811         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
24812         *ret_conv = DirectionalChannelInfo_read(ser_ref);
24813         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24814         return (uint64_t)ret_conv;
24815 }
24816
24817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24818         LDKChannelInfo this_obj_conv;
24819         this_obj_conv.inner = (void*)(this_obj & (~1));
24820         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24821         ChannelInfo_free(this_obj_conv);
24822 }
24823
24824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
24825         LDKChannelInfo this_ptr_conv;
24826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24827         this_ptr_conv.is_owned = false;
24828         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
24829         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24830         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24831         uint64_t ret_ref = (uint64_t)ret_var.inner;
24832         if (ret_var.is_owned) {
24833                 ret_ref |= 1;
24834         }
24835         return ret_ref;
24836 }
24837
24838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24839         LDKChannelInfo this_ptr_conv;
24840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24841         this_ptr_conv.is_owned = false;
24842         LDKChannelFeatures val_conv;
24843         val_conv.inner = (void*)(val & (~1));
24844         val_conv.is_owned = (val & 1) || (val == 0);
24845         val_conv = ChannelFeatures_clone(&val_conv);
24846         ChannelInfo_set_features(&this_ptr_conv, val_conv);
24847 }
24848
24849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
24850         LDKChannelInfo this_ptr_conv;
24851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24852         this_ptr_conv.is_owned = false;
24853         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24854         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form);
24855         return ret_arr;
24856 }
24857
24858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24859         LDKChannelInfo this_ptr_conv;
24860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24861         this_ptr_conv.is_owned = false;
24862         LDKPublicKey val_ref;
24863         CHECK((*env)->GetArrayLength(env, val) == 33);
24864         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24865         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
24866 }
24867
24868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
24869         LDKChannelInfo this_ptr_conv;
24870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24871         this_ptr_conv.is_owned = false;
24872         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
24873         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24874         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24875         uint64_t ret_ref = (uint64_t)ret_var.inner;
24876         if (ret_var.is_owned) {
24877                 ret_ref |= 1;
24878         }
24879         return ret_ref;
24880 }
24881
24882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24883         LDKChannelInfo this_ptr_conv;
24884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24885         this_ptr_conv.is_owned = false;
24886         LDKDirectionalChannelInfo val_conv;
24887         val_conv.inner = (void*)(val & (~1));
24888         val_conv.is_owned = (val & 1) || (val == 0);
24889         val_conv = DirectionalChannelInfo_clone(&val_conv);
24890         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
24891 }
24892
24893 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
24894         LDKChannelInfo this_ptr_conv;
24895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24896         this_ptr_conv.is_owned = false;
24897         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24898         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form);
24899         return ret_arr;
24900 }
24901
24902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24903         LDKChannelInfo this_ptr_conv;
24904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24905         this_ptr_conv.is_owned = false;
24906         LDKPublicKey val_ref;
24907         CHECK((*env)->GetArrayLength(env, val) == 33);
24908         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24909         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
24910 }
24911
24912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
24913         LDKChannelInfo this_ptr_conv;
24914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24915         this_ptr_conv.is_owned = false;
24916         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
24917         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24918         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24919         uint64_t ret_ref = (uint64_t)ret_var.inner;
24920         if (ret_var.is_owned) {
24921                 ret_ref |= 1;
24922         }
24923         return ret_ref;
24924 }
24925
24926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24927         LDKChannelInfo this_ptr_conv;
24928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24929         this_ptr_conv.is_owned = false;
24930         LDKDirectionalChannelInfo val_conv;
24931         val_conv.inner = (void*)(val & (~1));
24932         val_conv.is_owned = (val & 1) || (val == 0);
24933         val_conv = DirectionalChannelInfo_clone(&val_conv);
24934         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
24935 }
24936
24937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
24938         LDKChannelInfo this_ptr_conv;
24939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24940         this_ptr_conv.is_owned = false;
24941         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24942         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
24943         uint64_t ret_ref = (uint64_t)ret_copy;
24944         return ret_ref;
24945 }
24946
24947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24948         LDKChannelInfo this_ptr_conv;
24949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24950         this_ptr_conv.is_owned = false;
24951         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(((uint64_t)val) & ~1);
24952         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
24953 }
24954
24955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
24956         LDKChannelInfo this_ptr_conv;
24957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24958         this_ptr_conv.is_owned = false;
24959         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
24960         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24961         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24962         uint64_t ret_ref = (uint64_t)ret_var.inner;
24963         if (ret_var.is_owned) {
24964                 ret_ref |= 1;
24965         }
24966         return ret_ref;
24967 }
24968
24969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24970         LDKChannelInfo this_ptr_conv;
24971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24972         this_ptr_conv.is_owned = false;
24973         LDKChannelAnnouncement val_conv;
24974         val_conv.inner = (void*)(val & (~1));
24975         val_conv.is_owned = (val & 1) || (val == 0);
24976         val_conv = ChannelAnnouncement_clone(&val_conv);
24977         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
24978 }
24979
24980 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) {
24981         LDKChannelFeatures features_arg_conv;
24982         features_arg_conv.inner = (void*)(features_arg & (~1));
24983         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24984         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
24985         LDKPublicKey node_one_arg_ref;
24986         CHECK((*env)->GetArrayLength(env, node_one_arg) == 33);
24987         (*env)->GetByteArrayRegion(env, node_one_arg, 0, 33, node_one_arg_ref.compressed_form);
24988         LDKDirectionalChannelInfo one_to_two_arg_conv;
24989         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
24990         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
24991         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
24992         LDKPublicKey node_two_arg_ref;
24993         CHECK((*env)->GetArrayLength(env, node_two_arg) == 33);
24994         (*env)->GetByteArrayRegion(env, node_two_arg, 0, 33, node_two_arg_ref.compressed_form);
24995         LDKDirectionalChannelInfo two_to_one_arg_conv;
24996         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
24997         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
24998         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
24999         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1);
25000         LDKChannelAnnouncement announcement_message_arg_conv;
25001         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
25002         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
25003         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
25004         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);
25005         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25006         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25007         uint64_t ret_ref = (uint64_t)ret_var.inner;
25008         if (ret_var.is_owned) {
25009                 ret_ref |= 1;
25010         }
25011         return ret_ref;
25012 }
25013
25014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25015         LDKChannelInfo orig_conv;
25016         orig_conv.inner = (void*)(orig & (~1));
25017         orig_conv.is_owned = false;
25018         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
25019         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25020         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25021         uint64_t ret_ref = (uint64_t)ret_var.inner;
25022         if (ret_var.is_owned) {
25023                 ret_ref |= 1;
25024         }
25025         return ret_ref;
25026 }
25027
25028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
25029         LDKChannelInfo obj_conv;
25030         obj_conv.inner = (void*)(obj & (~1));
25031         obj_conv.is_owned = false;
25032         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
25033         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25034         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25035         CVec_u8Z_free(ret_var);
25036         return ret_arr;
25037 }
25038
25039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25040         LDKu8slice ser_ref;
25041         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25042         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25043         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
25044         *ret_conv = ChannelInfo_read(ser_ref);
25045         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25046         return (uint64_t)ret_conv;
25047 }
25048
25049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25050         LDKRoutingFees this_obj_conv;
25051         this_obj_conv.inner = (void*)(this_obj & (~1));
25052         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25053         RoutingFees_free(this_obj_conv);
25054 }
25055
25056 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25057         LDKRoutingFees this_ptr_conv;
25058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25059         this_ptr_conv.is_owned = false;
25060         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
25061         return ret_val;
25062 }
25063
25064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25065         LDKRoutingFees this_ptr_conv;
25066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25067         this_ptr_conv.is_owned = false;
25068         RoutingFees_set_base_msat(&this_ptr_conv, val);
25069 }
25070
25071 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
25072         LDKRoutingFees this_ptr_conv;
25073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25074         this_ptr_conv.is_owned = false;
25075         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
25076         return ret_val;
25077 }
25078
25079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25080         LDKRoutingFees this_ptr_conv;
25081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25082         this_ptr_conv.is_owned = false;
25083         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
25084 }
25085
25086 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) {
25087         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
25088         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25089         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25090         uint64_t ret_ref = (uint64_t)ret_var.inner;
25091         if (ret_var.is_owned) {
25092                 ret_ref |= 1;
25093         }
25094         return ret_ref;
25095 }
25096
25097 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25098         LDKRoutingFees a_conv;
25099         a_conv.inner = (void*)(a & (~1));
25100         a_conv.is_owned = false;
25101         LDKRoutingFees b_conv;
25102         b_conv.inner = (void*)(b & (~1));
25103         b_conv.is_owned = false;
25104         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
25105         return ret_val;
25106 }
25107
25108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25109         LDKRoutingFees orig_conv;
25110         orig_conv.inner = (void*)(orig & (~1));
25111         orig_conv.is_owned = false;
25112         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
25113         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25114         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25115         uint64_t ret_ref = (uint64_t)ret_var.inner;
25116         if (ret_var.is_owned) {
25117                 ret_ref |= 1;
25118         }
25119         return ret_ref;
25120 }
25121
25122 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
25123         LDKRoutingFees obj_conv;
25124         obj_conv.inner = (void*)(obj & (~1));
25125         obj_conv.is_owned = false;
25126         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
25127         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25128         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25129         CVec_u8Z_free(ret_var);
25130         return ret_arr;
25131 }
25132
25133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25134         LDKu8slice ser_ref;
25135         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25136         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25137         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
25138         *ret_conv = RoutingFees_read(ser_ref);
25139         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25140         return (uint64_t)ret_conv;
25141 }
25142
25143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25144         LDKNodeAnnouncementInfo this_obj_conv;
25145         this_obj_conv.inner = (void*)(this_obj & (~1));
25146         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25147         NodeAnnouncementInfo_free(this_obj_conv);
25148 }
25149
25150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
25151         LDKNodeAnnouncementInfo this_ptr_conv;
25152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25153         this_ptr_conv.is_owned = false;
25154         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
25155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25157         uint64_t ret_ref = (uint64_t)ret_var.inner;
25158         if (ret_var.is_owned) {
25159                 ret_ref |= 1;
25160         }
25161         return ret_ref;
25162 }
25163
25164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25165         LDKNodeAnnouncementInfo this_ptr_conv;
25166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25167         this_ptr_conv.is_owned = false;
25168         LDKNodeFeatures val_conv;
25169         val_conv.inner = (void*)(val & (~1));
25170         val_conv.is_owned = (val & 1) || (val == 0);
25171         val_conv = NodeFeatures_clone(&val_conv);
25172         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
25173 }
25174
25175 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
25176         LDKNodeAnnouncementInfo this_ptr_conv;
25177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25178         this_ptr_conv.is_owned = false;
25179         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
25180         return ret_val;
25181 }
25182
25183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25184         LDKNodeAnnouncementInfo this_ptr_conv;
25185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25186         this_ptr_conv.is_owned = false;
25187         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
25188 }
25189
25190 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
25191         LDKNodeAnnouncementInfo this_ptr_conv;
25192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25193         this_ptr_conv.is_owned = false;
25194         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
25195         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
25196         return ret_arr;
25197 }
25198
25199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25200         LDKNodeAnnouncementInfo this_ptr_conv;
25201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25202         this_ptr_conv.is_owned = false;
25203         LDKThreeBytes val_ref;
25204         CHECK((*env)->GetArrayLength(env, val) == 3);
25205         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
25206         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
25207 }
25208
25209 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
25210         LDKNodeAnnouncementInfo this_ptr_conv;
25211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25212         this_ptr_conv.is_owned = false;
25213         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25214         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
25215         return ret_arr;
25216 }
25217
25218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25219         LDKNodeAnnouncementInfo this_ptr_conv;
25220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25221         this_ptr_conv.is_owned = false;
25222         LDKThirtyTwoBytes val_ref;
25223         CHECK((*env)->GetArrayLength(env, val) == 32);
25224         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25225         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
25226 }
25227
25228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
25229         LDKNodeAnnouncementInfo this_ptr_conv;
25230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25231         this_ptr_conv.is_owned = false;
25232         LDKCVec_NetAddressZ val_constr;
25233         val_constr.datalen = (*env)->GetArrayLength(env, val);
25234         if (val_constr.datalen > 0)
25235                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25236         else
25237                 val_constr.data = NULL;
25238         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
25239         for (size_t m = 0; m < val_constr.datalen; m++) {
25240                 int64_t val_conv_12 = val_vals[m];
25241                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(((uint64_t)val_conv_12) & ~1);
25242                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
25243                 val_constr.data[m] = val_conv_12_conv;
25244         }
25245         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
25246         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
25247 }
25248
25249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
25250         LDKNodeAnnouncementInfo this_ptr_conv;
25251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25252         this_ptr_conv.is_owned = false;
25253         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
25254         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25255         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25256         uint64_t ret_ref = (uint64_t)ret_var.inner;
25257         if (ret_var.is_owned) {
25258                 ret_ref |= 1;
25259         }
25260         return ret_ref;
25261 }
25262
25263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25264         LDKNodeAnnouncementInfo this_ptr_conv;
25265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25266         this_ptr_conv.is_owned = false;
25267         LDKNodeAnnouncement val_conv;
25268         val_conv.inner = (void*)(val & (~1));
25269         val_conv.is_owned = (val & 1) || (val == 0);
25270         val_conv = NodeAnnouncement_clone(&val_conv);
25271         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
25272 }
25273
25274 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) {
25275         LDKNodeFeatures features_arg_conv;
25276         features_arg_conv.inner = (void*)(features_arg & (~1));
25277         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
25278         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
25279         LDKThreeBytes rgb_arg_ref;
25280         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
25281         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
25282         LDKThirtyTwoBytes alias_arg_ref;
25283         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
25284         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
25285         LDKCVec_NetAddressZ addresses_arg_constr;
25286         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
25287         if (addresses_arg_constr.datalen > 0)
25288                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25289         else
25290                 addresses_arg_constr.data = NULL;
25291         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
25292         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
25293                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
25294                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(((uint64_t)addresses_arg_conv_12) & ~1);
25295                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
25296         }
25297         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
25298         LDKNodeAnnouncement announcement_message_arg_conv;
25299         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
25300         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
25301         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
25302         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
25303         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25304         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25305         uint64_t ret_ref = (uint64_t)ret_var.inner;
25306         if (ret_var.is_owned) {
25307                 ret_ref |= 1;
25308         }
25309         return ret_ref;
25310 }
25311
25312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25313         LDKNodeAnnouncementInfo orig_conv;
25314         orig_conv.inner = (void*)(orig & (~1));
25315         orig_conv.is_owned = false;
25316         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
25317         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25318         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25319         uint64_t ret_ref = (uint64_t)ret_var.inner;
25320         if (ret_var.is_owned) {
25321                 ret_ref |= 1;
25322         }
25323         return ret_ref;
25324 }
25325
25326 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
25327         LDKNodeAnnouncementInfo obj_conv;
25328         obj_conv.inner = (void*)(obj & (~1));
25329         obj_conv.is_owned = false;
25330         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
25331         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25332         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25333         CVec_u8Z_free(ret_var);
25334         return ret_arr;
25335 }
25336
25337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25338         LDKu8slice ser_ref;
25339         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25340         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25341         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
25342         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
25343         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25344         return (uint64_t)ret_conv;
25345 }
25346
25347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25348         LDKNodeInfo this_obj_conv;
25349         this_obj_conv.inner = (void*)(this_obj & (~1));
25350         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25351         NodeInfo_free(this_obj_conv);
25352 }
25353
25354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
25355         LDKNodeInfo this_ptr_conv;
25356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25357         this_ptr_conv.is_owned = false;
25358         LDKCVec_u64Z val_constr;
25359         val_constr.datalen = (*env)->GetArrayLength(env, val);
25360         if (val_constr.datalen > 0)
25361                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
25362         else
25363                 val_constr.data = NULL;
25364         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
25365         for (size_t g = 0; g < val_constr.datalen; g++) {
25366                 int64_t val_conv_6 = val_vals[g];
25367                 val_constr.data[g] = val_conv_6;
25368         }
25369         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
25370         NodeInfo_set_channels(&this_ptr_conv, val_constr);
25371 }
25372
25373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
25374         LDKNodeInfo this_ptr_conv;
25375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25376         this_ptr_conv.is_owned = false;
25377         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
25378         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25379         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25380         uint64_t ret_ref = (uint64_t)ret_var.inner;
25381         if (ret_var.is_owned) {
25382                 ret_ref |= 1;
25383         }
25384         return ret_ref;
25385 }
25386
25387 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) {
25388         LDKNodeInfo this_ptr_conv;
25389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25390         this_ptr_conv.is_owned = false;
25391         LDKRoutingFees val_conv;
25392         val_conv.inner = (void*)(val & (~1));
25393         val_conv.is_owned = (val & 1) || (val == 0);
25394         val_conv = RoutingFees_clone(&val_conv);
25395         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
25396 }
25397
25398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
25399         LDKNodeInfo this_ptr_conv;
25400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25401         this_ptr_conv.is_owned = false;
25402         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
25403         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25404         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25405         uint64_t ret_ref = (uint64_t)ret_var.inner;
25406         if (ret_var.is_owned) {
25407                 ret_ref |= 1;
25408         }
25409         return ret_ref;
25410 }
25411
25412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25413         LDKNodeInfo this_ptr_conv;
25414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25415         this_ptr_conv.is_owned = false;
25416         LDKNodeAnnouncementInfo val_conv;
25417         val_conv.inner = (void*)(val & (~1));
25418         val_conv.is_owned = (val & 1) || (val == 0);
25419         val_conv = NodeAnnouncementInfo_clone(&val_conv);
25420         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
25421 }
25422
25423 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) {
25424         LDKCVec_u64Z channels_arg_constr;
25425         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
25426         if (channels_arg_constr.datalen > 0)
25427                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
25428         else
25429                 channels_arg_constr.data = NULL;
25430         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
25431         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
25432                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
25433                 channels_arg_constr.data[g] = channels_arg_conv_6;
25434         }
25435         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
25436         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
25437         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
25438         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
25439         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
25440         LDKNodeAnnouncementInfo announcement_info_arg_conv;
25441         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
25442         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
25443         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
25444         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
25445         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25446         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25447         uint64_t ret_ref = (uint64_t)ret_var.inner;
25448         if (ret_var.is_owned) {
25449                 ret_ref |= 1;
25450         }
25451         return ret_ref;
25452 }
25453
25454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25455         LDKNodeInfo orig_conv;
25456         orig_conv.inner = (void*)(orig & (~1));
25457         orig_conv.is_owned = false;
25458         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
25459         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25460         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25461         uint64_t ret_ref = (uint64_t)ret_var.inner;
25462         if (ret_var.is_owned) {
25463                 ret_ref |= 1;
25464         }
25465         return ret_ref;
25466 }
25467
25468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
25469         LDKNodeInfo obj_conv;
25470         obj_conv.inner = (void*)(obj & (~1));
25471         obj_conv.is_owned = false;
25472         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
25473         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25474         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25475         CVec_u8Z_free(ret_var);
25476         return ret_arr;
25477 }
25478
25479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25480         LDKu8slice ser_ref;
25481         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25482         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25483         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
25484         *ret_conv = NodeInfo_read(ser_ref);
25485         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25486         return (uint64_t)ret_conv;
25487 }
25488
25489 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
25490         LDKNetworkGraph obj_conv;
25491         obj_conv.inner = (void*)(obj & (~1));
25492         obj_conv.is_owned = false;
25493         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
25494         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25495         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25496         CVec_u8Z_free(ret_var);
25497         return ret_arr;
25498 }
25499
25500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25501         LDKu8slice ser_ref;
25502         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25503         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25504         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
25505         *ret_conv = NetworkGraph_read(ser_ref);
25506         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25507         return (uint64_t)ret_conv;
25508 }
25509
25510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
25511         LDKThirtyTwoBytes genesis_hash_ref;
25512         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
25513         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
25514         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
25515         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25516         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25517         uint64_t ret_ref = (uint64_t)ret_var.inner;
25518         if (ret_var.is_owned) {
25519                 ret_ref |= 1;
25520         }
25521         return ret_ref;
25522 }
25523
25524 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) {
25525         LDKNetworkGraph this_arg_conv;
25526         this_arg_conv.inner = (void*)(this_arg & (~1));
25527         this_arg_conv.is_owned = false;
25528         LDKNodeAnnouncement msg_conv;
25529         msg_conv.inner = (void*)(msg & (~1));
25530         msg_conv.is_owned = false;
25531         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25532         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
25533         return (uint64_t)ret_conv;
25534 }
25535
25536 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) {
25537         LDKNetworkGraph this_arg_conv;
25538         this_arg_conv.inner = (void*)(this_arg & (~1));
25539         this_arg_conv.is_owned = false;
25540         LDKUnsignedNodeAnnouncement msg_conv;
25541         msg_conv.inner = (void*)(msg & (~1));
25542         msg_conv.is_owned = false;
25543         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25544         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
25545         return (uint64_t)ret_conv;
25546 }
25547
25548 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) {
25549         LDKNetworkGraph this_arg_conv;
25550         this_arg_conv.inner = (void*)(this_arg & (~1));
25551         this_arg_conv.is_owned = false;
25552         LDKChannelAnnouncement msg_conv;
25553         msg_conv.inner = (void*)(msg & (~1));
25554         msg_conv.is_owned = false;
25555         LDKAccess *chain_access_conv_ptr = NULL;
25556         if (chain_access != 0) {
25557                 LDKAccess chain_access_conv;
25558                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25559                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25560                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25561                         LDKAccess_JCalls_cloned(&chain_access_conv);
25562                 }
25563                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25564                 *chain_access_conv_ptr = chain_access_conv;
25565         }
25566         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25567         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
25568         return (uint64_t)ret_conv;
25569 }
25570
25571 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) {
25572         LDKNetworkGraph this_arg_conv;
25573         this_arg_conv.inner = (void*)(this_arg & (~1));
25574         this_arg_conv.is_owned = false;
25575         LDKUnsignedChannelAnnouncement msg_conv;
25576         msg_conv.inner = (void*)(msg & (~1));
25577         msg_conv.is_owned = false;
25578         LDKAccess *chain_access_conv_ptr = NULL;
25579         if (chain_access != 0) {
25580                 LDKAccess chain_access_conv;
25581                 chain_access_conv = *(LDKAccess*)(((uint64_t)chain_access) & ~1);
25582                 if (chain_access_conv.free == LDKAccess_JCalls_free) {
25583                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25584                         LDKAccess_JCalls_cloned(&chain_access_conv);
25585                 }
25586                 chain_access_conv_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
25587                 *chain_access_conv_ptr = chain_access_conv;
25588         }
25589         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25590         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv_ptr);
25591         return (uint64_t)ret_conv;
25592 }
25593
25594 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) {
25595         LDKNetworkGraph this_arg_conv;
25596         this_arg_conv.inner = (void*)(this_arg & (~1));
25597         this_arg_conv.is_owned = false;
25598         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
25599 }
25600
25601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
25602         LDKNetworkGraph this_arg_conv;
25603         this_arg_conv.inner = (void*)(this_arg & (~1));
25604         this_arg_conv.is_owned = false;
25605         LDKChannelUpdate msg_conv;
25606         msg_conv.inner = (void*)(msg & (~1));
25607         msg_conv.is_owned = false;
25608         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25609         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
25610         return (uint64_t)ret_conv;
25611 }
25612
25613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
25614         LDKNetworkGraph this_arg_conv;
25615         this_arg_conv.inner = (void*)(this_arg & (~1));
25616         this_arg_conv.is_owned = false;
25617         LDKUnsignedChannelUpdate msg_conv;
25618         msg_conv.inner = (void*)(msg & (~1));
25619         msg_conv.is_owned = false;
25620         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
25621         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
25622         return (uint64_t)ret_conv;
25623 }
25624
25625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25626         LDKFilesystemPersister this_obj_conv;
25627         this_obj_conv.inner = (void*)(this_obj & (~1));
25628         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25629         FilesystemPersister_free(this_obj_conv);
25630 }
25631
25632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
25633         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
25634         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
25635         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25636         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25637         uint64_t ret_ref = (uint64_t)ret_var.inner;
25638         if (ret_var.is_owned) {
25639                 ret_ref |= 1;
25640         }
25641         return ret_ref;
25642 }
25643
25644 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
25645         LDKFilesystemPersister this_arg_conv;
25646         this_arg_conv.inner = (void*)(this_arg & (~1));
25647         this_arg_conv.is_owned = false;
25648         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
25649         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25650         Str_free(ret_str);
25651         return ret_conv;
25652 }
25653
25654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
25655         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
25656         LDKChannelManager manager_conv;
25657         manager_conv.inner = (void*)(manager & (~1));
25658         manager_conv.is_owned = false;
25659         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25660         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
25661         return (uint64_t)ret_conv;
25662 }
25663
25664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
25665         LDKFilesystemPersister this_arg_conv;
25666         this_arg_conv.inner = (void*)(this_arg & (~1));
25667         this_arg_conv.is_owned = false;
25668         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
25669         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25670                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25671                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
25672         }
25673         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
25674         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
25675         return (uint64_t)ret_conv;
25676 }
25677
25678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
25679         LDKFilesystemPersister this_arg_conv;
25680         this_arg_conv.inner = (void*)(this_arg & (~1));
25681         this_arg_conv.is_owned = false;
25682         LDKPersist* ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
25683         *ret = FilesystemPersister_as_Persist(&this_arg_conv);
25684         return (uint64_t)ret;
25685 }
25686
25687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25688         LDKBackgroundProcessor this_obj_conv;
25689         this_obj_conv.inner = (void*)(this_obj & (~1));
25690         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25691         BackgroundProcessor_free(this_obj_conv);
25692 }
25693
25694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25695         if ((this_ptr & 1) != 0) return;
25696         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(((uint64_t)this_ptr) & ~1);
25697         FREE((void*)this_ptr);
25698         ChannelManagerPersister_free(this_ptr_conv);
25699 }
25700
25701 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) {
25702         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(((uint64_t)persister) & ~1);
25703         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
25704                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25705                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
25706         }
25707         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(((uint64_t)event_handler) & ~1);
25708         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
25709                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25710                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
25711         }
25712         LDKChainMonitor chain_monitor_conv;
25713         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
25714         chain_monitor_conv.is_owned = false;
25715         LDKChannelManager channel_manager_conv;
25716         channel_manager_conv.inner = (void*)(channel_manager & (~1));
25717         channel_manager_conv.is_owned = false;
25718         LDKPeerManager peer_manager_conv;
25719         peer_manager_conv.inner = (void*)(peer_manager & (~1));
25720         peer_manager_conv.is_owned = false;
25721         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
25722         if (logger_conv.free == LDKLogger_JCalls_free) {
25723                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25724                 LDKLogger_JCalls_cloned(&logger_conv);
25725         }
25726         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, &peer_manager_conv, logger_conv);
25727         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25728         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25729         uint64_t ret_ref = (uint64_t)ret_var.inner;
25730         if (ret_var.is_owned) {
25731                 ret_ref |= 1;
25732         }
25733         return ret_ref;
25734 }
25735
25736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
25737         LDKBackgroundProcessor this_arg_conv;
25738         this_arg_conv.inner = (void*)(this_arg & (~1));
25739         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
25740         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
25741         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
25742         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
25743         return (uint64_t)ret_conv;
25744 }
25745
25746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
25747         check_platform();
25748 }
25749
25750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25751         LDKInvoice this_obj_conv;
25752         this_obj_conv.inner = (void*)(this_obj & (~1));
25753         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25754         Invoice_free(this_obj_conv);
25755 }
25756
25757 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25758         LDKInvoice a_conv;
25759         a_conv.inner = (void*)(a & (~1));
25760         a_conv.is_owned = false;
25761         LDKInvoice b_conv;
25762         b_conv.inner = (void*)(b & (~1));
25763         b_conv.is_owned = false;
25764         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
25765         return ret_val;
25766 }
25767
25768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25769         LDKInvoice orig_conv;
25770         orig_conv.inner = (void*)(orig & (~1));
25771         orig_conv.is_owned = false;
25772         LDKInvoice ret_var = Invoice_clone(&orig_conv);
25773         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25774         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25775         uint64_t ret_ref = (uint64_t)ret_var.inner;
25776         if (ret_var.is_owned) {
25777                 ret_ref |= 1;
25778         }
25779         return ret_ref;
25780 }
25781
25782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25783         LDKSignedRawInvoice this_obj_conv;
25784         this_obj_conv.inner = (void*)(this_obj & (~1));
25785         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25786         SignedRawInvoice_free(this_obj_conv);
25787 }
25788
25789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25790         LDKSignedRawInvoice a_conv;
25791         a_conv.inner = (void*)(a & (~1));
25792         a_conv.is_owned = false;
25793         LDKSignedRawInvoice b_conv;
25794         b_conv.inner = (void*)(b & (~1));
25795         b_conv.is_owned = false;
25796         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
25797         return ret_val;
25798 }
25799
25800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25801         LDKSignedRawInvoice orig_conv;
25802         orig_conv.inner = (void*)(orig & (~1));
25803         orig_conv.is_owned = false;
25804         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
25805         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25806         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25807         uint64_t ret_ref = (uint64_t)ret_var.inner;
25808         if (ret_var.is_owned) {
25809                 ret_ref |= 1;
25810         }
25811         return ret_ref;
25812 }
25813
25814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25815         LDKRawInvoice this_obj_conv;
25816         this_obj_conv.inner = (void*)(this_obj & (~1));
25817         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25818         RawInvoice_free(this_obj_conv);
25819 }
25820
25821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
25822         LDKRawInvoice this_ptr_conv;
25823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25824         this_ptr_conv.is_owned = false;
25825         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
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 void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25836         LDKRawInvoice this_ptr_conv;
25837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25838         this_ptr_conv.is_owned = false;
25839         LDKRawDataPart val_conv;
25840         val_conv.inner = (void*)(val & (~1));
25841         val_conv.is_owned = (val & 1) || (val == 0);
25842         val_conv = RawDataPart_clone(&val_conv);
25843         RawInvoice_set_data(&this_ptr_conv, val_conv);
25844 }
25845
25846 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25847         LDKRawInvoice a_conv;
25848         a_conv.inner = (void*)(a & (~1));
25849         a_conv.is_owned = false;
25850         LDKRawInvoice b_conv;
25851         b_conv.inner = (void*)(b & (~1));
25852         b_conv.is_owned = false;
25853         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
25854         return ret_val;
25855 }
25856
25857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25858         LDKRawInvoice orig_conv;
25859         orig_conv.inner = (void*)(orig & (~1));
25860         orig_conv.is_owned = false;
25861         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
25862         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25863         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25864         uint64_t ret_ref = (uint64_t)ret_var.inner;
25865         if (ret_var.is_owned) {
25866                 ret_ref |= 1;
25867         }
25868         return ret_ref;
25869 }
25870
25871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25872         LDKRawDataPart this_obj_conv;
25873         this_obj_conv.inner = (void*)(this_obj & (~1));
25874         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25875         RawDataPart_free(this_obj_conv);
25876 }
25877
25878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
25879         LDKRawDataPart this_ptr_conv;
25880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25881         this_ptr_conv.is_owned = false;
25882         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
25883         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25884         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25885         uint64_t ret_ref = (uint64_t)ret_var.inner;
25886         if (ret_var.is_owned) {
25887                 ret_ref |= 1;
25888         }
25889         return ret_ref;
25890 }
25891
25892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25893         LDKRawDataPart this_ptr_conv;
25894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25895         this_ptr_conv.is_owned = false;
25896         LDKPositiveTimestamp val_conv;
25897         val_conv.inner = (void*)(val & (~1));
25898         val_conv.is_owned = (val & 1) || (val == 0);
25899         val_conv = PositiveTimestamp_clone(&val_conv);
25900         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
25901 }
25902
25903 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25904         LDKRawDataPart a_conv;
25905         a_conv.inner = (void*)(a & (~1));
25906         a_conv.is_owned = false;
25907         LDKRawDataPart b_conv;
25908         b_conv.inner = (void*)(b & (~1));
25909         b_conv.is_owned = false;
25910         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
25911         return ret_val;
25912 }
25913
25914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25915         LDKRawDataPart orig_conv;
25916         orig_conv.inner = (void*)(orig & (~1));
25917         orig_conv.is_owned = false;
25918         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
25919         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25920         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25921         uint64_t ret_ref = (uint64_t)ret_var.inner;
25922         if (ret_var.is_owned) {
25923                 ret_ref |= 1;
25924         }
25925         return ret_ref;
25926 }
25927
25928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25929         LDKPositiveTimestamp this_obj_conv;
25930         this_obj_conv.inner = (void*)(this_obj & (~1));
25931         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25932         PositiveTimestamp_free(this_obj_conv);
25933 }
25934
25935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25936         LDKPositiveTimestamp a_conv;
25937         a_conv.inner = (void*)(a & (~1));
25938         a_conv.is_owned = false;
25939         LDKPositiveTimestamp b_conv;
25940         b_conv.inner = (void*)(b & (~1));
25941         b_conv.is_owned = false;
25942         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
25943         return ret_val;
25944 }
25945
25946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25947         LDKPositiveTimestamp orig_conv;
25948         orig_conv.inner = (void*)(orig & (~1));
25949         orig_conv.is_owned = false;
25950         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
25951         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25952         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25953         uint64_t ret_ref = (uint64_t)ret_var.inner;
25954         if (ret_var.is_owned) {
25955                 ret_ref |= 1;
25956         }
25957         return ret_ref;
25958 }
25959
25960 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25961         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
25962         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
25963         return ret_conv;
25964 }
25965
25966 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
25967         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
25968         return ret_conv;
25969 }
25970
25971 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
25972         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
25973         return ret_conv;
25974 }
25975
25976 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
25977         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
25978         return ret_conv;
25979 }
25980
25981 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
25982         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
25983         return ret_conv;
25984 }
25985
25986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25987         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
25988         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
25989         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
25990         return ret_val;
25991 }
25992
25993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
25994         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
25995         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
25996         return ret_val;
25997 }
25998
25999 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26000         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
26001         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
26002         return ret_conv;
26003 }
26004
26005 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
26006         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
26007         return ret_conv;
26008 }
26009
26010 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
26011         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
26012         return ret_conv;
26013 }
26014
26015 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
26016         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
26017         return ret_conv;
26018 }
26019
26020 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
26021         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
26022         return ret_conv;
26023 }
26024
26025 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
26026         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
26027         return ret_conv;
26028 }
26029
26030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26031         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
26032         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
26033         jboolean ret_val = Currency_eq(a_conv, b_conv);
26034         return ret_val;
26035 }
26036
26037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26038         LDKSha256 this_obj_conv;
26039         this_obj_conv.inner = (void*)(this_obj & (~1));
26040         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26041         Sha256_free(this_obj_conv);
26042 }
26043
26044 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26045         LDKSha256 a_conv;
26046         a_conv.inner = (void*)(a & (~1));
26047         a_conv.is_owned = false;
26048         LDKSha256 b_conv;
26049         b_conv.inner = (void*)(b & (~1));
26050         b_conv.is_owned = false;
26051         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
26052         return ret_val;
26053 }
26054
26055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26056         LDKSha256 orig_conv;
26057         orig_conv.inner = (void*)(orig & (~1));
26058         orig_conv.is_owned = false;
26059         LDKSha256 ret_var = Sha256_clone(&orig_conv);
26060         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26061         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26062         uint64_t ret_ref = (uint64_t)ret_var.inner;
26063         if (ret_var.is_owned) {
26064                 ret_ref |= 1;
26065         }
26066         return ret_ref;
26067 }
26068
26069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26070         LDKDescription this_obj_conv;
26071         this_obj_conv.inner = (void*)(this_obj & (~1));
26072         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26073         Description_free(this_obj_conv);
26074 }
26075
26076 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26077         LDKDescription a_conv;
26078         a_conv.inner = (void*)(a & (~1));
26079         a_conv.is_owned = false;
26080         LDKDescription b_conv;
26081         b_conv.inner = (void*)(b & (~1));
26082         b_conv.is_owned = false;
26083         jboolean ret_val = Description_eq(&a_conv, &b_conv);
26084         return ret_val;
26085 }
26086
26087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26088         LDKDescription orig_conv;
26089         orig_conv.inner = (void*)(orig & (~1));
26090         orig_conv.is_owned = false;
26091         LDKDescription ret_var = Description_clone(&orig_conv);
26092         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26093         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26094         uint64_t ret_ref = (uint64_t)ret_var.inner;
26095         if (ret_var.is_owned) {
26096                 ret_ref |= 1;
26097         }
26098         return ret_ref;
26099 }
26100
26101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26102         LDKPayeePubKey this_obj_conv;
26103         this_obj_conv.inner = (void*)(this_obj & (~1));
26104         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26105         PayeePubKey_free(this_obj_conv);
26106 }
26107
26108 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26109         LDKPayeePubKey a_conv;
26110         a_conv.inner = (void*)(a & (~1));
26111         a_conv.is_owned = false;
26112         LDKPayeePubKey b_conv;
26113         b_conv.inner = (void*)(b & (~1));
26114         b_conv.is_owned = false;
26115         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
26116         return ret_val;
26117 }
26118
26119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26120         LDKPayeePubKey orig_conv;
26121         orig_conv.inner = (void*)(orig & (~1));
26122         orig_conv.is_owned = false;
26123         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
26124         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26125         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26126         uint64_t ret_ref = (uint64_t)ret_var.inner;
26127         if (ret_var.is_owned) {
26128                 ret_ref |= 1;
26129         }
26130         return ret_ref;
26131 }
26132
26133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26134         LDKExpiryTime this_obj_conv;
26135         this_obj_conv.inner = (void*)(this_obj & (~1));
26136         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26137         ExpiryTime_free(this_obj_conv);
26138 }
26139
26140 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26141         LDKExpiryTime a_conv;
26142         a_conv.inner = (void*)(a & (~1));
26143         a_conv.is_owned = false;
26144         LDKExpiryTime b_conv;
26145         b_conv.inner = (void*)(b & (~1));
26146         b_conv.is_owned = false;
26147         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
26148         return ret_val;
26149 }
26150
26151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26152         LDKExpiryTime orig_conv;
26153         orig_conv.inner = (void*)(orig & (~1));
26154         orig_conv.is_owned = false;
26155         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
26156         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26157         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26158         uint64_t ret_ref = (uint64_t)ret_var.inner;
26159         if (ret_var.is_owned) {
26160                 ret_ref |= 1;
26161         }
26162         return ret_ref;
26163 }
26164
26165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26166         LDKMinFinalCltvExpiry this_obj_conv;
26167         this_obj_conv.inner = (void*)(this_obj & (~1));
26168         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26169         MinFinalCltvExpiry_free(this_obj_conv);
26170 }
26171
26172 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26173         LDKMinFinalCltvExpiry a_conv;
26174         a_conv.inner = (void*)(a & (~1));
26175         a_conv.is_owned = false;
26176         LDKMinFinalCltvExpiry b_conv;
26177         b_conv.inner = (void*)(b & (~1));
26178         b_conv.is_owned = false;
26179         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
26180         return ret_val;
26181 }
26182
26183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26184         LDKMinFinalCltvExpiry orig_conv;
26185         orig_conv.inner = (void*)(orig & (~1));
26186         orig_conv.is_owned = false;
26187         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
26188         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26189         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26190         uint64_t ret_ref = (uint64_t)ret_var.inner;
26191         if (ret_var.is_owned) {
26192                 ret_ref |= 1;
26193         }
26194         return ret_ref;
26195 }
26196
26197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26198         if ((this_ptr & 1) != 0) return;
26199         LDKFallback this_ptr_conv = *(LDKFallback*)(((uint64_t)this_ptr) & ~1);
26200         FREE((void*)this_ptr);
26201         Fallback_free(this_ptr_conv);
26202 }
26203
26204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26205         LDKFallback* orig_conv = (LDKFallback*)orig;
26206         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26207         *ret_copy = Fallback_clone(orig_conv);
26208         uint64_t ret_ref = (uint64_t)ret_copy;
26209         return ret_ref;
26210 }
26211
26212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
26213         
26214         LDKCVec_u8Z program_ref;
26215         program_ref.datalen = (*env)->GetArrayLength(env, program);
26216         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
26217         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
26218         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26219         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
26220         uint64_t ret_ref = (uint64_t)ret_copy;
26221         return ret_ref;
26222 }
26223
26224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
26225         LDKTwentyBytes a_ref;
26226         CHECK((*env)->GetArrayLength(env, a) == 20);
26227         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
26228         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26229         *ret_copy = Fallback_pub_key_hash(a_ref);
26230         uint64_t ret_ref = (uint64_t)ret_copy;
26231         return ret_ref;
26232 }
26233
26234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
26235         LDKTwentyBytes a_ref;
26236         CHECK((*env)->GetArrayLength(env, a) == 20);
26237         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
26238         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
26239         *ret_copy = Fallback_script_hash(a_ref);
26240         uint64_t ret_ref = (uint64_t)ret_copy;
26241         return ret_ref;
26242 }
26243
26244 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26245         LDKFallback* a_conv = (LDKFallback*)a;
26246         LDKFallback* b_conv = (LDKFallback*)b;
26247         jboolean ret_val = Fallback_eq(a_conv, b_conv);
26248         return ret_val;
26249 }
26250
26251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26252         LDKInvoiceSignature this_obj_conv;
26253         this_obj_conv.inner = (void*)(this_obj & (~1));
26254         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26255         InvoiceSignature_free(this_obj_conv);
26256 }
26257
26258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26259         LDKInvoiceSignature a_conv;
26260         a_conv.inner = (void*)(a & (~1));
26261         a_conv.is_owned = false;
26262         LDKInvoiceSignature b_conv;
26263         b_conv.inner = (void*)(b & (~1));
26264         b_conv.is_owned = false;
26265         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
26266         return ret_val;
26267 }
26268
26269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26270         LDKInvoiceSignature orig_conv;
26271         orig_conv.inner = (void*)(orig & (~1));
26272         orig_conv.is_owned = false;
26273         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
26274         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26275         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26276         uint64_t ret_ref = (uint64_t)ret_var.inner;
26277         if (ret_var.is_owned) {
26278                 ret_ref |= 1;
26279         }
26280         return ret_ref;
26281 }
26282
26283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26284         LDKPrivateRoute this_obj_conv;
26285         this_obj_conv.inner = (void*)(this_obj & (~1));
26286         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26287         PrivateRoute_free(this_obj_conv);
26288 }
26289
26290 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26291         LDKPrivateRoute a_conv;
26292         a_conv.inner = (void*)(a & (~1));
26293         a_conv.is_owned = false;
26294         LDKPrivateRoute b_conv;
26295         b_conv.inner = (void*)(b & (~1));
26296         b_conv.is_owned = false;
26297         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
26298         return ret_val;
26299 }
26300
26301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26302         LDKPrivateRoute orig_conv;
26303         orig_conv.inner = (void*)(orig & (~1));
26304         orig_conv.is_owned = false;
26305         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
26306         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26307         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26308         uint64_t ret_ref = (uint64_t)ret_var.inner;
26309         if (ret_var.is_owned) {
26310                 ret_ref |= 1;
26311         }
26312         return ret_ref;
26313 }
26314
26315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
26316         LDKSignedRawInvoice this_arg_conv;
26317         this_arg_conv.inner = (void*)(this_arg & (~1));
26318         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26319         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
26320         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
26321         *ret_ref = SignedRawInvoice_into_parts(this_arg_conv);
26322         return (uint64_t)ret_ref;
26323 }
26324
26325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
26326         LDKSignedRawInvoice this_arg_conv;
26327         this_arg_conv.inner = (void*)(this_arg & (~1));
26328         this_arg_conv.is_owned = false;
26329         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
26330         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26331         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26332         uint64_t ret_ref = (uint64_t)ret_var.inner;
26333         if (ret_var.is_owned) {
26334                 ret_ref |= 1;
26335         }
26336         return ret_ref;
26337 }
26338
26339 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26340         LDKSignedRawInvoice this_arg_conv;
26341         this_arg_conv.inner = (void*)(this_arg & (~1));
26342         this_arg_conv.is_owned = false;
26343         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26344         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
26345         return ret_arr;
26346 }
26347
26348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
26349         LDKSignedRawInvoice this_arg_conv;
26350         this_arg_conv.inner = (void*)(this_arg & (~1));
26351         this_arg_conv.is_owned = false;
26352         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
26353         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26354         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26355         uint64_t ret_ref = (uint64_t)ret_var.inner;
26356         if (ret_var.is_owned) {
26357                 ret_ref |= 1;
26358         }
26359         return ret_ref;
26360 }
26361
26362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
26363         LDKSignedRawInvoice this_arg_conv;
26364         this_arg_conv.inner = (void*)(this_arg & (~1));
26365         this_arg_conv.is_owned = false;
26366         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
26367         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
26368         return (uint64_t)ret_conv;
26369 }
26370
26371 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
26372         LDKSignedRawInvoice this_arg_conv;
26373         this_arg_conv.inner = (void*)(this_arg & (~1));
26374         this_arg_conv.is_owned = false;
26375         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
26376         return ret_val;
26377 }
26378
26379 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26380         LDKRawInvoice this_arg_conv;
26381         this_arg_conv.inner = (void*)(this_arg & (~1));
26382         this_arg_conv.is_owned = false;
26383         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26384         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
26385         return ret_arr;
26386 }
26387
26388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26389         LDKRawInvoice this_arg_conv;
26390         this_arg_conv.inner = (void*)(this_arg & (~1));
26391         this_arg_conv.is_owned = false;
26392         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
26393         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26394         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26395         uint64_t ret_ref = (uint64_t)ret_var.inner;
26396         if (ret_var.is_owned) {
26397                 ret_ref |= 1;
26398         }
26399         return ret_ref;
26400 }
26401
26402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
26403         LDKRawInvoice this_arg_conv;
26404         this_arg_conv.inner = (void*)(this_arg & (~1));
26405         this_arg_conv.is_owned = false;
26406         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
26407         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26408         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26409         uint64_t ret_ref = (uint64_t)ret_var.inner;
26410         if (ret_var.is_owned) {
26411                 ret_ref |= 1;
26412         }
26413         return ret_ref;
26414 }
26415
26416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
26417         LDKRawInvoice this_arg_conv;
26418         this_arg_conv.inner = (void*)(this_arg & (~1));
26419         this_arg_conv.is_owned = false;
26420         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
26421         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26422         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26423         uint64_t ret_ref = (uint64_t)ret_var.inner;
26424         if (ret_var.is_owned) {
26425                 ret_ref |= 1;
26426         }
26427         return ret_ref;
26428 }
26429
26430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26431         LDKRawInvoice this_arg_conv;
26432         this_arg_conv.inner = (void*)(this_arg & (~1));
26433         this_arg_conv.is_owned = false;
26434         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
26435         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26436         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26437         uint64_t ret_ref = (uint64_t)ret_var.inner;
26438         if (ret_var.is_owned) {
26439                 ret_ref |= 1;
26440         }
26441         return ret_ref;
26442 }
26443
26444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
26445         LDKRawInvoice this_arg_conv;
26446         this_arg_conv.inner = (void*)(this_arg & (~1));
26447         this_arg_conv.is_owned = false;
26448         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
26449         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26450         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26451         uint64_t ret_ref = (uint64_t)ret_var.inner;
26452         if (ret_var.is_owned) {
26453                 ret_ref |= 1;
26454         }
26455         return ret_ref;
26456 }
26457
26458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
26459         LDKRawInvoice this_arg_conv;
26460         this_arg_conv.inner = (void*)(this_arg & (~1));
26461         this_arg_conv.is_owned = false;
26462         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
26463         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26464         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26465         uint64_t ret_ref = (uint64_t)ret_var.inner;
26466         if (ret_var.is_owned) {
26467                 ret_ref |= 1;
26468         }
26469         return ret_ref;
26470 }
26471
26472 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
26473         LDKRawInvoice this_arg_conv;
26474         this_arg_conv.inner = (void*)(this_arg & (~1));
26475         this_arg_conv.is_owned = false;
26476         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26477         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
26478         return ret_arr;
26479 }
26480
26481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
26482         LDKRawInvoice this_arg_conv;
26483         this_arg_conv.inner = (void*)(this_arg & (~1));
26484         this_arg_conv.is_owned = false;
26485         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
26486         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26487         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26488         uint64_t ret_ref = (uint64_t)ret_var.inner;
26489         if (ret_var.is_owned) {
26490                 ret_ref |= 1;
26491         }
26492         return ret_ref;
26493 }
26494
26495 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
26496         LDKRawInvoice this_arg_conv;
26497         this_arg_conv.inner = (void*)(this_arg & (~1));
26498         this_arg_conv.is_owned = false;
26499         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
26500         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26501         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26502         for (size_t o = 0; o < ret_var.datalen; o++) {
26503                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
26504                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26505                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26506                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
26507                 if (ret_conv_14_var.is_owned) {
26508                         ret_conv_14_ref |= 1;
26509                 }
26510                 ret_arr_ptr[o] = ret_conv_14_ref;
26511         }
26512         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26513         FREE(ret_var.data);
26514         return ret_arr;
26515 }
26516
26517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
26518         LDKRawInvoice this_arg_conv;
26519         this_arg_conv.inner = (void*)(this_arg & (~1));
26520         this_arg_conv.is_owned = false;
26521         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26522         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
26523         uint64_t ret_ref = (uint64_t)ret_copy;
26524         return ret_ref;
26525 }
26526
26527 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
26528         LDKRawInvoice this_arg_conv;
26529         this_arg_conv.inner = (void*)(this_arg & (~1));
26530         this_arg_conv.is_owned = false;
26531         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
26532         return ret_conv;
26533 }
26534
26535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
26536         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
26537         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
26538         return (uint64_t)ret_conv;
26539 }
26540
26541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
26542         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
26543         *ret_conv = PositiveTimestamp_from_system_time(time);
26544         return (uint64_t)ret_conv;
26545 }
26546
26547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
26548         LDKPositiveTimestamp this_arg_conv;
26549         this_arg_conv.inner = (void*)(this_arg & (~1));
26550         this_arg_conv.is_owned = false;
26551         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
26552         return ret_val;
26553 }
26554
26555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
26556         LDKPositiveTimestamp this_arg_conv;
26557         this_arg_conv.inner = (void*)(this_arg & (~1));
26558         this_arg_conv.is_owned = false;
26559         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
26560         return ret_val;
26561 }
26562
26563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
26564         LDKInvoice this_arg_conv;
26565         this_arg_conv.inner = (void*)(this_arg & (~1));
26566         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26567         this_arg_conv = Invoice_clone(&this_arg_conv);
26568         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
26569         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26570         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26571         uint64_t ret_ref = (uint64_t)ret_var.inner;
26572         if (ret_var.is_owned) {
26573                 ret_ref |= 1;
26574         }
26575         return ret_ref;
26576 }
26577
26578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
26579         LDKInvoice this_arg_conv;
26580         this_arg_conv.inner = (void*)(this_arg & (~1));
26581         this_arg_conv.is_owned = false;
26582         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
26583         *ret_conv = Invoice_check_signature(&this_arg_conv);
26584         return (uint64_t)ret_conv;
26585 }
26586
26587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
26588         LDKSignedRawInvoice signed_invoice_conv;
26589         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
26590         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
26591         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
26592         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
26593         *ret_conv = Invoice_from_signed(signed_invoice_conv);
26594         return (uint64_t)ret_conv;
26595 }
26596
26597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
26598         LDKInvoice this_arg_conv;
26599         this_arg_conv.inner = (void*)(this_arg & (~1));
26600         this_arg_conv.is_owned = false;
26601         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
26602         return ret_val;
26603 }
26604
26605 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
26606         LDKInvoice this_arg_conv;
26607         this_arg_conv.inner = (void*)(this_arg & (~1));
26608         this_arg_conv.is_owned = false;
26609         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26610         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
26611         return ret_arr;
26612 }
26613
26614 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
26615         LDKInvoice this_arg_conv;
26616         this_arg_conv.inner = (void*)(this_arg & (~1));
26617         this_arg_conv.is_owned = false;
26618         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26619         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
26620         return ret_arr;
26621 }
26622
26623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
26624         LDKInvoice this_arg_conv;
26625         this_arg_conv.inner = (void*)(this_arg & (~1));
26626         this_arg_conv.is_owned = false;
26627         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26628         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, Invoice_payment_secret(&this_arg_conv).data);
26629         return ret_arr;
26630 }
26631
26632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
26633         LDKInvoice this_arg_conv;
26634         this_arg_conv.inner = (void*)(this_arg & (~1));
26635         this_arg_conv.is_owned = false;
26636         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
26637         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26638         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26639         uint64_t ret_ref = (uint64_t)ret_var.inner;
26640         if (ret_var.is_owned) {
26641                 ret_ref |= 1;
26642         }
26643         return ret_ref;
26644 }
26645
26646 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
26647         LDKInvoice this_arg_conv;
26648         this_arg_conv.inner = (void*)(this_arg & (~1));
26649         this_arg_conv.is_owned = false;
26650         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26651         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
26652         return ret_arr;
26653 }
26654
26655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
26656         LDKInvoice this_arg_conv;
26657         this_arg_conv.inner = (void*)(this_arg & (~1));
26658         this_arg_conv.is_owned = false;
26659         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
26660         return ret_val;
26661 }
26662
26663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
26664         LDKInvoice this_arg_conv;
26665         this_arg_conv.inner = (void*)(this_arg & (~1));
26666         this_arg_conv.is_owned = false;
26667         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
26668         return ret_val;
26669 }
26670
26671 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
26672         LDKInvoice this_arg_conv;
26673         this_arg_conv.inner = (void*)(this_arg & (~1));
26674         this_arg_conv.is_owned = false;
26675         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
26676         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26677         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26678         for (size_t o = 0; o < ret_var.datalen; o++) {
26679                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
26680                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26681                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26682                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
26683                 if (ret_conv_14_var.is_owned) {
26684                         ret_conv_14_ref |= 1;
26685                 }
26686                 ret_arr_ptr[o] = ret_conv_14_ref;
26687         }
26688         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26689         FREE(ret_var.data);
26690         return ret_arr;
26691 }
26692
26693 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
26694         LDKInvoice this_arg_conv;
26695         this_arg_conv.inner = (void*)(this_arg & (~1));
26696         this_arg_conv.is_owned = false;
26697         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
26698         int64_tArray ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26699         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26700         for (size_t l = 0; l < ret_var.datalen; l++) {
26701                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
26702                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26703                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26704                 uint64_t ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
26705                 if (ret_conv_11_var.is_owned) {
26706                         ret_conv_11_ref |= 1;
26707                 }
26708                 ret_arr_ptr[l] = ret_conv_11_ref;
26709         }
26710         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26711         FREE(ret_var.data);
26712         return ret_arr;
26713 }
26714
26715 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
26716         LDKInvoice this_arg_conv;
26717         this_arg_conv.inner = (void*)(this_arg & (~1));
26718         this_arg_conv.is_owned = false;
26719         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
26720         return ret_conv;
26721 }
26722
26723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
26724         LDKInvoice this_arg_conv;
26725         this_arg_conv.inner = (void*)(this_arg & (~1));
26726         this_arg_conv.is_owned = false;
26727         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26728         *ret_copy = Invoice_amount_pico_btc(&this_arg_conv);
26729         uint64_t ret_ref = (uint64_t)ret_copy;
26730         return ret_ref;
26731 }
26732
26733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
26734         LDKStr description_conv = java_to_owned_str(env, description);
26735         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
26736         *ret_conv = Description_new(description_conv);
26737         return (uint64_t)ret_conv;
26738 }
26739
26740 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
26741         LDKDescription this_arg_conv;
26742         this_arg_conv.inner = (void*)(this_arg & (~1));
26743         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26744         this_arg_conv = Description_clone(&this_arg_conv);
26745         LDKStr ret_str = Description_into_inner(this_arg_conv);
26746         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26747         Str_free(ret_str);
26748         return ret_conv;
26749 }
26750
26751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
26752         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
26753         *ret_conv = ExpiryTime_from_seconds(seconds);
26754         return (uint64_t)ret_conv;
26755 }
26756
26757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
26758         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
26759         *ret_conv = ExpiryTime_from_duration(duration);
26760         return (uint64_t)ret_conv;
26761 }
26762
26763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
26764         LDKExpiryTime this_arg_conv;
26765         this_arg_conv.inner = (void*)(this_arg & (~1));
26766         this_arg_conv.is_owned = false;
26767         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
26768         return ret_val;
26769 }
26770
26771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
26772         LDKExpiryTime this_arg_conv;
26773         this_arg_conv.inner = (void*)(this_arg & (~1));
26774         this_arg_conv.is_owned = false;
26775         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
26776         return ret_val;
26777 }
26778
26779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
26780         LDKRouteHint hops_conv;
26781         hops_conv.inner = (void*)(hops & (~1));
26782         hops_conv.is_owned = (hops & 1) || (hops == 0);
26783         hops_conv = RouteHint_clone(&hops_conv);
26784         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
26785         *ret_conv = PrivateRoute_new(hops_conv);
26786         return (uint64_t)ret_conv;
26787 }
26788
26789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
26790         LDKPrivateRoute this_arg_conv;
26791         this_arg_conv.inner = (void*)(this_arg & (~1));
26792         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
26793         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
26794         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
26795         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26796         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26797         uint64_t ret_ref = (uint64_t)ret_var.inner;
26798         if (ret_var.is_owned) {
26799                 ret_ref |= 1;
26800         }
26801         return ret_ref;
26802 }
26803
26804 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26805         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
26806         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
26807         return ret_conv;
26808 }
26809
26810 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
26811         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
26812         return ret_conv;
26813 }
26814
26815 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
26816         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
26817         return ret_conv;
26818 }
26819
26820 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
26821         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
26822         return ret_conv;
26823 }
26824
26825 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1expiry_1time_1out_1of_1bounds(JNIEnv *env, jclass clz) {
26826         jclass ret_conv = LDKCreationError_to_java(env, CreationError_expiry_time_out_of_bounds());
26827         return ret_conv;
26828 }
26829
26830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26831         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
26832         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
26833         jboolean ret_val = CreationError_eq(a_conv, b_conv);
26834         return ret_val;
26835 }
26836
26837 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26838         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
26839         LDKStr ret_str = CreationError_to_str(o_conv);
26840         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26841         Str_free(ret_str);
26842         return ret_conv;
26843 }
26844
26845 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26846         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
26847         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
26848         return ret_conv;
26849 }
26850
26851 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
26852         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
26853         return ret_conv;
26854 }
26855
26856 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
26857         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
26858         return ret_conv;
26859 }
26860
26861 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
26862         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
26863         return ret_conv;
26864 }
26865
26866 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
26867         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
26868         return ret_conv;
26869 }
26870
26871 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
26872         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
26873         return ret_conv;
26874 }
26875
26876 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
26877         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
26878         return ret_conv;
26879 }
26880
26881 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
26882         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
26883         return ret_conv;
26884 }
26885
26886 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
26887         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
26888         return ret_conv;
26889 }
26890
26891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26892         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
26893         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
26894         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
26895         return ret_val;
26896 }
26897
26898 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26899         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
26900         LDKStr ret_str = SemanticError_to_str(o_conv);
26901         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26902         Str_free(ret_str);
26903         return ret_conv;
26904 }
26905
26906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26907         if ((this_ptr & 1) != 0) return;
26908         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(((uint64_t)this_ptr) & ~1);
26909         FREE((void*)this_ptr);
26910         SignOrCreationError_free(this_ptr_conv);
26911 }
26912
26913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26914         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
26915         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26916         *ret_copy = SignOrCreationError_clone(orig_conv);
26917         uint64_t ret_ref = (uint64_t)ret_copy;
26918         return ret_ref;
26919 }
26920
26921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
26922         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26923         *ret_copy = SignOrCreationError_sign_error();
26924         uint64_t ret_ref = (uint64_t)ret_copy;
26925         return ret_ref;
26926 }
26927
26928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
26929         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
26930         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
26931         *ret_copy = SignOrCreationError_creation_error(a_conv);
26932         uint64_t ret_ref = (uint64_t)ret_copy;
26933         return ret_ref;
26934 }
26935
26936 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26937         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
26938         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
26939         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
26940         return ret_val;
26941 }
26942
26943 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26944         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
26945         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
26946         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26947         Str_free(ret_str);
26948         return ret_conv;
26949 }
26950
26951 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) {
26952         LDKChannelManager channelmanager_conv;
26953         channelmanager_conv.inner = (void*)(channelmanager & (~1));
26954         channelmanager_conv.is_owned = false;
26955         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
26956         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26957                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26958                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26959         }
26960         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
26961         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1);
26962         LDKStr description_conv = java_to_owned_str(env, description);
26963         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
26964         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
26965         return (uint64_t)ret_conv;
26966 }
26967
26968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26969         LDKStr s_conv = java_to_owned_str(env, s);
26970         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
26971         *ret_conv = SiPrefix_from_str(s_conv);
26972         return (uint64_t)ret_conv;
26973 }
26974
26975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26976         LDKStr s_conv = java_to_owned_str(env, s);
26977         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
26978         *ret_conv = Invoice_from_str(s_conv);
26979         return (uint64_t)ret_conv;
26980 }
26981
26982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
26983         LDKStr s_conv = java_to_owned_str(env, s);
26984         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
26985         *ret_conv = SignedRawInvoice_from_str(s_conv);
26986         return (uint64_t)ret_conv;
26987 }
26988
26989 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
26990         LDKInvoice o_conv;
26991         o_conv.inner = (void*)(o & (~1));
26992         o_conv.is_owned = false;
26993         LDKStr ret_str = Invoice_to_str(&o_conv);
26994         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26995         Str_free(ret_str);
26996         return ret_conv;
26997 }
26998
26999 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27000         LDKSignedRawInvoice o_conv;
27001         o_conv.inner = (void*)(o & (~1));
27002         o_conv.is_owned = false;
27003         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
27004         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27005         Str_free(ret_str);
27006         return ret_conv;
27007 }
27008
27009 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27010         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
27011         LDKStr ret_str = Currency_to_str(o_conv);
27012         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27013         Str_free(ret_str);
27014         return ret_conv;
27015 }
27016
27017 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
27018         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
27019         LDKStr ret_str = SiPrefix_to_str(o_conv);
27020         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27021         Str_free(ret_str);
27022         return ret_conv;
27023 }
27024