d812573196c3b8bbc9999e8c0b73b074be06674a
[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 LIKELY(v) __builtin_expect(!!(v), 1)
11 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
12
13 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
14 #define MALLOC(a, _) malloc(a)
15 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
16 #define CHECK_ACCESS(p)
17 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
18 #define DO_ASSERT(a) (void)(a)
19 #define CHECK(a)
20
21 static jmethodID ordinal_meth = NULL;
22 static jmethodID slicedef_meth = NULL;
23 static jclass slicedef_cls = NULL;
24 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
25         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
26         CHECK(ordinal_meth != NULL);
27         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
28         CHECK(slicedef_meth != NULL);
29         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
30         CHECK(slicedef_cls != NULL);
31 }
32
33 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
34         return *((bool*)ptr);
35 }
36 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
37         return *((long*)ptr);
38 }
39 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
40         FREE((void*)ptr);
41 }
42 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
43         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
44         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
45         return ret_arr;
46 }
47 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
48         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
49         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
50         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
51         return ret_arr;
52 }
53 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
54         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
55         vec->datalen = (*env)->GetArrayLength(env, bytes);
56         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
57         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
58         return (uint64_t)vec;
59 }
60 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
61         LDKTransaction *txdata = (LDKTransaction*)ptr;
62         LDKu8slice slice;
63         slice.data = txdata->data;
64         slice.datalen = txdata->datalen;
65         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
66 }
67 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
68         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
69         txdata->datalen = (*env)->GetArrayLength(env, bytes);
70         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
71         txdata->data_is_owned = false;
72         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
73         return (uint64_t)txdata;
74 }
75 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
76         LDKTransaction *tx = (LDKTransaction*)ptr;
77         tx->data_is_owned = true;
78         Transaction_free(*tx);
79         FREE((void*)ptr);
80 }
81 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
82         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
83         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
84         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
85         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
86         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
87         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
88         return (uint64_t)vec->datalen;
89 }
90 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
91         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
92         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
93         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
94         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
95         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
96         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
97         vec->data = NULL;
98         vec->datalen = 0;
99         return (uint64_t)vec;
100 }
101
102 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
103 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
104 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
105 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
106
107 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
108 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
109 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
110
111 typedef jlongArray int64_tArray;
112 typedef jbyteArray int8_tArray;
113
114 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
115         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
116         char* conv_buf = MALLOC(len + 1, "str conv buf");
117         memcpy(conv_buf, chars, len);
118         conv_buf[len] = 0;
119         jstring ret = (*env)->NewStringUTF(env, conv_buf);
120         FREE(conv_buf);
121         return ret;
122 }
123 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
124         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
125         char* newchars = MALLOC(str_len + 1, "String chars");
126         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
127         memcpy(newchars, jchars, str_len);
128         newchars[str_len] = 0;
129         (*env)->ReleaseStringUTFChars(env, str, jchars);
130         LDKStr res = {
131                 .chars = newchars,
132                 .len = str_len,
133                 .chars_is_owned = true
134         };
135         return res;
136 }
137
138 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
139         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
140 }
141 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
142         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
143 }
144 #include "version.c"
145 static jclass arr_of_B_clz = NULL;
146 static jclass arr_of_J_clz = NULL;
147 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
148         arr_of_B_clz = (*env)->FindClass(env, "[B");
149         CHECK(arr_of_B_clz != NULL);
150         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
151         arr_of_J_clz = (*env)->FindClass(env, "[J");
152         CHECK(arr_of_J_clz != NULL);
153         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
154 }
155 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
156 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
157         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
158         if (UNLIKELY((*env)->ExceptionCheck(env))) {
159                 (*env)->ExceptionDescribe(env);
160                 (*env)->FatalError(env, "A call to AccessError.ordinal() from rust threw an exception.");
161         }
162         switch (ord) {
163                 case 0: return LDKAccessError_UnknownChain;
164                 case 1: return LDKAccessError_UnknownTx;
165         }
166         (*env)->FatalError(env, "A call to AccessError.ordinal() from rust returned an invalid value.");
167         abort(); // Unreachable, but will let the compiler know we don't return here
168 }
169 static jclass AccessError_class = NULL;
170 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
171 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
172 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
173         AccessError_class = (*env)->NewGlobalRef(env, clz);
174         CHECK(AccessError_class != NULL);
175         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
176         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
177         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
178         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
179 }
180 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
181         switch (val) {
182                 case LDKAccessError_UnknownChain:
183                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
184                 case LDKAccessError_UnknownTx:
185                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
186                 default: abort();
187         }
188 }
189
190 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
191         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
192         if (UNLIKELY((*env)->ExceptionCheck(env))) {
193                 (*env)->ExceptionDescribe(env);
194                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
195         }
196         switch (ord) {
197                 case 0: return LDKCOption_NoneZ_Some;
198                 case 1: return LDKCOption_NoneZ_None;
199         }
200         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
201         abort(); // Unreachable, but will let the compiler know we don't return here
202 }
203 static jclass COption_NoneZ_class = NULL;
204 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
205 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
206 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
207         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
208         CHECK(COption_NoneZ_class != NULL);
209         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
210         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
211         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
212         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
213 }
214 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
215         switch (val) {
216                 case LDKCOption_NoneZ_Some:
217                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
218                 case LDKCOption_NoneZ_None:
219                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
220                 default: abort();
221         }
222 }
223
224 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
225         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
226         if (UNLIKELY((*env)->ExceptionCheck(env))) {
227                 (*env)->ExceptionDescribe(env);
228                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust threw an exception.");
229         }
230         switch (ord) {
231                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
232                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
233         }
234         (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust returned an invalid value.");
235         abort(); // Unreachable, but will let the compiler know we don't return here
236 }
237 static jclass ChannelMonitorUpdateErr_class = NULL;
238 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
239 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
240 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
241         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
242         CHECK(ChannelMonitorUpdateErr_class != NULL);
243         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
244         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
245         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
246         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
247 }
248 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
249         switch (val) {
250                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
251                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
252                 case LDKChannelMonitorUpdateErr_PermanentFailure:
253                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
254                 default: abort();
255         }
256 }
257
258 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
259         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
260         if (UNLIKELY((*env)->ExceptionCheck(env))) {
261                 (*env)->ExceptionDescribe(env);
262                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
263         }
264         switch (ord) {
265                 case 0: return LDKConfirmationTarget_Background;
266                 case 1: return LDKConfirmationTarget_Normal;
267                 case 2: return LDKConfirmationTarget_HighPriority;
268         }
269         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
270         abort(); // Unreachable, but will let the compiler know we don't return here
271 }
272 static jclass ConfirmationTarget_class = NULL;
273 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
274 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
275 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
276 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
277         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
278         CHECK(ConfirmationTarget_class != NULL);
279         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
280         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
281         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
282         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
283         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
284         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
285 }
286 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
287         switch (val) {
288                 case LDKConfirmationTarget_Background:
289                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
290                 case LDKConfirmationTarget_Normal:
291                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
292                 case LDKConfirmationTarget_HighPriority:
293                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
294                 default: abort();
295         }
296 }
297
298 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
299         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
300         if (UNLIKELY((*env)->ExceptionCheck(env))) {
301                 (*env)->ExceptionDescribe(env);
302                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
303         }
304         switch (ord) {
305                 case 0: return LDKCreationError_DescriptionTooLong;
306                 case 1: return LDKCreationError_RouteTooLong;
307                 case 2: return LDKCreationError_TimestampOutOfBounds;
308                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
309                 case 4: return LDKCreationError_InvalidAmount;
310         }
311         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
312         abort(); // Unreachable, but will let the compiler know we don't return here
313 }
314 static jclass CreationError_class = NULL;
315 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
316 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
317 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
318 static jfieldID CreationError_LDKCreationError_ExpiryTimeOutOfBounds = NULL;
319 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
320 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
321         CreationError_class = (*env)->NewGlobalRef(env, clz);
322         CHECK(CreationError_class != NULL);
323         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
324         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
325         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
326         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
327         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
328         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
329         CreationError_LDKCreationError_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
330         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
331         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
332         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
333 }
334 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
335         switch (val) {
336                 case LDKCreationError_DescriptionTooLong:
337                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
338                 case LDKCreationError_RouteTooLong:
339                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
340                 case LDKCreationError_TimestampOutOfBounds:
341                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
342                 case LDKCreationError_ExpiryTimeOutOfBounds:
343                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
344                 case LDKCreationError_InvalidAmount:
345                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
346                 default: abort();
347         }
348 }
349
350 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
351         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
352         if (UNLIKELY((*env)->ExceptionCheck(env))) {
353                 (*env)->ExceptionDescribe(env);
354                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
355         }
356         switch (ord) {
357                 case 0: return LDKCurrency_Bitcoin;
358                 case 1: return LDKCurrency_BitcoinTestnet;
359                 case 2: return LDKCurrency_Regtest;
360                 case 3: return LDKCurrency_Simnet;
361                 case 4: return LDKCurrency_Signet;
362         }
363         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
364         abort(); // Unreachable, but will let the compiler know we don't return here
365 }
366 static jclass Currency_class = NULL;
367 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
368 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
369 static jfieldID Currency_LDKCurrency_Regtest = NULL;
370 static jfieldID Currency_LDKCurrency_Simnet = NULL;
371 static jfieldID Currency_LDKCurrency_Signet = NULL;
372 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
373         Currency_class = (*env)->NewGlobalRef(env, clz);
374         CHECK(Currency_class != NULL);
375         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
376         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
377         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
378         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
379         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
380         CHECK(Currency_LDKCurrency_Regtest != NULL);
381         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
382         CHECK(Currency_LDKCurrency_Simnet != NULL);
383         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
384         CHECK(Currency_LDKCurrency_Signet != NULL);
385 }
386 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
387         switch (val) {
388                 case LDKCurrency_Bitcoin:
389                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
390                 case LDKCurrency_BitcoinTestnet:
391                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
392                 case LDKCurrency_Regtest:
393                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
394                 case LDKCurrency_Simnet:
395                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
396                 case LDKCurrency_Signet:
397                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
398                 default: abort();
399         }
400 }
401
402 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
403         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
404         if (UNLIKELY((*env)->ExceptionCheck(env))) {
405                 (*env)->ExceptionDescribe(env);
406                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
407         }
408         switch (ord) {
409                 case 0: return LDKIOError_NotFound;
410                 case 1: return LDKIOError_PermissionDenied;
411                 case 2: return LDKIOError_ConnectionRefused;
412                 case 3: return LDKIOError_ConnectionReset;
413                 case 4: return LDKIOError_ConnectionAborted;
414                 case 5: return LDKIOError_NotConnected;
415                 case 6: return LDKIOError_AddrInUse;
416                 case 7: return LDKIOError_AddrNotAvailable;
417                 case 8: return LDKIOError_BrokenPipe;
418                 case 9: return LDKIOError_AlreadyExists;
419                 case 10: return LDKIOError_WouldBlock;
420                 case 11: return LDKIOError_InvalidInput;
421                 case 12: return LDKIOError_InvalidData;
422                 case 13: return LDKIOError_TimedOut;
423                 case 14: return LDKIOError_WriteZero;
424                 case 15: return LDKIOError_Interrupted;
425                 case 16: return LDKIOError_Other;
426                 case 17: return LDKIOError_UnexpectedEof;
427         }
428         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
429         abort(); // Unreachable, but will let the compiler know we don't return here
430 }
431 static jclass IOError_class = NULL;
432 static jfieldID IOError_LDKIOError_NotFound = NULL;
433 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
434 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
435 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
436 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
437 static jfieldID IOError_LDKIOError_NotConnected = NULL;
438 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
439 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
440 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
441 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
442 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
443 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
444 static jfieldID IOError_LDKIOError_InvalidData = NULL;
445 static jfieldID IOError_LDKIOError_TimedOut = NULL;
446 static jfieldID IOError_LDKIOError_WriteZero = NULL;
447 static jfieldID IOError_LDKIOError_Interrupted = NULL;
448 static jfieldID IOError_LDKIOError_Other = NULL;
449 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
450 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
451         IOError_class = (*env)->NewGlobalRef(env, clz);
452         CHECK(IOError_class != NULL);
453         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
454         CHECK(IOError_LDKIOError_NotFound != NULL);
455         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
456         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
457         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
458         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
459         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
460         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
461         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
462         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
463         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
464         CHECK(IOError_LDKIOError_NotConnected != NULL);
465         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
466         CHECK(IOError_LDKIOError_AddrInUse != NULL);
467         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
468         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
469         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
470         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
471         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
472         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
473         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
474         CHECK(IOError_LDKIOError_WouldBlock != NULL);
475         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
476         CHECK(IOError_LDKIOError_InvalidInput != NULL);
477         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
478         CHECK(IOError_LDKIOError_InvalidData != NULL);
479         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
480         CHECK(IOError_LDKIOError_TimedOut != NULL);
481         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
482         CHECK(IOError_LDKIOError_WriteZero != NULL);
483         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
484         CHECK(IOError_LDKIOError_Interrupted != NULL);
485         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
486         CHECK(IOError_LDKIOError_Other != NULL);
487         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
488         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
489 }
490 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
491         switch (val) {
492                 case LDKIOError_NotFound:
493                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
494                 case LDKIOError_PermissionDenied:
495                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
496                 case LDKIOError_ConnectionRefused:
497                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
498                 case LDKIOError_ConnectionReset:
499                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
500                 case LDKIOError_ConnectionAborted:
501                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
502                 case LDKIOError_NotConnected:
503                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
504                 case LDKIOError_AddrInUse:
505                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
506                 case LDKIOError_AddrNotAvailable:
507                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
508                 case LDKIOError_BrokenPipe:
509                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
510                 case LDKIOError_AlreadyExists:
511                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
512                 case LDKIOError_WouldBlock:
513                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
514                 case LDKIOError_InvalidInput:
515                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
516                 case LDKIOError_InvalidData:
517                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
518                 case LDKIOError_TimedOut:
519                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
520                 case LDKIOError_WriteZero:
521                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
522                 case LDKIOError_Interrupted:
523                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
524                 case LDKIOError_Other:
525                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
526                 case LDKIOError_UnexpectedEof:
527                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
528                 default: abort();
529         }
530 }
531
532 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
533         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
534         if (UNLIKELY((*env)->ExceptionCheck(env))) {
535                 (*env)->ExceptionDescribe(env);
536                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
537         }
538         switch (ord) {
539                 case 0: return LDKLevel_Gossip;
540                 case 1: return LDKLevel_Trace;
541                 case 2: return LDKLevel_Debug;
542                 case 3: return LDKLevel_Info;
543                 case 4: return LDKLevel_Warn;
544                 case 5: return LDKLevel_Error;
545         }
546         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
547         abort(); // Unreachable, but will let the compiler know we don't return here
548 }
549 static jclass Level_class = NULL;
550 static jfieldID Level_LDKLevel_Gossip = NULL;
551 static jfieldID Level_LDKLevel_Trace = NULL;
552 static jfieldID Level_LDKLevel_Debug = NULL;
553 static jfieldID Level_LDKLevel_Info = NULL;
554 static jfieldID Level_LDKLevel_Warn = NULL;
555 static jfieldID Level_LDKLevel_Error = NULL;
556 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
557         Level_class = (*env)->NewGlobalRef(env, clz);
558         CHECK(Level_class != NULL);
559         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
560         CHECK(Level_LDKLevel_Gossip != NULL);
561         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
562         CHECK(Level_LDKLevel_Trace != NULL);
563         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
564         CHECK(Level_LDKLevel_Debug != NULL);
565         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
566         CHECK(Level_LDKLevel_Info != NULL);
567         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
568         CHECK(Level_LDKLevel_Warn != NULL);
569         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
570         CHECK(Level_LDKLevel_Error != NULL);
571 }
572 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
573         switch (val) {
574                 case LDKLevel_Gossip:
575                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
576                 case LDKLevel_Trace:
577                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
578                 case LDKLevel_Debug:
579                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
580                 case LDKLevel_Info:
581                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
582                 case LDKLevel_Warn:
583                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
584                 case LDKLevel_Error:
585                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
586                 default: abort();
587         }
588 }
589
590 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
591         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
592         if (UNLIKELY((*env)->ExceptionCheck(env))) {
593                 (*env)->ExceptionDescribe(env);
594                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
595         }
596         switch (ord) {
597                 case 0: return LDKNetwork_Bitcoin;
598                 case 1: return LDKNetwork_Testnet;
599                 case 2: return LDKNetwork_Regtest;
600                 case 3: return LDKNetwork_Signet;
601         }
602         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
603         abort(); // Unreachable, but will let the compiler know we don't return here
604 }
605 static jclass Network_class = NULL;
606 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
607 static jfieldID Network_LDKNetwork_Testnet = NULL;
608 static jfieldID Network_LDKNetwork_Regtest = NULL;
609 static jfieldID Network_LDKNetwork_Signet = NULL;
610 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
611         Network_class = (*env)->NewGlobalRef(env, clz);
612         CHECK(Network_class != NULL);
613         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
614         CHECK(Network_LDKNetwork_Bitcoin != NULL);
615         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
616         CHECK(Network_LDKNetwork_Testnet != NULL);
617         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
618         CHECK(Network_LDKNetwork_Regtest != NULL);
619         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
620         CHECK(Network_LDKNetwork_Signet != NULL);
621 }
622 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
623         switch (val) {
624                 case LDKNetwork_Bitcoin:
625                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
626                 case LDKNetwork_Testnet:
627                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
628                 case LDKNetwork_Regtest:
629                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
630                 case LDKNetwork_Signet:
631                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
632                 default: abort();
633         }
634 }
635
636 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
637         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
638         if (UNLIKELY((*env)->ExceptionCheck(env))) {
639                 (*env)->ExceptionDescribe(env);
640                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
641         }
642         switch (ord) {
643                 case 0: return LDKSecp256k1Error_IncorrectSignature;
644                 case 1: return LDKSecp256k1Error_InvalidMessage;
645                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
646                 case 3: return LDKSecp256k1Error_InvalidSignature;
647                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
648                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
649                 case 6: return LDKSecp256k1Error_InvalidTweak;
650                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
651                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
652         }
653         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
654         abort(); // Unreachable, but will let the compiler know we don't return here
655 }
656 static jclass Secp256k1Error_class = NULL;
657 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
658 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
659 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
660 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
661 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
662 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
663 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
664 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
665 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
666 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
667         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
668         CHECK(Secp256k1Error_class != NULL);
669         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
670         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
671         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
672         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
673         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
674         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
675         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
676         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
677         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
678         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
679         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
680         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
681         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
682         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
683         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
684         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
685         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
686         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
687 }
688 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
689         switch (val) {
690                 case LDKSecp256k1Error_IncorrectSignature:
691                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
692                 case LDKSecp256k1Error_InvalidMessage:
693                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
694                 case LDKSecp256k1Error_InvalidPublicKey:
695                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
696                 case LDKSecp256k1Error_InvalidSignature:
697                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
698                 case LDKSecp256k1Error_InvalidSecretKey:
699                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
700                 case LDKSecp256k1Error_InvalidRecoveryId:
701                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
702                 case LDKSecp256k1Error_InvalidTweak:
703                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
704                 case LDKSecp256k1Error_TweakCheckFailed:
705                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
706                 case LDKSecp256k1Error_NotEnoughMemory:
707                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
708                 default: abort();
709         }
710 }
711
712 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
713         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
714         if (UNLIKELY((*env)->ExceptionCheck(env))) {
715                 (*env)->ExceptionDescribe(env);
716                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
717         }
718         switch (ord) {
719                 case 0: return LDKSemanticError_NoPaymentHash;
720                 case 1: return LDKSemanticError_MultiplePaymentHashes;
721                 case 2: return LDKSemanticError_NoDescription;
722                 case 3: return LDKSemanticError_MultipleDescriptions;
723                 case 4: return LDKSemanticError_NoPaymentSecret;
724                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
725                 case 6: return LDKSemanticError_InvalidFeatures;
726                 case 7: return LDKSemanticError_InvalidRecoveryId;
727                 case 8: return LDKSemanticError_InvalidSignature;
728                 case 9: return LDKSemanticError_ImpreciseAmount;
729         }
730         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
731         abort(); // Unreachable, but will let the compiler know we don't return here
732 }
733 static jclass SemanticError_class = NULL;
734 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
735 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
736 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
737 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
738 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
739 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
740 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
741 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
742 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
743 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
744 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
745         SemanticError_class = (*env)->NewGlobalRef(env, clz);
746         CHECK(SemanticError_class != NULL);
747         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
748         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
749         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
750         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
751         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
752         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
753         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
754         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
755         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
756         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
757         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
758         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
759         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
760         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
761         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
762         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
763         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
764         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
765         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
766         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
767 }
768 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
769         switch (val) {
770                 case LDKSemanticError_NoPaymentHash:
771                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
772                 case LDKSemanticError_MultiplePaymentHashes:
773                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
774                 case LDKSemanticError_NoDescription:
775                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
776                 case LDKSemanticError_MultipleDescriptions:
777                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
778                 case LDKSemanticError_NoPaymentSecret:
779                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
780                 case LDKSemanticError_MultiplePaymentSecrets:
781                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
782                 case LDKSemanticError_InvalidFeatures:
783                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
784                 case LDKSemanticError_InvalidRecoveryId:
785                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
786                 case LDKSemanticError_InvalidSignature:
787                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
788                 case LDKSemanticError_ImpreciseAmount:
789                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
790                 default: abort();
791         }
792 }
793
794 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
795         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
796         if (UNLIKELY((*env)->ExceptionCheck(env))) {
797                 (*env)->ExceptionDescribe(env);
798                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
799         }
800         switch (ord) {
801                 case 0: return LDKSiPrefix_Milli;
802                 case 1: return LDKSiPrefix_Micro;
803                 case 2: return LDKSiPrefix_Nano;
804                 case 3: return LDKSiPrefix_Pico;
805         }
806         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
807         abort(); // Unreachable, but will let the compiler know we don't return here
808 }
809 static jclass SiPrefix_class = NULL;
810 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
811 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
812 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
813 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
814 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
815         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
816         CHECK(SiPrefix_class != NULL);
817         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
818         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
819         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
820         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
821         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
822         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
823         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
824         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
825 }
826 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
827         switch (val) {
828                 case LDKSiPrefix_Milli:
829                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
830                 case LDKSiPrefix_Micro:
831                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
832                 case LDKSiPrefix_Nano:
833                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
834                 case LDKSiPrefix_Pico:
835                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
836                 default: abort();
837         }
838 }
839
840 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
841         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
842         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
843         return ret;
844 }
845 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) {
846         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
847         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
848         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
849         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
850         CVec_u8Z_free(ret_var);
851         return ret_arr;
852 }
853
854 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) {
855         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
856         int64_t ret_val = TxOut_get_value(thing_conv);
857         return ret_val;
858 }
859
860 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
861 CHECK(owner->result_ok);
862         return *owner->contents.result;
863 }
864 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
865         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
866         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
867         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
868         return ret_arr;
869 }
870
871 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
872 CHECK(!owner->result_ok);
873         return *owner->contents.err;
874 }
875 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
876         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
877         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
878         return ret_conv;
879 }
880
881 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
882 CHECK(owner->result_ok);
883         return *owner->contents.result;
884 }
885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
886         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
887         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
888         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
889         return ret_arr;
890 }
891
892 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
893 CHECK(!owner->result_ok);
894         return *owner->contents.err;
895 }
896 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
897         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
898         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
899         return ret_conv;
900 }
901
902 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
903 CHECK(owner->result_ok);
904         return TxCreationKeys_clone(&*owner->contents.result);
905 }
906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
907         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
908         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
909         uintptr_t ret_ref = 0;
910         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
911         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
913         ret_ref = (uintptr_t)ret_var.inner;
914         if (ret_var.is_owned) {
915                 ret_ref |= 1;
916         }
917         return ret_ref;
918 }
919
920 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
921 CHECK(!owner->result_ok);
922         return DecodeError_clone(&*owner->contents.err);
923 }
924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
925         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
926         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
927         uintptr_t ret_ref = 0;
928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
931         ret_ref = (uintptr_t)ret_var.inner;
932         if (ret_var.is_owned) {
933                 ret_ref |= 1;
934         }
935         return ret_ref;
936 }
937
938 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
939 CHECK(owner->result_ok);
940         return ChannelPublicKeys_clone(&*owner->contents.result);
941 }
942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
943         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
944         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
945         uintptr_t ret_ref = 0;
946         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
947         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
949         ret_ref = (uintptr_t)ret_var.inner;
950         if (ret_var.is_owned) {
951                 ret_ref |= 1;
952         }
953         return ret_ref;
954 }
955
956 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
957 CHECK(!owner->result_ok);
958         return DecodeError_clone(&*owner->contents.err);
959 }
960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
961         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
962         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
963         uintptr_t ret_ref = 0;
964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
967         ret_ref = (uintptr_t)ret_var.inner;
968         if (ret_var.is_owned) {
969                 ret_ref |= 1;
970         }
971         return ret_ref;
972 }
973
974 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
975 CHECK(owner->result_ok);
976         return TxCreationKeys_clone(&*owner->contents.result);
977 }
978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
979         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
980         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
981         uintptr_t ret_ref = 0;
982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
985         ret_ref = (uintptr_t)ret_var.inner;
986         if (ret_var.is_owned) {
987                 ret_ref |= 1;
988         }
989         return ret_ref;
990 }
991
992 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
993 CHECK(!owner->result_ok);
994         return *owner->contents.err;
995 }
996 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
997         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
998         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
999         return ret_conv;
1000 }
1001
1002 static jclass LDKCOption_u32Z_Some_class = NULL;
1003 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1004 static jclass LDKCOption_u32Z_None_class = NULL;
1005 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1007         LDKCOption_u32Z_Some_class =
1008                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1009         CHECK(LDKCOption_u32Z_Some_class != NULL);
1010         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1011         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1012         LDKCOption_u32Z_None_class =
1013                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1014         CHECK(LDKCOption_u32Z_None_class != NULL);
1015         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1016         CHECK(LDKCOption_u32Z_None_meth != NULL);
1017 }
1018 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1019         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
1020         switch(obj->tag) {
1021                 case LDKCOption_u32Z_Some: {
1022                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
1023                 }
1024                 case LDKCOption_u32Z_None: {
1025                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1026                 }
1027                 default: abort();
1028         }
1029 }
1030 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1031 CHECK(owner->result_ok);
1032         return HTLCOutputInCommitment_clone(&*owner->contents.result);
1033 }
1034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1035         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1036         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1037         uintptr_t ret_ref = 0;
1038         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1039         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1041         ret_ref = (uintptr_t)ret_var.inner;
1042         if (ret_var.is_owned) {
1043                 ret_ref |= 1;
1044         }
1045         return ret_ref;
1046 }
1047
1048 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1049 CHECK(!owner->result_ok);
1050         return DecodeError_clone(&*owner->contents.err);
1051 }
1052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1053         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1054         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1055         uintptr_t ret_ref = 0;
1056         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1057         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1059         ret_ref = (uintptr_t)ret_var.inner;
1060         if (ret_var.is_owned) {
1061                 ret_ref |= 1;
1062         }
1063         return ret_ref;
1064 }
1065
1066 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1067 CHECK(owner->result_ok);
1068         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
1069 }
1070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1071         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1072         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1073         uintptr_t ret_ref = 0;
1074         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1075         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1077         ret_ref = (uintptr_t)ret_var.inner;
1078         if (ret_var.is_owned) {
1079                 ret_ref |= 1;
1080         }
1081         return ret_ref;
1082 }
1083
1084 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1085 CHECK(!owner->result_ok);
1086         return DecodeError_clone(&*owner->contents.err);
1087 }
1088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1089         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1090         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1091         uintptr_t ret_ref = 0;
1092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1095         ret_ref = (uintptr_t)ret_var.inner;
1096         if (ret_var.is_owned) {
1097                 ret_ref |= 1;
1098         }
1099         return ret_ref;
1100 }
1101
1102 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1103 CHECK(owner->result_ok);
1104         return ChannelTransactionParameters_clone(&*owner->contents.result);
1105 }
1106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1107         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1108         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1109         uintptr_t ret_ref = 0;
1110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1113         ret_ref = (uintptr_t)ret_var.inner;
1114         if (ret_var.is_owned) {
1115                 ret_ref |= 1;
1116         }
1117         return ret_ref;
1118 }
1119
1120 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1121 CHECK(!owner->result_ok);
1122         return DecodeError_clone(&*owner->contents.err);
1123 }
1124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1125         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1126         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1127         uintptr_t ret_ref = 0;
1128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1131         ret_ref = (uintptr_t)ret_var.inner;
1132         if (ret_var.is_owned) {
1133                 ret_ref |= 1;
1134         }
1135         return ret_ref;
1136 }
1137
1138 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1139 CHECK(owner->result_ok);
1140         return HolderCommitmentTransaction_clone(&*owner->contents.result);
1141 }
1142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1143         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1144         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1145         uintptr_t ret_ref = 0;
1146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1149         ret_ref = (uintptr_t)ret_var.inner;
1150         if (ret_var.is_owned) {
1151                 ret_ref |= 1;
1152         }
1153         return ret_ref;
1154 }
1155
1156 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1157 CHECK(!owner->result_ok);
1158         return DecodeError_clone(&*owner->contents.err);
1159 }
1160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1161         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1162         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1163         uintptr_t ret_ref = 0;
1164         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1165         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1167         ret_ref = (uintptr_t)ret_var.inner;
1168         if (ret_var.is_owned) {
1169                 ret_ref |= 1;
1170         }
1171         return ret_ref;
1172 }
1173
1174 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1175 CHECK(owner->result_ok);
1176         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
1177 }
1178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1179         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1180         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1181         uintptr_t ret_ref = 0;
1182         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1183         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1185         ret_ref = (uintptr_t)ret_var.inner;
1186         if (ret_var.is_owned) {
1187                 ret_ref |= 1;
1188         }
1189         return ret_ref;
1190 }
1191
1192 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1193 CHECK(!owner->result_ok);
1194         return DecodeError_clone(&*owner->contents.err);
1195 }
1196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1197         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1198         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1199         uintptr_t ret_ref = 0;
1200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1203         ret_ref = (uintptr_t)ret_var.inner;
1204         if (ret_var.is_owned) {
1205                 ret_ref |= 1;
1206         }
1207         return ret_ref;
1208 }
1209
1210 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1211 CHECK(owner->result_ok);
1212         return &*owner->contents.result;
1213 }
1214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1215         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1216         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1217         uintptr_t ret_ref = 0;
1218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1221         ret_ref = (uintptr_t)ret_var.inner & ~1;
1222         return ret_ref;
1223 }
1224
1225 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1226 CHECK(!owner->result_ok);
1227         return *owner->contents.err;
1228 }
1229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1230         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1231         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1232 }
1233
1234 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1235 CHECK(owner->result_ok);
1236         return CommitmentTransaction_clone(&*owner->contents.result);
1237 }
1238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1239         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1240         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1241         uintptr_t ret_ref = 0;
1242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1245         ret_ref = (uintptr_t)ret_var.inner;
1246         if (ret_var.is_owned) {
1247                 ret_ref |= 1;
1248         }
1249         return ret_ref;
1250 }
1251
1252 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1253 CHECK(!owner->result_ok);
1254         return DecodeError_clone(&*owner->contents.err);
1255 }
1256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1257         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1258         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1259         uintptr_t ret_ref = 0;
1260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1263         ret_ref = (uintptr_t)ret_var.inner;
1264         if (ret_var.is_owned) {
1265                 ret_ref |= 1;
1266         }
1267         return ret_ref;
1268 }
1269
1270 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1271 CHECK(owner->result_ok);
1272         return &*owner->contents.result;
1273 }
1274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1275         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1276         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1277         uintptr_t ret_ref = 0;
1278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1281         ret_ref = (uintptr_t)ret_var.inner & ~1;
1282         return ret_ref;
1283 }
1284
1285 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1286 CHECK(!owner->result_ok);
1287         return *owner->contents.err;
1288 }
1289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1290         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1291         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1292 }
1293
1294 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1295 CHECK(owner->result_ok);
1296         return *owner->contents.result;
1297 }
1298 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1299         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1300         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1301         jobjectArray ret_arr = NULL;
1302         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1303         ;
1304         for (size_t i = 0; i < ret_var.datalen; i++) {
1305                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1306                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1307                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1308         }
1309         
1310         return ret_arr;
1311 }
1312
1313 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1314 CHECK(!owner->result_ok);
1315         return *owner->contents.err;
1316 }
1317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1318         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1319         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1320 }
1321
1322 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1323 CHECK(owner->result_ok);
1324         return ShutdownScript_clone(&*owner->contents.result);
1325 }
1326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1327         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1328         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1329         uintptr_t ret_ref = 0;
1330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1333         ret_ref = (uintptr_t)ret_var.inner;
1334         if (ret_var.is_owned) {
1335                 ret_ref |= 1;
1336         }
1337         return ret_ref;
1338 }
1339
1340 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1341 CHECK(!owner->result_ok);
1342         return DecodeError_clone(&*owner->contents.err);
1343 }
1344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1345         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1346         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1347         uintptr_t ret_ref = 0;
1348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1351         ret_ref = (uintptr_t)ret_var.inner;
1352         if (ret_var.is_owned) {
1353                 ret_ref |= 1;
1354         }
1355         return ret_ref;
1356 }
1357
1358 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1359 CHECK(owner->result_ok);
1360         return ShutdownScript_clone(&*owner->contents.result);
1361 }
1362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1363         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1364         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1365         uintptr_t ret_ref = 0;
1366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1369         ret_ref = (uintptr_t)ret_var.inner;
1370         if (ret_var.is_owned) {
1371                 ret_ref |= 1;
1372         }
1373         return ret_ref;
1374 }
1375
1376 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1377 CHECK(!owner->result_ok);
1378         return InvalidShutdownScript_clone(&*owner->contents.err);
1379 }
1380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1381         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1382         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1383         uintptr_t ret_ref = 0;
1384         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1385         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1387         ret_ref = (uintptr_t)ret_var.inner;
1388         if (ret_var.is_owned) {
1389                 ret_ref |= 1;
1390         }
1391         return ret_ref;
1392 }
1393
1394 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1395 CHECK(owner->result_ok);
1396         return *owner->contents.result;
1397 }
1398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1399         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1400         CResult_NoneErrorZ_get_ok(owner_conv);
1401 }
1402
1403 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1404 CHECK(!owner->result_ok);
1405         return *owner->contents.err;
1406 }
1407 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1408         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1409         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
1410         return ret_conv;
1411 }
1412
1413 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1414 CHECK(owner->result_ok);
1415         return RouteHop_clone(&*owner->contents.result);
1416 }
1417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1418         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1419         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1420         uintptr_t ret_ref = 0;
1421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1424         ret_ref = (uintptr_t)ret_var.inner;
1425         if (ret_var.is_owned) {
1426                 ret_ref |= 1;
1427         }
1428         return ret_ref;
1429 }
1430
1431 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1432 CHECK(!owner->result_ok);
1433         return DecodeError_clone(&*owner->contents.err);
1434 }
1435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1436         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1437         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1438         uintptr_t ret_ref = 0;
1439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1442         ret_ref = (uintptr_t)ret_var.inner;
1443         if (ret_var.is_owned) {
1444                 ret_ref |= 1;
1445         }
1446         return ret_ref;
1447 }
1448
1449 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1450         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1451         for (size_t i = 0; i < ret.datalen; i++) {
1452                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1453         }
1454         return ret;
1455 }
1456 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1457         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1458         for (size_t i = 0; i < ret.datalen; i++) {
1459                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1460         }
1461         return ret;
1462 }
1463 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1464 CHECK(owner->result_ok);
1465         return Route_clone(&*owner->contents.result);
1466 }
1467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1468         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1469         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1470         uintptr_t ret_ref = 0;
1471         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1472         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1474         ret_ref = (uintptr_t)ret_var.inner;
1475         if (ret_var.is_owned) {
1476                 ret_ref |= 1;
1477         }
1478         return ret_ref;
1479 }
1480
1481 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1482 CHECK(!owner->result_ok);
1483         return DecodeError_clone(&*owner->contents.err);
1484 }
1485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1486         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1487         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1488         uintptr_t ret_ref = 0;
1489         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1490         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1492         ret_ref = (uintptr_t)ret_var.inner;
1493         if (ret_var.is_owned) {
1494                 ret_ref |= 1;
1495         }
1496         return ret_ref;
1497 }
1498
1499 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1500 CHECK(owner->result_ok);
1501         return RouteParameters_clone(&*owner->contents.result);
1502 }
1503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1504         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1505         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1506         uintptr_t ret_ref = 0;
1507         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1508         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1510         ret_ref = (uintptr_t)ret_var.inner;
1511         if (ret_var.is_owned) {
1512                 ret_ref |= 1;
1513         }
1514         return ret_ref;
1515 }
1516
1517 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1518 CHECK(!owner->result_ok);
1519         return DecodeError_clone(&*owner->contents.err);
1520 }
1521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1522         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1523         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1524         uintptr_t ret_ref = 0;
1525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1528         ret_ref = (uintptr_t)ret_var.inner;
1529         if (ret_var.is_owned) {
1530                 ret_ref |= 1;
1531         }
1532         return ret_ref;
1533 }
1534
1535 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1536         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1537         for (size_t i = 0; i < ret.datalen; i++) {
1538                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1539         }
1540         return ret;
1541 }
1542 static jclass LDKCOption_u64Z_Some_class = NULL;
1543 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1544 static jclass LDKCOption_u64Z_None_class = NULL;
1545 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1547         LDKCOption_u64Z_Some_class =
1548                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1549         CHECK(LDKCOption_u64Z_Some_class != NULL);
1550         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1551         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1552         LDKCOption_u64Z_None_class =
1553                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1554         CHECK(LDKCOption_u64Z_None_class != NULL);
1555         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1556         CHECK(LDKCOption_u64Z_None_meth != NULL);
1557 }
1558 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1559         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1560         switch(obj->tag) {
1561                 case LDKCOption_u64Z_Some: {
1562                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1563                 }
1564                 case LDKCOption_u64Z_None: {
1565                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1566                 }
1567                 default: abort();
1568         }
1569 }
1570 static inline struct LDKPayee CResult_PayeeDecodeErrorZ_get_ok(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR owner){
1571 CHECK(owner->result_ok);
1572         return Payee_clone(&*owner->contents.result);
1573 }
1574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1575         LDKCResult_PayeeDecodeErrorZ* owner_conv = (LDKCResult_PayeeDecodeErrorZ*)(owner & ~1);
1576         LDKPayee ret_var = CResult_PayeeDecodeErrorZ_get_ok(owner_conv);
1577         uintptr_t ret_ref = 0;
1578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1581         ret_ref = (uintptr_t)ret_var.inner;
1582         if (ret_var.is_owned) {
1583                 ret_ref |= 1;
1584         }
1585         return ret_ref;
1586 }
1587
1588 static inline struct LDKDecodeError CResult_PayeeDecodeErrorZ_get_err(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR owner){
1589 CHECK(!owner->result_ok);
1590         return DecodeError_clone(&*owner->contents.err);
1591 }
1592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1593         LDKCResult_PayeeDecodeErrorZ* owner_conv = (LDKCResult_PayeeDecodeErrorZ*)(owner & ~1);
1594         LDKDecodeError ret_var = CResult_PayeeDecodeErrorZ_get_err(owner_conv);
1595         uintptr_t ret_ref = 0;
1596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1599         ret_ref = (uintptr_t)ret_var.inner;
1600         if (ret_var.is_owned) {
1601                 ret_ref |= 1;
1602         }
1603         return ret_ref;
1604 }
1605
1606 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1607         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1608         for (size_t i = 0; i < ret.datalen; i++) {
1609                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1610         }
1611         return ret;
1612 }
1613 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1614 CHECK(owner->result_ok);
1615         return RouteHint_clone(&*owner->contents.result);
1616 }
1617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1618         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1619         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1620         uintptr_t ret_ref = 0;
1621         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1622         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1624         ret_ref = (uintptr_t)ret_var.inner;
1625         if (ret_var.is_owned) {
1626                 ret_ref |= 1;
1627         }
1628         return ret_ref;
1629 }
1630
1631 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1632 CHECK(!owner->result_ok);
1633         return DecodeError_clone(&*owner->contents.err);
1634 }
1635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1636         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1637         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1638         uintptr_t ret_ref = 0;
1639         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1640         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1642         ret_ref = (uintptr_t)ret_var.inner;
1643         if (ret_var.is_owned) {
1644                 ret_ref |= 1;
1645         }
1646         return ret_ref;
1647 }
1648
1649 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1650 CHECK(owner->result_ok);
1651         return RouteHintHop_clone(&*owner->contents.result);
1652 }
1653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1654         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1655         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1656         uintptr_t ret_ref = 0;
1657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1660         ret_ref = (uintptr_t)ret_var.inner;
1661         if (ret_var.is_owned) {
1662                 ret_ref |= 1;
1663         }
1664         return ret_ref;
1665 }
1666
1667 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1668 CHECK(!owner->result_ok);
1669         return DecodeError_clone(&*owner->contents.err);
1670 }
1671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1672         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1673         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1674         uintptr_t ret_ref = 0;
1675         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1676         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1678         ret_ref = (uintptr_t)ret_var.inner;
1679         if (ret_var.is_owned) {
1680                 ret_ref |= 1;
1681         }
1682         return ret_ref;
1683 }
1684
1685 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1686         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1687         for (size_t i = 0; i < ret.datalen; i++) {
1688                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1689         }
1690         return ret;
1691 }
1692 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1693 CHECK(owner->result_ok);
1694         return Route_clone(&*owner->contents.result);
1695 }
1696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1697         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1698         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1699         uintptr_t ret_ref = 0;
1700         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1701         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1703         ret_ref = (uintptr_t)ret_var.inner;
1704         if (ret_var.is_owned) {
1705                 ret_ref |= 1;
1706         }
1707         return ret_ref;
1708 }
1709
1710 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1711 CHECK(!owner->result_ok);
1712         return LightningError_clone(&*owner->contents.err);
1713 }
1714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1715         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1716         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1717         uintptr_t ret_ref = 0;
1718         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1719         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1721         ret_ref = (uintptr_t)ret_var.inner;
1722         if (ret_var.is_owned) {
1723                 ret_ref |= 1;
1724         }
1725         return ret_ref;
1726 }
1727
1728 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1729 CHECK(owner->result_ok);
1730         return TxOut_clone(&*owner->contents.result);
1731 }
1732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1733         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1734         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1735         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
1736         return (uintptr_t)ret_ref;
1737 }
1738
1739 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1740 CHECK(!owner->result_ok);
1741         return AccessError_clone(&*owner->contents.err);
1742 }
1743 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1744         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1745         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
1746         return ret_conv;
1747 }
1748
1749 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1750         return owner->a;
1751 }
1752 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
1753         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1754         intptr_t ret_val = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1755         return ret_val;
1756 }
1757
1758 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1759         return owner->b;
1760 }
1761 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
1762         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1763         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1764         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1765         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1766         return ret_arr;
1767 }
1768
1769 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1770         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1771         for (size_t i = 0; i < ret.datalen; i++) {
1772                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1773         }
1774         return ret;
1775 }
1776 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1777         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1778         for (size_t i = 0; i < ret.datalen; i++) {
1779                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1780         }
1781         return ret;
1782 }
1783 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1784 CHECK(owner->result_ok);
1785         return *owner->contents.result;
1786 }
1787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1788         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1789         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
1790 }
1791
1792 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1793 CHECK(!owner->result_ok);
1794         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
1795 }
1796 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1797         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1798         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
1799         return ret_conv;
1800 }
1801
1802 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1803 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1804 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
1805 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
1806 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
1807 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
1808 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
1809 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
1810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1811         LDKMonitorEvent_HTLCEvent_class =
1812                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
1813         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1814         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1815         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1816         LDKMonitorEvent_CommitmentTxConfirmed_class =
1817                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
1818         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
1819         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
1820         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
1821         LDKMonitorEvent_UpdateCompleted_class =
1822                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
1823         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
1824         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
1825         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
1826         LDKMonitorEvent_UpdateFailed_class =
1827                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
1828         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
1829         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
1830         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
1831 }
1832 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1833         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1834         switch(obj->tag) {
1835                 case LDKMonitorEvent_HTLCEvent: {
1836                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1837                         uintptr_t htlc_event_ref = 0;
1838                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1839                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1840                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1841                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
1842                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1843                 }
1844                 case LDKMonitorEvent_CommitmentTxConfirmed: {
1845                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1846                         uintptr_t commitment_tx_confirmed_ref = 0;
1847                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1848                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1849                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1850                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
1851                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
1852                 }
1853                 case LDKMonitorEvent_UpdateCompleted: {
1854                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1855                         uintptr_t funding_txo_ref = 0;
1856                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1857                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1858                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1859                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
1860                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, obj->update_completed.monitor_update_id);
1861                 }
1862                 case LDKMonitorEvent_UpdateFailed: {
1863                         LDKOutPoint update_failed_var = obj->update_failed;
1864                         uintptr_t update_failed_ref = 0;
1865                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1866                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1867                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1868                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
1869                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
1870                 }
1871                 default: abort();
1872         }
1873 }
1874 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1875         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1876         for (size_t i = 0; i < ret.datalen; i++) {
1877                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1878         }
1879         return ret;
1880 }
1881 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1882 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1883 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1884 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1886         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1887                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
1888         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1889         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1890         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1891         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1892                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
1893         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1894         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1895         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1896 }
1897 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1898         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1899         switch(obj->tag) {
1900                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1901                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1902                         *some_conv = obj->some;
1903                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1904                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((uintptr_t)some_conv));
1905                 }
1906                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1907                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1908                 }
1909                 default: abort();
1910         }
1911 }
1912 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
1913 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
1914 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
1915 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
1916 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
1917 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
1918 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
1919 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
1920 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
1921 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
1922 static jclass LDKClosureReason_ProcessingError_class = NULL;
1923 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
1924 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
1925 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
1926 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
1927 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
1928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
1929         LDKClosureReason_CounterpartyForceClosed_class =
1930                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
1931         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
1932         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
1933         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
1934         LDKClosureReason_HolderForceClosed_class =
1935                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
1936         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
1937         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
1938         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
1939         LDKClosureReason_CooperativeClosure_class =
1940                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
1941         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
1942         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
1943         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
1944         LDKClosureReason_CommitmentTxConfirmed_class =
1945                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
1946         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
1947         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
1948         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
1949         LDKClosureReason_FundingTimedOut_class =
1950                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
1951         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
1952         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
1953         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
1954         LDKClosureReason_ProcessingError_class =
1955                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
1956         CHECK(LDKClosureReason_ProcessingError_class != NULL);
1957         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
1958         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
1959         LDKClosureReason_DisconnectedPeer_class =
1960                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
1961         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
1962         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
1963         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
1964         LDKClosureReason_OutdatedChannelManager_class =
1965                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
1966         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
1967         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
1968         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
1969 }
1970 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1971         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1972         switch(obj->tag) {
1973                 case LDKClosureReason_CounterpartyForceClosed: {
1974                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1975                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
1976                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
1977                 }
1978                 case LDKClosureReason_HolderForceClosed: {
1979                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
1980                 }
1981                 case LDKClosureReason_CooperativeClosure: {
1982                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
1983                 }
1984                 case LDKClosureReason_CommitmentTxConfirmed: {
1985                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
1986                 }
1987                 case LDKClosureReason_FundingTimedOut: {
1988                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
1989                 }
1990                 case LDKClosureReason_ProcessingError: {
1991                         LDKStr err_str = obj->processing_error.err;
1992                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1993                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
1994                 }
1995                 case LDKClosureReason_DisconnectedPeer: {
1996                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
1997                 }
1998                 case LDKClosureReason_OutdatedChannelManager: {
1999                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2000                 }
2001                 default: abort();
2002         }
2003 }
2004 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2005 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2006 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2007 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2009         LDKCOption_ClosureReasonZ_Some_class =
2010                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2011         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2012         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2013         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2014         LDKCOption_ClosureReasonZ_None_class =
2015                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2016         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2017         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2018         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2019 }
2020 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2021         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
2022         switch(obj->tag) {
2023                 case LDKCOption_ClosureReasonZ_Some: {
2024                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
2025                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2026                 }
2027                 case LDKCOption_ClosureReasonZ_None: {
2028                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2029                 }
2030                 default: abort();
2031         }
2032 }
2033 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2034 CHECK(owner->result_ok);
2035         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2036 }
2037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2038         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2039         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2040         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2041         uintptr_t ret_ref = (uintptr_t)ret_copy;
2042         return ret_ref;
2043 }
2044
2045 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2046 CHECK(!owner->result_ok);
2047         return DecodeError_clone(&*owner->contents.err);
2048 }
2049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2050         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2051         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2052         uintptr_t ret_ref = 0;
2053         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2054         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2056         ret_ref = (uintptr_t)ret_var.inner;
2057         if (ret_var.is_owned) {
2058                 ret_ref |= 1;
2059         }
2060         return ret_ref;
2061 }
2062
2063 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2064 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2065 static jclass LDKNetworkUpdate_ChannelClosed_class = NULL;
2066 static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL;
2067 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2068 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2070         LDKNetworkUpdate_ChannelUpdateMessage_class =
2071                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2072         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2073         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2074         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2075         LDKNetworkUpdate_ChannelClosed_class =
2076                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed"));
2077         CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL);
2078         LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "<init>", "(JZ)V");
2079         CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL);
2080         LDKNetworkUpdate_NodeFailure_class =
2081                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2082         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2083         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2084         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2085 }
2086 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2087         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
2088         switch(obj->tag) {
2089                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2090                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2091                         uintptr_t msg_ref = 0;
2092                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2093                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2094                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2095                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2096                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2097                 }
2098                 case LDKNetworkUpdate_ChannelClosed: {
2099                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
2100                 }
2101                 case LDKNetworkUpdate_NodeFailure: {
2102                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2103                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2104                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
2105                 }
2106                 default: abort();
2107         }
2108 }
2109 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2110 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2111 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2112 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2114         LDKCOption_NetworkUpdateZ_Some_class =
2115                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2116         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2117         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2118         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2119         LDKCOption_NetworkUpdateZ_None_class =
2120                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2121         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2122         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2123         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2124 }
2125 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2126         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
2127         switch(obj->tag) {
2128                 case LDKCOption_NetworkUpdateZ_Some: {
2129                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
2130                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2131                 }
2132                 case LDKCOption_NetworkUpdateZ_None: {
2133                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2134                 }
2135                 default: abort();
2136         }
2137 }
2138 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2139 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2140 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2141 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2142 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2143 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2145         LDKSpendableOutputDescriptor_StaticOutput_class =
2146                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2147         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2148         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2149         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2150         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2151                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2152         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2153         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2154         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2155         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2156                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2157         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2158         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2159         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2160 }
2161 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2162         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
2163         switch(obj->tag) {
2164                 case LDKSpendableOutputDescriptor_StaticOutput: {
2165                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2166                         uintptr_t outpoint_ref = 0;
2167                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2168                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2169                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2170                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
2171                         uintptr_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
2172                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uintptr_t)output_ref);
2173                 }
2174                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2175                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2176                         uintptr_t delayed_payment_output_ref = 0;
2177                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2178                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2179                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2180                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
2181                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2182                 }
2183                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2184                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2185                         uintptr_t static_payment_output_ref = 0;
2186                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2187                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2188                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2189                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
2190                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2191                 }
2192                 default: abort();
2193         }
2194 }
2195 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2196         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2197         for (size_t i = 0; i < ret.datalen; i++) {
2198                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2199         }
2200         return ret;
2201 }
2202 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
2203 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
2204 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
2205 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
2206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
2207         LDKPaymentPurpose_InvoicePayment_class =
2208                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
2209         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
2210         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
2211         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
2212         LDKPaymentPurpose_SpontaneousPayment_class =
2213                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
2214         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
2215         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
2216         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
2217 }
2218 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2219         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
2220         switch(obj->tag) {
2221                 case LDKPaymentPurpose_InvoicePayment: {
2222                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2223                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
2224                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
2225                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
2226                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
2227                 }
2228                 case LDKPaymentPurpose_SpontaneousPayment: {
2229                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
2230                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
2231                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
2232                 }
2233                 default: abort();
2234         }
2235 }
2236 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2237 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2238 static jclass LDKEvent_PaymentReceived_class = NULL;
2239 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2240 static jclass LDKEvent_PaymentSent_class = NULL;
2241 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2242 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2243 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2244 static jclass LDKEvent_PaymentFailed_class = NULL;
2245 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2246 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2247 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2248 static jclass LDKEvent_SpendableOutputs_class = NULL;
2249 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2250 static jclass LDKEvent_PaymentForwarded_class = NULL;
2251 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2252 static jclass LDKEvent_ChannelClosed_class = NULL;
2253 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2254 static jclass LDKEvent_DiscardFunding_class = NULL;
2255 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
2256 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2257 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
2259         LDKEvent_FundingGenerationReady_class =
2260                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
2261         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
2262         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
2263         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
2264         LDKEvent_PaymentReceived_class =
2265                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
2266         CHECK(LDKEvent_PaymentReceived_class != NULL);
2267         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
2268         CHECK(LDKEvent_PaymentReceived_meth != NULL);
2269         LDKEvent_PaymentSent_class =
2270                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
2271         CHECK(LDKEvent_PaymentSent_class != NULL);
2272         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
2273         CHECK(LDKEvent_PaymentSent_meth != NULL);
2274         LDKEvent_PaymentPathFailed_class =
2275                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
2276         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
2277         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
2278         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
2279         LDKEvent_PaymentFailed_class =
2280                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
2281         CHECK(LDKEvent_PaymentFailed_class != NULL);
2282         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
2283         CHECK(LDKEvent_PaymentFailed_meth != NULL);
2284         LDKEvent_PendingHTLCsForwardable_class =
2285                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
2286         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
2287         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
2288         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
2289         LDKEvent_SpendableOutputs_class =
2290                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
2291         CHECK(LDKEvent_SpendableOutputs_class != NULL);
2292         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
2293         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
2294         LDKEvent_PaymentForwarded_class =
2295                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
2296         CHECK(LDKEvent_PaymentForwarded_class != NULL);
2297         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
2298         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
2299         LDKEvent_ChannelClosed_class =
2300                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
2301         CHECK(LDKEvent_ChannelClosed_class != NULL);
2302         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
2303         CHECK(LDKEvent_ChannelClosed_meth != NULL);
2304         LDKEvent_DiscardFunding_class =
2305                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
2306         CHECK(LDKEvent_DiscardFunding_class != NULL);
2307         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
2308         CHECK(LDKEvent_DiscardFunding_meth != NULL);
2309         LDKEvent_PaymentPathSuccessful_class =
2310                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
2311         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
2312         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
2313         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
2314 }
2315 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2316         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2317         switch(obj->tag) {
2318                 case LDKEvent_FundingGenerationReady: {
2319                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2320                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
2321                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
2322                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
2323                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2324                         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);
2325                 }
2326                 case LDKEvent_PaymentReceived: {
2327                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2328                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2329                         uintptr_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
2330                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
2331                 }
2332                 case LDKEvent_PaymentSent: {
2333                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2334                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2335                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2336                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2337                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2338                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2339                         uintptr_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
2340                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2341                 }
2342                 case LDKEvent_PaymentPathFailed: {
2343                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2344                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
2345                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2346                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
2347                         uintptr_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
2348                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2349                         int64_tArray path_arr = NULL;
2350                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2351                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2352                         for (size_t k = 0; k < path_var.datalen; k++) {
2353                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2354                                 uintptr_t path_conv_10_ref = 0;
2355                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2356                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2357                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2358                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2359                                 path_arr_ptr[k] = path_conv_10_ref;
2360                         }
2361                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2362                         uintptr_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
2363                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2364                         uintptr_t retry_ref = 0;
2365                         if ((uintptr_t)retry_var.inner > 4096) {
2366                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2367                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2368                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2369                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
2370                         }
2371                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, obj->payment_path_failed.rejected_by_dest, network_update_ref, obj->payment_path_failed.all_paths_failed, path_arr, short_channel_id_ref, retry_ref);
2372                 }
2373                 case LDKEvent_PaymentFailed: {
2374                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2375                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2376                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2377                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2378                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2379                 }
2380                 case LDKEvent_PendingHTLCsForwardable: {
2381                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
2382                 }
2383                 case LDKEvent_SpendableOutputs: {
2384                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2385                         int64_tArray outputs_arr = NULL;
2386                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2387                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2388                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2389                                 uintptr_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
2390                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2391                         }
2392                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2393                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2394                 }
2395                 case LDKEvent_PaymentForwarded: {
2396                         uintptr_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
2397                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
2398                 }
2399                 case LDKEvent_ChannelClosed: {
2400                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2401                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2402                         uintptr_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
2403                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, obj->channel_closed.user_channel_id, reason_ref);
2404                 }
2405                 case LDKEvent_DiscardFunding: {
2406                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2407                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2408                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2409                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2410                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2411                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2412                 }
2413                 case LDKEvent_PaymentPathSuccessful: {
2414                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2415                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2416                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2417                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2418                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2419                         int64_tArray path_arr = NULL;
2420                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2421                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2422                         for (size_t k = 0; k < path_var.datalen; k++) {
2423                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2424                                 uintptr_t path_conv_10_ref = 0;
2425                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2426                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2427                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2428                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2429                                 path_arr_ptr[k] = path_conv_10_ref;
2430                         }
2431                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2432                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2433                 }
2434                 default: abort();
2435         }
2436 }
2437 static jclass LDKCOption_EventZ_Some_class = NULL;
2438 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2439 static jclass LDKCOption_EventZ_None_class = NULL;
2440 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2442         LDKCOption_EventZ_Some_class =
2443                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2444         CHECK(LDKCOption_EventZ_Some_class != NULL);
2445         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2446         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2447         LDKCOption_EventZ_None_class =
2448                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2449         CHECK(LDKCOption_EventZ_None_class != NULL);
2450         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2451         CHECK(LDKCOption_EventZ_None_meth != NULL);
2452 }
2453 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2454         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2455         switch(obj->tag) {
2456                 case LDKCOption_EventZ_Some: {
2457                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
2458                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2459                 }
2460                 case LDKCOption_EventZ_None: {
2461                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2462                 }
2463                 default: abort();
2464         }
2465 }
2466 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2467 CHECK(owner->result_ok);
2468         return COption_EventZ_clone(&*owner->contents.result);
2469 }
2470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2471         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2472         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2473         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2474         uintptr_t ret_ref = (uintptr_t)ret_copy;
2475         return ret_ref;
2476 }
2477
2478 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2479 CHECK(!owner->result_ok);
2480         return DecodeError_clone(&*owner->contents.err);
2481 }
2482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2483         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2484         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2485         uintptr_t ret_ref = 0;
2486         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2487         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2489         ret_ref = (uintptr_t)ret_var.inner;
2490         if (ret_var.is_owned) {
2491                 ret_ref |= 1;
2492         }
2493         return ret_ref;
2494 }
2495
2496 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2497 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2498 static jclass LDKErrorAction_IgnoreError_class = NULL;
2499 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2500 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2501 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2502 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2503 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2504 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2505 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2507         LDKErrorAction_DisconnectPeer_class =
2508                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2509         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2510         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2511         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2512         LDKErrorAction_IgnoreError_class =
2513                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2514         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2515         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2516         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2517         LDKErrorAction_IgnoreAndLog_class =
2518                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2519         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2520         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2521         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2522         LDKErrorAction_IgnoreDuplicateGossip_class =
2523                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2524         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2525         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2526         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2527         LDKErrorAction_SendErrorMessage_class =
2528                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2529         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2530         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2531         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2532 }
2533 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2534         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2535         switch(obj->tag) {
2536                 case LDKErrorAction_DisconnectPeer: {
2537                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2538                         uintptr_t msg_ref = 0;
2539                         if ((uintptr_t)msg_var.inner > 4096) {
2540                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2541                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2542                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2543                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2544                         }
2545                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2546                 }
2547                 case LDKErrorAction_IgnoreError: {
2548                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2549                 }
2550                 case LDKErrorAction_IgnoreAndLog: {
2551                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2552                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2553                 }
2554                 case LDKErrorAction_IgnoreDuplicateGossip: {
2555                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2556                 }
2557                 case LDKErrorAction_SendErrorMessage: {
2558                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2559                         uintptr_t msg_ref = 0;
2560                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2561                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2562                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2563                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2564                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2565                 }
2566                 default: abort();
2567         }
2568 }
2569 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2570 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2571 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2572 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2573 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2574 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2575 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2576 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2577 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
2578 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
2579 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2580 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2581 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2582 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2583 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2584 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2585 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2586 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2587 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2588 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2589 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2590 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2591 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2592 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2593 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2594 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2595 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2596 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2597 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2598 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2599 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2600 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2601 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2602 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2603 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2604 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2605 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2606 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2608         LDKMessageSendEvent_SendAcceptChannel_class =
2609                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2610         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2611         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2612         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2613         LDKMessageSendEvent_SendOpenChannel_class =
2614                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2615         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2616         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2617         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2618         LDKMessageSendEvent_SendFundingCreated_class =
2619                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2620         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2621         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2622         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2623         LDKMessageSendEvent_SendFundingSigned_class =
2624                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2625         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2626         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2627         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2628         LDKMessageSendEvent_SendFundingLocked_class =
2629                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked"));
2630         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
2631         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
2632         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
2633         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2634                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2635         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2636         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2637         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2638         LDKMessageSendEvent_UpdateHTLCs_class =
2639                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2640         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2641         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2642         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2643         LDKMessageSendEvent_SendRevokeAndACK_class =
2644                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2645         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2646         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2647         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2648         LDKMessageSendEvent_SendClosingSigned_class =
2649                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2650         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2651         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2652         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2653         LDKMessageSendEvent_SendShutdown_class =
2654                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2655         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2656         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2657         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2658         LDKMessageSendEvent_SendChannelReestablish_class =
2659                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2660         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2661         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2662         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2663         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2664                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2665         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2666         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2667         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2668         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2669                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2670         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2671         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2672         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2673         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2674                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2675         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2676         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2677         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2678         LDKMessageSendEvent_SendChannelUpdate_class =
2679                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2680         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2681         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2682         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2683         LDKMessageSendEvent_HandleError_class =
2684                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2685         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2686         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2687         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2688         LDKMessageSendEvent_SendChannelRangeQuery_class =
2689                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2690         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2691         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2692         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2693         LDKMessageSendEvent_SendShortIdsQuery_class =
2694                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2695         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2696         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2697         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2698         LDKMessageSendEvent_SendReplyChannelRange_class =
2699                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2700         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2701         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2702         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2703 }
2704 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2705         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2706         switch(obj->tag) {
2707                 case LDKMessageSendEvent_SendAcceptChannel: {
2708                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2709                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2710                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2711                         uintptr_t msg_ref = 0;
2712                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2713                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2714                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2715                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2716                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2717                 }
2718                 case LDKMessageSendEvent_SendOpenChannel: {
2719                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2720                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2721                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2722                         uintptr_t msg_ref = 0;
2723                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2724                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2725                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2726                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2727                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2728                 }
2729                 case LDKMessageSendEvent_SendFundingCreated: {
2730                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2731                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2732                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2733                         uintptr_t msg_ref = 0;
2734                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2735                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2736                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2737                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2738                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2739                 }
2740                 case LDKMessageSendEvent_SendFundingSigned: {
2741                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2742                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2743                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2744                         uintptr_t msg_ref = 0;
2745                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2746                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2747                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2748                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2749                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2750                 }
2751                 case LDKMessageSendEvent_SendFundingLocked: {
2752                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2753                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
2754                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2755                         uintptr_t msg_ref = 0;
2756                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2757                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2758                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2759                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2760                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
2761                 }
2762                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2763                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2764                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2765                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2766                         uintptr_t msg_ref = 0;
2767                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2768                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2769                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2770                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2771                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2772                 }
2773                 case LDKMessageSendEvent_UpdateHTLCs: {
2774                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2775                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2776                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2777                         uintptr_t updates_ref = 0;
2778                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2779                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2780                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2781                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2782                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2783                 }
2784                 case LDKMessageSendEvent_SendRevokeAndACK: {
2785                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2786                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2787                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2788                         uintptr_t msg_ref = 0;
2789                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2790                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2791                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2792                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2793                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
2794                 }
2795                 case LDKMessageSendEvent_SendClosingSigned: {
2796                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2797                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
2798                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2799                         uintptr_t msg_ref = 0;
2800                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2801                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2802                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2803                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2804                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
2805                 }
2806                 case LDKMessageSendEvent_SendShutdown: {
2807                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2808                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
2809                         LDKShutdown msg_var = obj->send_shutdown.msg;
2810                         uintptr_t msg_ref = 0;
2811                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2812                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2813                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2814                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2815                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
2816                 }
2817                 case LDKMessageSendEvent_SendChannelReestablish: {
2818                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2819                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
2820                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2821                         uintptr_t msg_ref = 0;
2822                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2823                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2824                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2825                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2826                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
2827                 }
2828                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
2829                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2830                         uintptr_t msg_ref = 0;
2831                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2832                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2833                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2834                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2835                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2836                         uintptr_t update_msg_ref = 0;
2837                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2838                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2839                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2840                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2841                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
2842                 }
2843                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
2844                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2845                         uintptr_t msg_ref = 0;
2846                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2847                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2848                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2849                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2850                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
2851                 }
2852                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
2853                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2854                         uintptr_t msg_ref = 0;
2855                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2856                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2857                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2858                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2859                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
2860                 }
2861                 case LDKMessageSendEvent_SendChannelUpdate: {
2862                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2863                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
2864                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2865                         uintptr_t msg_ref = 0;
2866                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2867                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2868                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2869                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2870                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
2871                 }
2872                 case LDKMessageSendEvent_HandleError: {
2873                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2874                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
2875                         uintptr_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2876                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
2877                 }
2878                 case LDKMessageSendEvent_SendChannelRangeQuery: {
2879                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2880                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
2881                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2882                         uintptr_t msg_ref = 0;
2883                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2884                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2885                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2886                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2887                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
2888                 }
2889                 case LDKMessageSendEvent_SendShortIdsQuery: {
2890                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2891                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
2892                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2893                         uintptr_t msg_ref = 0;
2894                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2895                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2896                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2897                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2898                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
2899                 }
2900                 case LDKMessageSendEvent_SendReplyChannelRange: {
2901                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2902                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
2903                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2904                         uintptr_t msg_ref = 0;
2905                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2906                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2907                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2908                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2909                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
2910                 }
2911                 default: abort();
2912         }
2913 }
2914 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2915         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2916         for (size_t i = 0; i < ret.datalen; i++) {
2917                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2918         }
2919         return ret;
2920 }
2921 static inline struct LDKScoringParameters *CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2922 CHECK(owner->result_ok);
2923         return &*owner->contents.result;
2924 }
2925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2926         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2927         LDKScoringParameters ret_var = *CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
2928         uintptr_t ret_ref = 0;
2929         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2930         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2932         ret_ref = (uintptr_t)ret_var.inner & ~1;
2933         return ret_ref;
2934 }
2935
2936 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2937 CHECK(!owner->result_ok);
2938         return DecodeError_clone(&*owner->contents.err);
2939 }
2940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2941         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2942         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
2943         uintptr_t ret_ref = 0;
2944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2947         ret_ref = (uintptr_t)ret_var.inner;
2948         if (ret_var.is_owned) {
2949                 ret_ref |= 1;
2950         }
2951         return ret_ref;
2952 }
2953
2954 static inline struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2955 CHECK(owner->result_ok);
2956         return &*owner->contents.result;
2957 }
2958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2959         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2960         LDKScorer ret_var = *CResult_ScorerDecodeErrorZ_get_ok(owner_conv);
2961         uintptr_t ret_ref = 0;
2962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2965         ret_ref = (uintptr_t)ret_var.inner & ~1;
2966         return ret_ref;
2967 }
2968
2969 static inline struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2970 CHECK(!owner->result_ok);
2971         return DecodeError_clone(&*owner->contents.err);
2972 }
2973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2974         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2975         LDKDecodeError ret_var = CResult_ScorerDecodeErrorZ_get_err(owner_conv);
2976         uintptr_t ret_ref = 0;
2977         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2978         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2980         ret_ref = (uintptr_t)ret_var.inner;
2981         if (ret_var.is_owned) {
2982                 ret_ref |= 1;
2983         }
2984         return ret_ref;
2985 }
2986
2987 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2988 CHECK(owner->result_ok);
2989         return InitFeatures_clone(&*owner->contents.result);
2990 }
2991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2992         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2993         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2994         uintptr_t ret_ref = 0;
2995         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2996         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2998         ret_ref = (uintptr_t)ret_var.inner;
2999         if (ret_var.is_owned) {
3000                 ret_ref |= 1;
3001         }
3002         return ret_ref;
3003 }
3004
3005 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3006 CHECK(!owner->result_ok);
3007         return DecodeError_clone(&*owner->contents.err);
3008 }
3009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3010         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3011         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3012         uintptr_t ret_ref = 0;
3013         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3014         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3016         ret_ref = (uintptr_t)ret_var.inner;
3017         if (ret_var.is_owned) {
3018                 ret_ref |= 1;
3019         }
3020         return ret_ref;
3021 }
3022
3023 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3024 CHECK(owner->result_ok);
3025         return ChannelFeatures_clone(&*owner->contents.result);
3026 }
3027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3028         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3029         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3030         uintptr_t ret_ref = 0;
3031         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3032         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3034         ret_ref = (uintptr_t)ret_var.inner;
3035         if (ret_var.is_owned) {
3036                 ret_ref |= 1;
3037         }
3038         return ret_ref;
3039 }
3040
3041 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3042 CHECK(!owner->result_ok);
3043         return DecodeError_clone(&*owner->contents.err);
3044 }
3045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3046         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3047         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3048         uintptr_t ret_ref = 0;
3049         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3050         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3052         ret_ref = (uintptr_t)ret_var.inner;
3053         if (ret_var.is_owned) {
3054                 ret_ref |= 1;
3055         }
3056         return ret_ref;
3057 }
3058
3059 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3060 CHECK(owner->result_ok);
3061         return NodeFeatures_clone(&*owner->contents.result);
3062 }
3063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3064         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3065         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3066         uintptr_t ret_ref = 0;
3067         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3068         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3070         ret_ref = (uintptr_t)ret_var.inner;
3071         if (ret_var.is_owned) {
3072                 ret_ref |= 1;
3073         }
3074         return ret_ref;
3075 }
3076
3077 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3078 CHECK(!owner->result_ok);
3079         return DecodeError_clone(&*owner->contents.err);
3080 }
3081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3082         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3083         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3084         uintptr_t ret_ref = 0;
3085         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3086         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3087         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3088         ret_ref = (uintptr_t)ret_var.inner;
3089         if (ret_var.is_owned) {
3090                 ret_ref |= 1;
3091         }
3092         return ret_ref;
3093 }
3094
3095 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3096 CHECK(owner->result_ok);
3097         return InvoiceFeatures_clone(&*owner->contents.result);
3098 }
3099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3100         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3101         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3102         uintptr_t ret_ref = 0;
3103         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3104         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3106         ret_ref = (uintptr_t)ret_var.inner;
3107         if (ret_var.is_owned) {
3108                 ret_ref |= 1;
3109         }
3110         return ret_ref;
3111 }
3112
3113 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3114 CHECK(!owner->result_ok);
3115         return DecodeError_clone(&*owner->contents.err);
3116 }
3117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3118         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3119         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3120         uintptr_t ret_ref = 0;
3121         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3122         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3124         ret_ref = (uintptr_t)ret_var.inner;
3125         if (ret_var.is_owned) {
3126                 ret_ref |= 1;
3127         }
3128         return ret_ref;
3129 }
3130
3131 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3132 CHECK(owner->result_ok);
3133         return ChannelTypeFeatures_clone(&*owner->contents.result);
3134 }
3135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3136         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3137         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3138         uintptr_t ret_ref = 0;
3139         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3140         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3142         ret_ref = (uintptr_t)ret_var.inner;
3143         if (ret_var.is_owned) {
3144                 ret_ref |= 1;
3145         }
3146         return ret_ref;
3147 }
3148
3149 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3150 CHECK(!owner->result_ok);
3151         return DecodeError_clone(&*owner->contents.err);
3152 }
3153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3154         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3155         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3156         uintptr_t ret_ref = 0;
3157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3160         ret_ref = (uintptr_t)ret_var.inner;
3161         if (ret_var.is_owned) {
3162                 ret_ref |= 1;
3163         }
3164         return ret_ref;
3165 }
3166
3167 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3168 CHECK(owner->result_ok);
3169         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
3170 }
3171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3172         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3173         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3174         uintptr_t ret_ref = 0;
3175         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3176         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3178         ret_ref = (uintptr_t)ret_var.inner;
3179         if (ret_var.is_owned) {
3180                 ret_ref |= 1;
3181         }
3182         return ret_ref;
3183 }
3184
3185 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3186 CHECK(!owner->result_ok);
3187         return DecodeError_clone(&*owner->contents.err);
3188 }
3189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3190         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3191         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3192         uintptr_t ret_ref = 0;
3193         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3194         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3196         ret_ref = (uintptr_t)ret_var.inner;
3197         if (ret_var.is_owned) {
3198                 ret_ref |= 1;
3199         }
3200         return ret_ref;
3201 }
3202
3203 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3204 CHECK(owner->result_ok);
3205         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
3206 }
3207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3208         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3209         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3210         uintptr_t ret_ref = 0;
3211         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3212         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3214         ret_ref = (uintptr_t)ret_var.inner;
3215         if (ret_var.is_owned) {
3216                 ret_ref |= 1;
3217         }
3218         return ret_ref;
3219 }
3220
3221 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3222 CHECK(!owner->result_ok);
3223         return DecodeError_clone(&*owner->contents.err);
3224 }
3225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3226         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3227         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3228         uintptr_t ret_ref = 0;
3229         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3230         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3232         ret_ref = (uintptr_t)ret_var.inner;
3233         if (ret_var.is_owned) {
3234                 ret_ref |= 1;
3235         }
3236         return ret_ref;
3237 }
3238
3239 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3240 CHECK(owner->result_ok);
3241         return SpendableOutputDescriptor_clone(&*owner->contents.result);
3242 }
3243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3244         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3245         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
3246         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3247         uintptr_t ret_ref = (uintptr_t)ret_copy;
3248         return ret_ref;
3249 }
3250
3251 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3252 CHECK(!owner->result_ok);
3253         return DecodeError_clone(&*owner->contents.err);
3254 }
3255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3256         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3257         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3258         uintptr_t ret_ref = 0;
3259         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3260         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3262         ret_ref = (uintptr_t)ret_var.inner;
3263         if (ret_var.is_owned) {
3264                 ret_ref |= 1;
3265         }
3266         return ret_ref;
3267 }
3268
3269 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
3270 CHECK(owner->result_ok);
3271         return *owner->contents.result;
3272 }
3273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3274         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
3275         CResult_NoneNoneZ_get_ok(owner_conv);
3276 }
3277
3278 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
3279 CHECK(!owner->result_ok);
3280         return *owner->contents.err;
3281 }
3282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3283         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
3284         CResult_NoneNoneZ_get_err(owner_conv);
3285 }
3286
3287 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3288         return owner->a;
3289 }
3290 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3291         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3292         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3293         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
3294         return ret_arr;
3295 }
3296
3297 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3298         return owner->b;
3299 }
3300 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3301         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3302         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
3303         jobjectArray ret_arr = NULL;
3304         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
3305         ;
3306         for (size_t i = 0; i < ret_var.datalen; i++) {
3307                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
3308                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
3309                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
3310         }
3311         
3312         return ret_arr;
3313 }
3314
3315 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3316 CHECK(owner->result_ok);
3317         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
3318 }
3319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3320         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3321         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3322         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
3323         return ((uintptr_t)ret_conv);
3324 }
3325
3326 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3327 CHECK(!owner->result_ok);
3328         return *owner->contents.err;
3329 }
3330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3331         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3332         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
3333 }
3334
3335 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3336 CHECK(owner->result_ok);
3337         return *owner->contents.result;
3338 }
3339 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3340         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3341         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3342         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
3343         return ret_arr;
3344 }
3345
3346 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3347 CHECK(!owner->result_ok);
3348         return *owner->contents.err;
3349 }
3350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3351         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3352         CResult_SignatureNoneZ_get_err(owner_conv);
3353 }
3354
3355 typedef struct LDKBaseSign_JCalls {
3356         atomic_size_t refcnt;
3357         JavaVM *vm;
3358         jweak o;
3359         jmethodID get_per_commitment_point_meth;
3360         jmethodID release_commitment_secret_meth;
3361         jmethodID validate_holder_commitment_meth;
3362         jmethodID channel_keys_id_meth;
3363         jmethodID sign_counterparty_commitment_meth;
3364         jmethodID validate_counterparty_revocation_meth;
3365         jmethodID sign_holder_commitment_and_htlcs_meth;
3366         jmethodID sign_justice_revoked_output_meth;
3367         jmethodID sign_justice_revoked_htlc_meth;
3368         jmethodID sign_counterparty_htlc_transaction_meth;
3369         jmethodID sign_closing_transaction_meth;
3370         jmethodID sign_channel_announcement_meth;
3371         jmethodID ready_channel_meth;
3372 } LDKBaseSign_JCalls;
3373 static void LDKBaseSign_JCalls_free(void* this_arg) {
3374         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3375         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3376                 JNIEnv *env;
3377                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3378                 if (get_jenv_res == JNI_EDETACHED) {
3379                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3380                 } else {
3381                         DO_ASSERT(get_jenv_res == JNI_OK);
3382                 }
3383                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3384                 if (get_jenv_res == JNI_EDETACHED) {
3385                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3386                 }
3387                 FREE(j_calls);
3388         }
3389 }
3390 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3391         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3392         JNIEnv *env;
3393         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3394         if (get_jenv_res == JNI_EDETACHED) {
3395                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3396         } else {
3397                 DO_ASSERT(get_jenv_res == JNI_OK);
3398         }
3399         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3400         CHECK(obj != NULL);
3401         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
3402         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3403                 (*env)->ExceptionDescribe(env);
3404                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
3405         }
3406         LDKPublicKey ret_ref;
3407         CHECK((*env)->GetArrayLength(env, ret) == 33);
3408         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3409         if (get_jenv_res == JNI_EDETACHED) {
3410                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3411         }
3412         return ret_ref;
3413 }
3414 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3415         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3416         JNIEnv *env;
3417         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3418         if (get_jenv_res == JNI_EDETACHED) {
3419                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3420         } else {
3421                 DO_ASSERT(get_jenv_res == JNI_OK);
3422         }
3423         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3424         CHECK(obj != NULL);
3425         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
3426         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3427                 (*env)->ExceptionDescribe(env);
3428                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
3429         }
3430         LDKThirtyTwoBytes ret_ref;
3431         CHECK((*env)->GetArrayLength(env, ret) == 32);
3432         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3433         if (get_jenv_res == JNI_EDETACHED) {
3434                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3435         }
3436         return ret_ref;
3437 }
3438 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
3439         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3440         JNIEnv *env;
3441         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3442         if (get_jenv_res == JNI_EDETACHED) {
3443                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3444         } else {
3445                 DO_ASSERT(get_jenv_res == JNI_OK);
3446         }
3447         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
3448         uintptr_t holder_tx_ref = 0;
3449         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
3450         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3451         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3452         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3453         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
3454         if (holder_tx_var.is_owned) {
3455                 holder_tx_ref |= 1;
3456         }
3457         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3458         CHECK(obj != NULL);
3459         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref);
3460         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3461                 (*env)->ExceptionDescribe(env);
3462                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
3463         }
3464         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3465         CHECK_ACCESS(ret_ptr);
3466         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3467         FREE((void*)ret);
3468         if (get_jenv_res == JNI_EDETACHED) {
3469                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3470         }
3471         return ret_conv;
3472 }
3473 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3474         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3475         JNIEnv *env;
3476         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3477         if (get_jenv_res == JNI_EDETACHED) {
3478                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3479         } else {
3480                 DO_ASSERT(get_jenv_res == JNI_OK);
3481         }
3482         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3483         CHECK(obj != NULL);
3484         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
3485         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3486                 (*env)->ExceptionDescribe(env);
3487                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
3488         }
3489         LDKThirtyTwoBytes ret_ref;
3490         CHECK((*env)->GetArrayLength(env, ret) == 32);
3491         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3492         if (get_jenv_res == JNI_EDETACHED) {
3493                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3494         }
3495         return ret_ref;
3496 }
3497 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
3498         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3499         JNIEnv *env;
3500         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3501         if (get_jenv_res == JNI_EDETACHED) {
3502                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3503         } else {
3504                 DO_ASSERT(get_jenv_res == JNI_OK);
3505         }
3506         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3507         uintptr_t commitment_tx_ref = 0;
3508         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
3509         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3510         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3511         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3512         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3513         if (commitment_tx_var.is_owned) {
3514                 commitment_tx_ref |= 1;
3515         }
3516         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3517         CHECK(obj != NULL);
3518         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
3519         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3520                 (*env)->ExceptionDescribe(env);
3521                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
3522         }
3523         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3524         CHECK_ACCESS(ret_ptr);
3525         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3526         FREE((void*)ret);
3527         if (get_jenv_res == JNI_EDETACHED) {
3528                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3529         }
3530         return ret_conv;
3531 }
3532 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3533         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3534         JNIEnv *env;
3535         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3536         if (get_jenv_res == JNI_EDETACHED) {
3537                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3538         } else {
3539                 DO_ASSERT(get_jenv_res == JNI_OK);
3540         }
3541         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
3542         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
3543         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3544         CHECK(obj != NULL);
3545         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
3546         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3547                 (*env)->ExceptionDescribe(env);
3548                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
3549         }
3550         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3551         CHECK_ACCESS(ret_ptr);
3552         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3553         FREE((void*)ret);
3554         if (get_jenv_res == JNI_EDETACHED) {
3555                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3556         }
3557         return ret_conv;
3558 }
3559 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3560         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3561         JNIEnv *env;
3562         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3563         if (get_jenv_res == JNI_EDETACHED) {
3564                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3565         } else {
3566                 DO_ASSERT(get_jenv_res == JNI_OK);
3567         }
3568         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3569         uintptr_t commitment_tx_ref = 0;
3570         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
3571         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3572         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3573         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3574         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3575         if (commitment_tx_var.is_owned) {
3576                 commitment_tx_ref |= 1;
3577         }
3578         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3579         CHECK(obj != NULL);
3580         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
3581         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3582                 (*env)->ExceptionDescribe(env);
3583                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
3584         }
3585         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3586         CHECK_ACCESS(ret_ptr);
3587         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3588         FREE((void*)ret);
3589         if (get_jenv_res == JNI_EDETACHED) {
3590                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3591         }
3592         return ret_conv;
3593 }
3594 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]) {
3595         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
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         LDKTransaction justice_tx_var = justice_tx;
3604         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
3605         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
3606         Transaction_free(justice_tx_var);
3607         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
3608         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
3609         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3610         CHECK(obj != NULL);
3611         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
3612         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3613                 (*env)->ExceptionDescribe(env);
3614                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
3615         }
3616         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3617         CHECK_ACCESS(ret_ptr);
3618         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3619         FREE((void*)ret);
3620         if (get_jenv_res == JNI_EDETACHED) {
3621                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3622         }
3623         return ret_conv;
3624 }
3625 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) {
3626         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3627         JNIEnv *env;
3628         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3629         if (get_jenv_res == JNI_EDETACHED) {
3630                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3631         } else {
3632                 DO_ASSERT(get_jenv_res == JNI_OK);
3633         }
3634         LDKTransaction justice_tx_var = justice_tx;
3635         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
3636         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
3637         Transaction_free(justice_tx_var);
3638         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
3639         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
3640         LDKHTLCOutputInCommitment htlc_var = *htlc;
3641         uintptr_t htlc_ref = 0;
3642         htlc_var = HTLCOutputInCommitment_clone(htlc);
3643         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3644         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3645         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3646         htlc_ref = (uintptr_t)htlc_var.inner;
3647         if (htlc_var.is_owned) {
3648                 htlc_ref |= 1;
3649         }
3650         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3651         CHECK(obj != NULL);
3652         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
3653         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3654                 (*env)->ExceptionDescribe(env);
3655                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
3656         }
3657         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3658         CHECK_ACCESS(ret_ptr);
3659         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3660         FREE((void*)ret);
3661         if (get_jenv_res == JNI_EDETACHED) {
3662                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3663         }
3664         return ret_conv;
3665 }
3666 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) {
3667         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3668         JNIEnv *env;
3669         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3670         if (get_jenv_res == JNI_EDETACHED) {
3671                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3672         } else {
3673                 DO_ASSERT(get_jenv_res == JNI_OK);
3674         }
3675         LDKTransaction htlc_tx_var = htlc_tx;
3676         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
3677         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
3678         Transaction_free(htlc_tx_var);
3679         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
3680         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
3681         LDKHTLCOutputInCommitment htlc_var = *htlc;
3682         uintptr_t htlc_ref = 0;
3683         htlc_var = HTLCOutputInCommitment_clone(htlc);
3684         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3685         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3686         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3687         htlc_ref = (uintptr_t)htlc_var.inner;
3688         if (htlc_var.is_owned) {
3689                 htlc_ref |= 1;
3690         }
3691         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3692         CHECK(obj != NULL);
3693         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
3694         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3695                 (*env)->ExceptionDescribe(env);
3696                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
3697         }
3698         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3699         CHECK_ACCESS(ret_ptr);
3700         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3701         FREE((void*)ret);
3702         if (get_jenv_res == JNI_EDETACHED) {
3703                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3704         }
3705         return ret_conv;
3706 }
3707 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3708         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3709         JNIEnv *env;
3710         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3711         if (get_jenv_res == JNI_EDETACHED) {
3712                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3713         } else {
3714                 DO_ASSERT(get_jenv_res == JNI_OK);
3715         }
3716         LDKClosingTransaction closing_tx_var = *closing_tx;
3717         uintptr_t closing_tx_ref = 0;
3718         closing_tx_var = ClosingTransaction_clone(closing_tx);
3719         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3720         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3721         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3722         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
3723         if (closing_tx_var.is_owned) {
3724                 closing_tx_ref |= 1;
3725         }
3726         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3727         CHECK(obj != NULL);
3728         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
3729         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3730                 (*env)->ExceptionDescribe(env);
3731                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
3732         }
3733         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3734         CHECK_ACCESS(ret_ptr);
3735         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3736         FREE((void*)ret);
3737         if (get_jenv_res == JNI_EDETACHED) {
3738                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3739         }
3740         return ret_conv;
3741 }
3742 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3743         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3744         JNIEnv *env;
3745         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3746         if (get_jenv_res == JNI_EDETACHED) {
3747                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3748         } else {
3749                 DO_ASSERT(get_jenv_res == JNI_OK);
3750         }
3751         LDKUnsignedChannelAnnouncement msg_var = *msg;
3752         uintptr_t msg_ref = 0;
3753         msg_var = UnsignedChannelAnnouncement_clone(msg);
3754         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3755         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3756         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3757         msg_ref = (uintptr_t)msg_var.inner;
3758         if (msg_var.is_owned) {
3759                 msg_ref |= 1;
3760         }
3761         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3762         CHECK(obj != NULL);
3763         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
3764         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3765                 (*env)->ExceptionDescribe(env);
3766                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
3767         }
3768         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3769         CHECK_ACCESS(ret_ptr);
3770         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3771         FREE((void*)ret);
3772         if (get_jenv_res == JNI_EDETACHED) {
3773                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3774         }
3775         return ret_conv;
3776 }
3777 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3778         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3779         JNIEnv *env;
3780         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3781         if (get_jenv_res == JNI_EDETACHED) {
3782                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3783         } else {
3784                 DO_ASSERT(get_jenv_res == JNI_OK);
3785         }
3786         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3787         uintptr_t channel_parameters_ref = 0;
3788         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
3789         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3790         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3791         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
3792         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
3793         if (channel_parameters_var.is_owned) {
3794                 channel_parameters_ref |= 1;
3795         }
3796         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3797         CHECK(obj != NULL);
3798         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
3799         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3800                 (*env)->ExceptionDescribe(env);
3801                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
3802         }
3803         if (get_jenv_res == JNI_EDETACHED) {
3804                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3805         }
3806 }
3807 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
3808         jclass c = (*env)->GetObjectClass(env, o);
3809         CHECK(c != NULL);
3810         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
3811         atomic_init(&calls->refcnt, 1);
3812         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3813         calls->o = (*env)->NewWeakGlobalRef(env, o);
3814         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
3815         CHECK(calls->get_per_commitment_point_meth != NULL);
3816         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
3817         CHECK(calls->release_commitment_secret_meth != NULL);
3818         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J)J");
3819         CHECK(calls->validate_holder_commitment_meth != NULL);
3820         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
3821         CHECK(calls->channel_keys_id_meth != NULL);
3822         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
3823         CHECK(calls->sign_counterparty_commitment_meth != NULL);
3824         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
3825         CHECK(calls->validate_counterparty_revocation_meth != NULL);
3826         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
3827         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
3828         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
3829         CHECK(calls->sign_justice_revoked_output_meth != NULL);
3830         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
3831         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
3832         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
3833         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
3834         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
3835         CHECK(calls->sign_closing_transaction_meth != NULL);
3836         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
3837         CHECK(calls->sign_channel_announcement_meth != NULL);
3838         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
3839         CHECK(calls->ready_channel_meth != NULL);
3840
3841         LDKChannelPublicKeys pubkeys_conv;
3842         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3843         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3844         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3845
3846         LDKBaseSign ret = {
3847                 .this_arg = (void*) calls,
3848                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
3849                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
3850                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
3851                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
3852                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
3853                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
3854                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
3855                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
3856                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
3857                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
3858                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
3859                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
3860                 .ready_channel = ready_channel_LDKBaseSign_jcall,
3861                 .free = LDKBaseSign_JCalls_free,
3862                 .pubkeys = pubkeys_conv,
3863                 .set_pubkeys = NULL,
3864         };
3865         return ret;
3866 }
3867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
3868         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3869         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
3870         return (uint64_t)res_ptr;
3871 }
3872 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) {
3873         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3874         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3875         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3876         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3877         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
3878         return ret_arr;
3879 }
3880
3881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
3882         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3883         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3884         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3885         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3886         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
3887         return ret_arr;
3888 }
3889
3890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1holder_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t holder_tx) {
3891         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3892         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3893         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3894         LDKHolderCommitmentTransaction holder_tx_conv;
3895         holder_tx_conv.inner = (void*)(holder_tx & (~1));
3896         holder_tx_conv.is_owned = false;
3897         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
3898         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3899         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
3900         return (uintptr_t)ret_conv;
3901 }
3902
3903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
3904         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3905         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3906         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3907         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3908         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
3909         return ret_arr;
3910 }
3911
3912 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) {
3913         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3914         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3915         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3916         LDKCommitmentTransaction commitment_tx_conv;
3917         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3918         commitment_tx_conv.is_owned = false;
3919         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3920         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3921         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
3922         return (uintptr_t)ret_conv;
3923 }
3924
3925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1counterparty_1revocation(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx, int8_tArray secret) {
3926         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3927         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3928         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3929         unsigned char secret_arr[32];
3930         CHECK((*env)->GetArrayLength(env, secret) == 32);
3931         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
3932         unsigned char (*secret_ref)[32] = &secret_arr;
3933         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3934         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
3935         return (uintptr_t)ret_conv;
3936 }
3937
3938 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) {
3939         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3940         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3941         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3942         LDKHolderCommitmentTransaction commitment_tx_conv;
3943         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3944         commitment_tx_conv.is_owned = false;
3945         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3946         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3947         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
3948         return (uintptr_t)ret_conv;
3949 }
3950
3951 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, intptr_t input, int64_t amount, int8_tArray per_commitment_key) {
3952         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3953         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3954         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3955         LDKTransaction justice_tx_ref;
3956         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
3957         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3958         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
3959         justice_tx_ref.data_is_owned = true;
3960         unsigned char per_commitment_key_arr[32];
3961         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
3962         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
3963         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3964         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3965         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
3966         return (uintptr_t)ret_conv;
3967 }
3968
3969 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, intptr_t input, int64_t amount, int8_tArray per_commitment_key, int64_t htlc) {
3970         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3971         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3972         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3973         LDKTransaction justice_tx_ref;
3974         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
3975         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3976         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
3977         justice_tx_ref.data_is_owned = true;
3978         unsigned char per_commitment_key_arr[32];
3979         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
3980         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
3981         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3982         LDKHTLCOutputInCommitment htlc_conv;
3983         htlc_conv.inner = (void*)(htlc & (~1));
3984         htlc_conv.is_owned = false;
3985         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3986         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3987         *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);
3988         return (uintptr_t)ret_conv;
3989 }
3990
3991 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, intptr_t input, int64_t amount, int8_tArray per_commitment_point, int64_t htlc) {
3992         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3993         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3994         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3995         LDKTransaction htlc_tx_ref;
3996         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
3997         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
3998         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
3999         htlc_tx_ref.data_is_owned = true;
4000         LDKPublicKey per_commitment_point_ref;
4001         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
4002         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
4003         LDKHTLCOutputInCommitment htlc_conv;
4004         htlc_conv.inner = (void*)(htlc & (~1));
4005         htlc_conv.is_owned = false;
4006         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4007         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4008         *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);
4009         return (uintptr_t)ret_conv;
4010 }
4011
4012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int64_t closing_tx) {
4013         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4014         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4015         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4016         LDKClosingTransaction closing_tx_conv;
4017         closing_tx_conv.inner = (void*)(closing_tx & (~1));
4018         closing_tx_conv.is_owned = false;
4019         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
4020         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4021         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
4022         return (uintptr_t)ret_conv;
4023 }
4024
4025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
4026         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4027         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4028         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4029         LDKUnsignedChannelAnnouncement msg_conv;
4030         msg_conv.inner = (void*)(msg & (~1));
4031         msg_conv.is_owned = false;
4032         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
4033         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4034         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4035         return (uintptr_t)ret_conv;
4036 }
4037
4038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
4039         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4040         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4041         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4042         LDKChannelTransactionParameters channel_parameters_conv;
4043         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
4044         channel_parameters_conv.is_owned = false;
4045         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
4046         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
4047 }
4048
4049 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
4050         if (this_arg->set_pubkeys != NULL)
4051                 this_arg->set_pubkeys(this_arg);
4052         return this_arg->pubkeys;
4053 }
4054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
4055         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4056         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4057         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4058         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
4059         uintptr_t ret_ref = 0;
4060         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4061         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4063         ret_ref = (uintptr_t)ret_var.inner;
4064         if (ret_var.is_owned) {
4065                 ret_ref |= 1;
4066         }
4067         return ret_ref;
4068 }
4069
4070 typedef struct LDKSign_JCalls {
4071         atomic_size_t refcnt;
4072         JavaVM *vm;
4073         jweak o;
4074         LDKBaseSign_JCalls* BaseSign;
4075         jmethodID write_meth;
4076 } LDKSign_JCalls;
4077 static void LDKSign_JCalls_free(void* this_arg) {
4078         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4079         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4080                 JNIEnv *env;
4081                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4082                 if (get_jenv_res == JNI_EDETACHED) {
4083                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4084                 } else {
4085                         DO_ASSERT(get_jenv_res == JNI_OK);
4086                 }
4087                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4088                 if (get_jenv_res == JNI_EDETACHED) {
4089                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4090                 }
4091                 FREE(j_calls);
4092         }
4093 }
4094 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
4095         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4096         JNIEnv *env;
4097         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4098         if (get_jenv_res == JNI_EDETACHED) {
4099                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4100         } else {
4101                 DO_ASSERT(get_jenv_res == JNI_OK);
4102         }
4103         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4104         CHECK(obj != NULL);
4105         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
4106         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4107                 (*env)->ExceptionDescribe(env);
4108                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
4109         }
4110         LDKCVec_u8Z ret_ref;
4111         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4112         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4113         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4114         if (get_jenv_res == JNI_EDETACHED) {
4115                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4116         }
4117         return ret_ref;
4118 }
4119 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
4120         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
4121         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4122         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
4123 }
4124 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
4125         jclass c = (*env)->GetObjectClass(env, o);
4126         CHECK(c != NULL);
4127         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
4128         atomic_init(&calls->refcnt, 1);
4129         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4130         calls->o = (*env)->NewWeakGlobalRef(env, o);
4131         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
4132         CHECK(calls->write_meth != NULL);
4133
4134         LDKChannelPublicKeys pubkeys_conv;
4135         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4136         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4137         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4138
4139         LDKSign ret = {
4140                 .this_arg = (void*) calls,
4141                 .write = write_LDKSign_jcall,
4142                 .cloned = LDKSign_JCalls_cloned,
4143                 .free = LDKSign_JCalls_free,
4144                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
4145         };
4146         calls->BaseSign = ret.BaseSign.this_arg;
4147         return ret;
4148 }
4149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
4150         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
4151         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
4152         return (uint64_t)res_ptr;
4153 }
4154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
4155         LDKSign *inp = (LDKSign *)(arg & ~1);
4156         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
4157         DO_ASSERT((res_ptr & 1) == 0);
4158         return (int64_t)(res_ptr | 1);
4159 }
4160 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
4161         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4162         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4163         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
4164         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4165         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4166         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4167         CVec_u8Z_free(ret_var);
4168         return ret_arr;
4169 }
4170
4171 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4172 CHECK(owner->result_ok);
4173         return Sign_clone(&*owner->contents.result);
4174 }
4175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4176         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4177         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4178         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
4179         return (uintptr_t)ret_ret;
4180 }
4181
4182 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4183 CHECK(!owner->result_ok);
4184         return DecodeError_clone(&*owner->contents.err);
4185 }
4186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4187         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4188         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
4189         uintptr_t ret_ref = 0;
4190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4193         ret_ref = (uintptr_t)ret_var.inner;
4194         if (ret_var.is_owned) {
4195                 ret_ref |= 1;
4196         }
4197         return ret_ref;
4198 }
4199
4200 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4201 CHECK(owner->result_ok);
4202         return *owner->contents.result;
4203 }
4204 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4205         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4206         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
4207         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
4208         return ret_arr;
4209 }
4210
4211 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4212 CHECK(!owner->result_ok);
4213         return *owner->contents.err;
4214 }
4215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4216         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4217         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
4218 }
4219
4220 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
4221         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
4222         for (size_t i = 0; i < ret.datalen; i++) {
4223                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
4224         }
4225         return ret;
4226 }
4227 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4228 CHECK(owner->result_ok);
4229         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
4230 }
4231 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4232         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4233         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
4234         jobjectArray ret_arr = NULL;
4235         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4236         ;
4237         for (size_t i = 0; i < ret_var.datalen; i++) {
4238                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
4239                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
4240                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
4241                 CVec_u8Z_free(ret_conv_8_var);
4242                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4243         }
4244         
4245         FREE(ret_var.data);
4246         return ret_arr;
4247 }
4248
4249 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4250 CHECK(!owner->result_ok);
4251         return *owner->contents.err;
4252 }
4253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4254         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4255         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
4256 }
4257
4258 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4259 CHECK(owner->result_ok);
4260         return InMemorySigner_clone(&*owner->contents.result);
4261 }
4262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4263         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4264         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
4265         uintptr_t ret_ref = 0;
4266         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4267         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4269         ret_ref = (uintptr_t)ret_var.inner;
4270         if (ret_var.is_owned) {
4271                 ret_ref |= 1;
4272         }
4273         return ret_ref;
4274 }
4275
4276 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4277 CHECK(!owner->result_ok);
4278         return DecodeError_clone(&*owner->contents.err);
4279 }
4280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4281         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4282         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
4283         uintptr_t ret_ref = 0;
4284         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4285         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4287         ret_ref = (uintptr_t)ret_var.inner;
4288         if (ret_var.is_owned) {
4289                 ret_ref |= 1;
4290         }
4291         return ret_ref;
4292 }
4293
4294 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4295         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4296         for (size_t i = 0; i < ret.datalen; i++) {
4297                 ret.data[i] = TxOut_clone(&orig->data[i]);
4298         }
4299         return ret;
4300 }
4301 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4302 CHECK(owner->result_ok);
4303         return *owner->contents.result;
4304 }
4305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4306         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4307         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
4308         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4309         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4310         return ret_arr;
4311 }
4312
4313 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4314 CHECK(!owner->result_ok);
4315         return *owner->contents.err;
4316 }
4317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4318         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4319         CResult_TransactionNoneZ_get_err(owner_conv);
4320 }
4321
4322 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
4323         return ThirtyTwoBytes_clone(&owner->a);
4324 }
4325 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4326         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
4327         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4328         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
4329         return ret_arr;
4330 }
4331
4332 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
4333         return ChannelMonitor_clone(&owner->b);
4334 }
4335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4336         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
4337         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
4338         uintptr_t ret_ref = 0;
4339         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4340         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4342         ret_ref = (uintptr_t)ret_var.inner;
4343         if (ret_var.is_owned) {
4344                 ret_ref |= 1;
4345         }
4346         return ret_ref;
4347 }
4348
4349 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
4350         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
4351         for (size_t i = 0; i < ret.datalen; i++) {
4352                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
4353         }
4354         return ret;
4355 }
4356 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
4357 CHECK(owner->result_ok);
4358         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
4359 }
4360 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4361         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
4362         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
4363         int64_tArray ret_arr = NULL;
4364         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4365         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4366         for (size_t j = 0; j < ret_var.datalen; j++) {
4367                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4368                 *ret_conv_35_conv = ret_var.data[j];
4369                 ret_arr_ptr[j] = ((uintptr_t)ret_conv_35_conv);
4370         }
4371         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4372         FREE(ret_var.data);
4373         return ret_arr;
4374 }
4375
4376 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
4377 CHECK(!owner->result_ok);
4378         return *owner->contents.err;
4379 }
4380 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4381         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
4382         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
4383         return ret_conv;
4384 }
4385
4386 static jclass LDKCOption_u16Z_Some_class = NULL;
4387 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
4388 static jclass LDKCOption_u16Z_None_class = NULL;
4389 static jmethodID LDKCOption_u16Z_None_meth = NULL;
4390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
4391         LDKCOption_u16Z_Some_class =
4392                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
4393         CHECK(LDKCOption_u16Z_Some_class != NULL);
4394         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
4395         CHECK(LDKCOption_u16Z_Some_meth != NULL);
4396         LDKCOption_u16Z_None_class =
4397                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
4398         CHECK(LDKCOption_u16Z_None_class != NULL);
4399         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
4400         CHECK(LDKCOption_u16Z_None_meth != NULL);
4401 }
4402 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4403         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4404         switch(obj->tag) {
4405                 case LDKCOption_u16Z_Some: {
4406                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
4407                 }
4408                 case LDKCOption_u16Z_None: {
4409                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
4410                 }
4411                 default: abort();
4412         }
4413 }
4414 static jclass LDKAPIError_APIMisuseError_class = NULL;
4415 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
4416 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
4417 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
4418 static jclass LDKAPIError_RouteError_class = NULL;
4419 static jmethodID LDKAPIError_RouteError_meth = NULL;
4420 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
4421 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
4422 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
4423 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
4424 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
4425 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
4426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
4427         LDKAPIError_APIMisuseError_class =
4428                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
4429         CHECK(LDKAPIError_APIMisuseError_class != NULL);
4430         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
4431         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
4432         LDKAPIError_FeeRateTooHigh_class =
4433                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
4434         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
4435         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
4436         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
4437         LDKAPIError_RouteError_class =
4438                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
4439         CHECK(LDKAPIError_RouteError_class != NULL);
4440         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
4441         CHECK(LDKAPIError_RouteError_meth != NULL);
4442         LDKAPIError_ChannelUnavailable_class =
4443                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
4444         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
4445         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
4446         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
4447         LDKAPIError_MonitorUpdateFailed_class =
4448                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
4449         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
4450         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
4451         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
4452         LDKAPIError_IncompatibleShutdownScript_class =
4453                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
4454         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
4455         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
4456         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
4457 }
4458 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4459         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4460         switch(obj->tag) {
4461                 case LDKAPIError_APIMisuseError: {
4462                         LDKStr err_str = obj->api_misuse_error.err;
4463                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4464                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
4465                 }
4466                 case LDKAPIError_FeeRateTooHigh: {
4467                         LDKStr err_str = obj->fee_rate_too_high.err;
4468                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4469                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
4470                 }
4471                 case LDKAPIError_RouteError: {
4472                         LDKStr err_str = obj->route_error.err;
4473                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4474                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
4475                 }
4476                 case LDKAPIError_ChannelUnavailable: {
4477                         LDKStr err_str = obj->channel_unavailable.err;
4478                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4479                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
4480                 }
4481                 case LDKAPIError_MonitorUpdateFailed: {
4482                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
4483                 }
4484                 case LDKAPIError_IncompatibleShutdownScript: {
4485                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
4486                         uintptr_t script_ref = 0;
4487                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4488                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4489                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
4490                         script_ref = (uintptr_t)script_var.inner & ~1;
4491                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
4492                 }
4493                 default: abort();
4494         }
4495 }
4496 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4497 CHECK(owner->result_ok);
4498         return *owner->contents.result;
4499 }
4500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4501         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4502         CResult_NoneAPIErrorZ_get_ok(owner_conv);
4503 }
4504
4505 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4506 CHECK(!owner->result_ok);
4507         return APIError_clone(&*owner->contents.err);
4508 }
4509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4510         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4511         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4512         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
4513         uintptr_t ret_ref = (uintptr_t)ret_copy;
4514         return ret_ref;
4515 }
4516
4517 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4518         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4519         for (size_t i = 0; i < ret.datalen; i++) {
4520                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4521         }
4522         return ret;
4523 }
4524 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4525         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4526         for (size_t i = 0; i < ret.datalen; i++) {
4527                 ret.data[i] = APIError_clone(&orig->data[i]);
4528         }
4529         return ret;
4530 }
4531 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4532 CHECK(owner->result_ok);
4533         return ThirtyTwoBytes_clone(&*owner->contents.result);
4534 }
4535 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4536         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4537         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
4539         return ret_arr;
4540 }
4541
4542 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4543 CHECK(!owner->result_ok);
4544         return APIError_clone(&*owner->contents.err);
4545 }
4546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4547         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4548         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4549         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
4550         uintptr_t ret_ref = (uintptr_t)ret_copy;
4551         return ret_ref;
4552 }
4553
4554 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
4555 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
4556 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
4557 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
4558 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
4559 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
4560 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
4561 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
4562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
4563         LDKPaymentSendFailure_ParameterError_class =
4564                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
4565         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
4566         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
4567         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
4568         LDKPaymentSendFailure_PathParameterError_class =
4569                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
4570         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
4571         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
4572         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
4573         LDKPaymentSendFailure_AllFailedRetrySafe_class =
4574                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
4575         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
4576         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
4577         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
4578         LDKPaymentSendFailure_PartialFailure_class =
4579                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
4580         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
4581         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
4582         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
4583 }
4584 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4585         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4586         switch(obj->tag) {
4587                 case LDKPaymentSendFailure_ParameterError: {
4588                         uintptr_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
4589                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
4590                 }
4591                 case LDKPaymentSendFailure_PathParameterError: {
4592                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4593                         int64_tArray path_parameter_error_arr = NULL;
4594                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
4595                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
4596                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4597                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4598                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4599                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4600                                 path_parameter_error_arr_ptr[w] = (uintptr_t)path_parameter_error_conv_22_conv;
4601                         }
4602                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
4603                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
4604                 }
4605                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
4606                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4607                         int64_tArray all_failed_retry_safe_arr = NULL;
4608                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
4609                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
4610                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
4611                                 uintptr_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
4612                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
4613                         }
4614                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
4615                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
4616                 }
4617                 case LDKPaymentSendFailure_PartialFailure: {
4618                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
4619                         int64_tArray results_arr = NULL;
4620                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
4621                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
4622                         for (size_t w = 0; w < results_var.datalen; w++) {
4623                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4624                                 *results_conv_22_conv = results_var.data[w];
4625                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
4626                                 results_arr_ptr[w] = (uintptr_t)results_conv_22_conv;
4627                         }
4628                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
4629                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
4630                         uintptr_t failed_paths_retry_ref = 0;
4631                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
4632                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4633                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4634                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
4635                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
4636                         }
4637                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
4638                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
4639                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
4640                 }
4641                 default: abort();
4642         }
4643 }
4644 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4645 CHECK(owner->result_ok);
4646         return ThirtyTwoBytes_clone(&*owner->contents.result);
4647 }
4648 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4649         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4650         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4651         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
4652         return ret_arr;
4653 }
4654
4655 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4656 CHECK(!owner->result_ok);
4657         return PaymentSendFailure_clone(&*owner->contents.err);
4658 }
4659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4660         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4661         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4662         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
4663         uintptr_t ret_ref = (uintptr_t)ret_copy;
4664         return ret_ref;
4665 }
4666
4667 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4668 CHECK(owner->result_ok);
4669         return *owner->contents.result;
4670 }
4671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4672         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4673         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
4674 }
4675
4676 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4677 CHECK(!owner->result_ok);
4678         return PaymentSendFailure_clone(&*owner->contents.err);
4679 }
4680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4681         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4682         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4683         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
4684         uintptr_t ret_ref = (uintptr_t)ret_copy;
4685         return ret_ref;
4686 }
4687
4688 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4689         return ThirtyTwoBytes_clone(&owner->a);
4690 }
4691 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4692         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4693         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4694         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
4695         return ret_arr;
4696 }
4697
4698 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4699         return ThirtyTwoBytes_clone(&owner->b);
4700 }
4701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4702         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4703         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4704         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
4705         return ret_arr;
4706 }
4707
4708 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4709 CHECK(owner->result_ok);
4710         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
4711 }
4712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4713         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4714         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
4715         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
4716         return ((uintptr_t)ret_conv);
4717 }
4718
4719 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4720 CHECK(!owner->result_ok);
4721         return PaymentSendFailure_clone(&*owner->contents.err);
4722 }
4723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4724         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4725         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4726         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
4727         uintptr_t ret_ref = (uintptr_t)ret_copy;
4728         return ret_ref;
4729 }
4730
4731 static jclass LDKNetAddress_IPv4_class = NULL;
4732 static jmethodID LDKNetAddress_IPv4_meth = NULL;
4733 static jclass LDKNetAddress_IPv6_class = NULL;
4734 static jmethodID LDKNetAddress_IPv6_meth = NULL;
4735 static jclass LDKNetAddress_OnionV2_class = NULL;
4736 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
4737 static jclass LDKNetAddress_OnionV3_class = NULL;
4738 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
4739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
4740         LDKNetAddress_IPv4_class =
4741                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
4742         CHECK(LDKNetAddress_IPv4_class != NULL);
4743         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
4744         CHECK(LDKNetAddress_IPv4_meth != NULL);
4745         LDKNetAddress_IPv6_class =
4746                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
4747         CHECK(LDKNetAddress_IPv6_class != NULL);
4748         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
4749         CHECK(LDKNetAddress_IPv6_meth != NULL);
4750         LDKNetAddress_OnionV2_class =
4751                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
4752         CHECK(LDKNetAddress_OnionV2_class != NULL);
4753         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
4754         CHECK(LDKNetAddress_OnionV2_meth != NULL);
4755         LDKNetAddress_OnionV3_class =
4756                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
4757         CHECK(LDKNetAddress_OnionV3_class != NULL);
4758         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
4759         CHECK(LDKNetAddress_OnionV3_meth != NULL);
4760 }
4761 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4762         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4763         switch(obj->tag) {
4764                 case LDKNetAddress_IPv4: {
4765                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
4766                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
4767                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
4768                 }
4769                 case LDKNetAddress_IPv6: {
4770                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
4771                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
4772                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
4773                 }
4774                 case LDKNetAddress_OnionV2: {
4775                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
4776                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
4777                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
4778                 }
4779                 case LDKNetAddress_OnionV3: {
4780                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
4781                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
4782                         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);
4783                 }
4784                 default: abort();
4785         }
4786 }
4787 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4788         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4789         for (size_t i = 0; i < ret.datalen; i++) {
4790                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4791         }
4792         return ret;
4793 }
4794 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4795         return ThirtyTwoBytes_clone(&owner->a);
4796 }
4797 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4798         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4799         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4800         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
4801         return ret_arr;
4802 }
4803
4804 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4805         return ThirtyTwoBytes_clone(&owner->b);
4806 }
4807 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4808         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4809         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4810         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
4811         return ret_arr;
4812 }
4813
4814 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4815 CHECK(owner->result_ok);
4816         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4817 }
4818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4819         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4820         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4821         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
4822         return ((uintptr_t)ret_conv);
4823 }
4824
4825 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4826 CHECK(!owner->result_ok);
4827         return *owner->contents.err;
4828 }
4829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4830         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4831         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
4832 }
4833
4834 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4835 CHECK(owner->result_ok);
4836         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4837 }
4838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4839         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4840         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4841         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
4842         return ((uintptr_t)ret_conv);
4843 }
4844
4845 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4846 CHECK(!owner->result_ok);
4847         return APIError_clone(&*owner->contents.err);
4848 }
4849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4850         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4851         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4852         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
4853         uintptr_t ret_ref = (uintptr_t)ret_copy;
4854         return ret_ref;
4855 }
4856
4857 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4858 CHECK(owner->result_ok);
4859         return ThirtyTwoBytes_clone(&*owner->contents.result);
4860 }
4861 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4862         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4863         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4864         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
4865         return ret_arr;
4866 }
4867
4868 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4869 CHECK(!owner->result_ok);
4870         return *owner->contents.err;
4871 }
4872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4873         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4874         CResult_PaymentSecretNoneZ_get_err(owner_conv);
4875 }
4876
4877 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4878 CHECK(owner->result_ok);
4879         return ThirtyTwoBytes_clone(&*owner->contents.result);
4880 }
4881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4882         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4883         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4884         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
4885         return ret_arr;
4886 }
4887
4888 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4889 CHECK(!owner->result_ok);
4890         return APIError_clone(&*owner->contents.err);
4891 }
4892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4893         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4894         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4895         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
4896         uintptr_t ret_ref = (uintptr_t)ret_copy;
4897         return ret_ref;
4898 }
4899
4900 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4901 CHECK(owner->result_ok);
4902         return ThirtyTwoBytes_clone(&*owner->contents.result);
4903 }
4904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4905         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4906         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4907         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
4908         return ret_arr;
4909 }
4910
4911 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4912 CHECK(!owner->result_ok);
4913         return APIError_clone(&*owner->contents.err);
4914 }
4915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4916         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4917         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4918         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
4919         uintptr_t ret_ref = (uintptr_t)ret_copy;
4920         return ret_ref;
4921 }
4922
4923 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4924         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4925         for (size_t i = 0; i < ret.datalen; i++) {
4926                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4927         }
4928         return ret;
4929 }
4930 typedef struct LDKWatch_JCalls {
4931         atomic_size_t refcnt;
4932         JavaVM *vm;
4933         jweak o;
4934         jmethodID watch_channel_meth;
4935         jmethodID update_channel_meth;
4936         jmethodID release_pending_monitor_events_meth;
4937 } LDKWatch_JCalls;
4938 static void LDKWatch_JCalls_free(void* this_arg) {
4939         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4940         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4941                 JNIEnv *env;
4942                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4943                 if (get_jenv_res == JNI_EDETACHED) {
4944                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4945                 } else {
4946                         DO_ASSERT(get_jenv_res == JNI_OK);
4947                 }
4948                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4949                 if (get_jenv_res == JNI_EDETACHED) {
4950                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4951                 }
4952                 FREE(j_calls);
4953         }
4954 }
4955 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4956         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4957         JNIEnv *env;
4958         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4959         if (get_jenv_res == JNI_EDETACHED) {
4960                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4961         } else {
4962                 DO_ASSERT(get_jenv_res == JNI_OK);
4963         }
4964         LDKOutPoint funding_txo_var = funding_txo;
4965         uintptr_t funding_txo_ref = 0;
4966         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4967         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4968         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4969         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4970         if (funding_txo_var.is_owned) {
4971                 funding_txo_ref |= 1;
4972         }
4973         LDKChannelMonitor monitor_var = monitor;
4974         uintptr_t monitor_ref = 0;
4975         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4976         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4977         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
4978         monitor_ref = (uintptr_t)monitor_var.inner;
4979         if (monitor_var.is_owned) {
4980                 monitor_ref |= 1;
4981         }
4982         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4983         CHECK(obj != NULL);
4984         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
4985         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4986                 (*env)->ExceptionDescribe(env);
4987                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
4988         }
4989         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4990         CHECK_ACCESS(ret_ptr);
4991         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4992         FREE((void*)ret);
4993         if (get_jenv_res == JNI_EDETACHED) {
4994                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4995         }
4996         return ret_conv;
4997 }
4998 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4999         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5000         JNIEnv *env;
5001         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5002         if (get_jenv_res == JNI_EDETACHED) {
5003                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5004         } else {
5005                 DO_ASSERT(get_jenv_res == JNI_OK);
5006         }
5007         LDKOutPoint funding_txo_var = funding_txo;
5008         uintptr_t funding_txo_ref = 0;
5009         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5010         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5011         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5012         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5013         if (funding_txo_var.is_owned) {
5014                 funding_txo_ref |= 1;
5015         }
5016         LDKChannelMonitorUpdate update_var = update;
5017         uintptr_t update_ref = 0;
5018         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5019         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5020         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5021         update_ref = (uintptr_t)update_var.inner;
5022         if (update_var.is_owned) {
5023                 update_ref |= 1;
5024         }
5025         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5026         CHECK(obj != NULL);
5027         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
5028         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5029                 (*env)->ExceptionDescribe(env);
5030                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
5031         }
5032         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5033         CHECK_ACCESS(ret_ptr);
5034         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5035         FREE((void*)ret);
5036         if (get_jenv_res == JNI_EDETACHED) {
5037                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5038         }
5039         return ret_conv;
5040 }
5041 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5042         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5043         JNIEnv *env;
5044         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5045         if (get_jenv_res == JNI_EDETACHED) {
5046                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5047         } else {
5048                 DO_ASSERT(get_jenv_res == JNI_OK);
5049         }
5050         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5051         CHECK(obj != NULL);
5052         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
5053         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5054                 (*env)->ExceptionDescribe(env);
5055                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
5056         }
5057         LDKCVec_MonitorEventZ ret_constr;
5058         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5059         if (ret_constr.datalen > 0)
5060                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
5061         else
5062                 ret_constr.data = NULL;
5063         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5064         for (size_t o = 0; o < ret_constr.datalen; o++) {
5065                 int64_t ret_conv_14 = ret_vals[o];
5066                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
5067                 CHECK_ACCESS(ret_conv_14_ptr);
5068                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
5069                 FREE((void*)ret_conv_14);
5070                 ret_constr.data[o] = ret_conv_14_conv;
5071         }
5072         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5073         if (get_jenv_res == JNI_EDETACHED) {
5074                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5075         }
5076         return ret_constr;
5077 }
5078 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5079         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5080         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5081 }
5082 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
5083         jclass c = (*env)->GetObjectClass(env, o);
5084         CHECK(c != NULL);
5085         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5086         atomic_init(&calls->refcnt, 1);
5087         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5088         calls->o = (*env)->NewWeakGlobalRef(env, o);
5089         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
5090         CHECK(calls->watch_channel_meth != NULL);
5091         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
5092         CHECK(calls->update_channel_meth != NULL);
5093         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
5094         CHECK(calls->release_pending_monitor_events_meth != NULL);
5095
5096         LDKWatch ret = {
5097                 .this_arg = (void*) calls,
5098                 .watch_channel = watch_channel_LDKWatch_jcall,
5099                 .update_channel = update_channel_LDKWatch_jcall,
5100                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5101                 .free = LDKWatch_JCalls_free,
5102         };
5103         return ret;
5104 }
5105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
5106         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5107         *res_ptr = LDKWatch_init(env, clz, o);
5108         return (uint64_t)res_ptr;
5109 }
5110 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) {
5111         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5112         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5113         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5114         LDKOutPoint funding_txo_conv;
5115         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5116         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5117         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5118         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5119         LDKChannelMonitor monitor_conv;
5120         monitor_conv.inner = (void*)(monitor & (~1));
5121         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
5122         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5123         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5124         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5125         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5126         return (uintptr_t)ret_conv;
5127 }
5128
5129 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) {
5130         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5131         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5132         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5133         LDKOutPoint funding_txo_conv;
5134         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5135         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5136         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5137         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5138         LDKChannelMonitorUpdate update_conv;
5139         update_conv.inner = (void*)(update & (~1));
5140         update_conv.is_owned = (update & 1) || (update == 0);
5141         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5142         update_conv = ChannelMonitorUpdate_clone(&update_conv);
5143         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5144         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
5145         return (uintptr_t)ret_conv;
5146 }
5147
5148 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
5149         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5150         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5151         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5152         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
5153         int64_tArray ret_arr = NULL;
5154         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5155         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5156         for (size_t o = 0; o < ret_var.datalen; o++) {
5157                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
5158                 *ret_conv_14_copy = ret_var.data[o];
5159                 uintptr_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
5160                 ret_arr_ptr[o] = ret_conv_14_ref;
5161         }
5162         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5163         FREE(ret_var.data);
5164         return ret_arr;
5165 }
5166
5167 typedef struct LDKBroadcasterInterface_JCalls {
5168         atomic_size_t refcnt;
5169         JavaVM *vm;
5170         jweak o;
5171         jmethodID broadcast_transaction_meth;
5172 } LDKBroadcasterInterface_JCalls;
5173 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
5174         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5175         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5176                 JNIEnv *env;
5177                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5178                 if (get_jenv_res == JNI_EDETACHED) {
5179                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5180                 } else {
5181                         DO_ASSERT(get_jenv_res == JNI_OK);
5182                 }
5183                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5184                 if (get_jenv_res == JNI_EDETACHED) {
5185                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5186                 }
5187                 FREE(j_calls);
5188         }
5189 }
5190 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
5191         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5192         JNIEnv *env;
5193         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5194         if (get_jenv_res == JNI_EDETACHED) {
5195                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5196         } else {
5197                 DO_ASSERT(get_jenv_res == JNI_OK);
5198         }
5199         LDKTransaction tx_var = tx;
5200         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
5201         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
5202         Transaction_free(tx_var);
5203         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5204         CHECK(obj != NULL);
5205         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
5206         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5207                 (*env)->ExceptionDescribe(env);
5208                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
5209         }
5210         if (get_jenv_res == JNI_EDETACHED) {
5211                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5212         }
5213 }
5214 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
5215         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
5216         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5217 }
5218 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
5219         jclass c = (*env)->GetObjectClass(env, o);
5220         CHECK(c != NULL);
5221         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
5222         atomic_init(&calls->refcnt, 1);
5223         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5224         calls->o = (*env)->NewWeakGlobalRef(env, o);
5225         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
5226         CHECK(calls->broadcast_transaction_meth != NULL);
5227
5228         LDKBroadcasterInterface ret = {
5229                 .this_arg = (void*) calls,
5230                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
5231                 .free = LDKBroadcasterInterface_JCalls_free,
5232         };
5233         return ret;
5234 }
5235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
5236         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
5237         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
5238         return (uint64_t)res_ptr;
5239 }
5240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
5241         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5242         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5243         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
5244         LDKTransaction tx_ref;
5245         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
5246         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
5247         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
5248         tx_ref.data_is_owned = true;
5249         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
5250 }
5251
5252 typedef struct LDKKeysInterface_JCalls {
5253         atomic_size_t refcnt;
5254         JavaVM *vm;
5255         jweak o;
5256         jmethodID get_node_secret_meth;
5257         jmethodID get_destination_script_meth;
5258         jmethodID get_shutdown_scriptpubkey_meth;
5259         jmethodID get_channel_signer_meth;
5260         jmethodID get_secure_random_bytes_meth;
5261         jmethodID read_chan_signer_meth;
5262         jmethodID sign_invoice_meth;
5263         jmethodID get_inbound_payment_key_material_meth;
5264 } LDKKeysInterface_JCalls;
5265 static void LDKKeysInterface_JCalls_free(void* this_arg) {
5266         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5267         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5268                 JNIEnv *env;
5269                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5270                 if (get_jenv_res == JNI_EDETACHED) {
5271                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5272                 } else {
5273                         DO_ASSERT(get_jenv_res == JNI_OK);
5274                 }
5275                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5276                 if (get_jenv_res == JNI_EDETACHED) {
5277                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5278                 }
5279                 FREE(j_calls);
5280         }
5281 }
5282 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
5283         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5284         JNIEnv *env;
5285         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5286         if (get_jenv_res == JNI_EDETACHED) {
5287                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5288         } else {
5289                 DO_ASSERT(get_jenv_res == JNI_OK);
5290         }
5291         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5292         CHECK(obj != NULL);
5293         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
5294         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5295                 (*env)->ExceptionDescribe(env);
5296                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
5297         }
5298         LDKSecretKey ret_ref;
5299         CHECK((*env)->GetArrayLength(env, ret) == 32);
5300         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
5301         if (get_jenv_res == JNI_EDETACHED) {
5302                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5303         }
5304         return ret_ref;
5305 }
5306 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
5307         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5308         JNIEnv *env;
5309         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5310         if (get_jenv_res == JNI_EDETACHED) {
5311                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5312         } else {
5313                 DO_ASSERT(get_jenv_res == JNI_OK);
5314         }
5315         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5316         CHECK(obj != NULL);
5317         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
5318         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5319                 (*env)->ExceptionDescribe(env);
5320                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
5321         }
5322         LDKCVec_u8Z ret_ref;
5323         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5324         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5325         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5326         if (get_jenv_res == JNI_EDETACHED) {
5327                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5328         }
5329         return ret_ref;
5330 }
5331 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
5332         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5333         JNIEnv *env;
5334         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5335         if (get_jenv_res == JNI_EDETACHED) {
5336                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5337         } else {
5338                 DO_ASSERT(get_jenv_res == JNI_OK);
5339         }
5340         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5341         CHECK(obj != NULL);
5342         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
5343         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5344                 (*env)->ExceptionDescribe(env);
5345                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
5346         }
5347         LDKShutdownScript ret_conv;
5348         ret_conv.inner = (void*)(ret & (~1));
5349         ret_conv.is_owned = (ret & 1) || (ret == 0);
5350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
5351         if (get_jenv_res == JNI_EDETACHED) {
5352                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5353         }
5354         return ret_conv;
5355 }
5356 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
5357         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5358         JNIEnv *env;
5359         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5360         if (get_jenv_res == JNI_EDETACHED) {
5361                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5362         } else {
5363                 DO_ASSERT(get_jenv_res == JNI_OK);
5364         }
5365         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5366         CHECK(obj != NULL);
5367         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
5368         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5369                 (*env)->ExceptionDescribe(env);
5370                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
5371         }
5372         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5373         CHECK_ACCESS(ret_ptr);
5374         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
5375         FREE((void*)ret);
5376         if (get_jenv_res == JNI_EDETACHED) {
5377                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5378         }
5379         return ret_conv;
5380 }
5381 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
5382         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5383         JNIEnv *env;
5384         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5385         if (get_jenv_res == JNI_EDETACHED) {
5386                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5387         } else {
5388                 DO_ASSERT(get_jenv_res == JNI_OK);
5389         }
5390         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5391         CHECK(obj != NULL);
5392         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
5393         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5394                 (*env)->ExceptionDescribe(env);
5395                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
5396         }
5397         LDKThirtyTwoBytes ret_ref;
5398         CHECK((*env)->GetArrayLength(env, ret) == 32);
5399         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5400         if (get_jenv_res == JNI_EDETACHED) {
5401                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5402         }
5403         return ret_ref;
5404 }
5405 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
5406         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5407         JNIEnv *env;
5408         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5409         if (get_jenv_res == JNI_EDETACHED) {
5410                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5411         } else {
5412                 DO_ASSERT(get_jenv_res == JNI_OK);
5413         }
5414         LDKu8slice reader_var = reader;
5415         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
5416         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
5417         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5418         CHECK(obj != NULL);
5419         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
5420         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5421                 (*env)->ExceptionDescribe(env);
5422                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
5423         }
5424         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5425         CHECK_ACCESS(ret_ptr);
5426         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
5427         FREE((void*)ret);
5428         if (get_jenv_res == JNI_EDETACHED) {
5429                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5430         }
5431         return ret_conv;
5432 }
5433 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
5434         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5435         JNIEnv *env;
5436         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5437         if (get_jenv_res == JNI_EDETACHED) {
5438                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5439         } else {
5440                 DO_ASSERT(get_jenv_res == JNI_OK);
5441         }
5442         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
5443         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
5444         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
5445         CVec_u8Z_free(invoice_preimage_var);
5446         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5447         CHECK(obj != NULL);
5448         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
5449         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5450                 (*env)->ExceptionDescribe(env);
5451                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
5452         }
5453         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5454         CHECK_ACCESS(ret_ptr);
5455         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
5456         FREE((void*)ret);
5457         if (get_jenv_res == JNI_EDETACHED) {
5458                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5459         }
5460         return ret_conv;
5461 }
5462 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
5463         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5464         JNIEnv *env;
5465         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5466         if (get_jenv_res == JNI_EDETACHED) {
5467                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5468         } else {
5469                 DO_ASSERT(get_jenv_res == JNI_OK);
5470         }
5471         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5472         CHECK(obj != NULL);
5473         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
5474         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5475                 (*env)->ExceptionDescribe(env);
5476                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
5477         }
5478         LDKThirtyTwoBytes ret_ref;
5479         CHECK((*env)->GetArrayLength(env, ret) == 32);
5480         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5481         if (get_jenv_res == JNI_EDETACHED) {
5482                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5483         }
5484         return ret_ref;
5485 }
5486 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
5487         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
5488         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5489 }
5490 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
5491         jclass c = (*env)->GetObjectClass(env, o);
5492         CHECK(c != NULL);
5493         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
5494         atomic_init(&calls->refcnt, 1);
5495         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5496         calls->o = (*env)->NewWeakGlobalRef(env, o);
5497         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
5498         CHECK(calls->get_node_secret_meth != NULL);
5499         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
5500         CHECK(calls->get_destination_script_meth != NULL);
5501         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
5502         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
5503         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
5504         CHECK(calls->get_channel_signer_meth != NULL);
5505         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
5506         CHECK(calls->get_secure_random_bytes_meth != NULL);
5507         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
5508         CHECK(calls->read_chan_signer_meth != NULL);
5509         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
5510         CHECK(calls->sign_invoice_meth != NULL);
5511         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
5512         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
5513
5514         LDKKeysInterface ret = {
5515                 .this_arg = (void*) calls,
5516                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
5517                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
5518                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
5519                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
5520                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
5521                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
5522                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
5523                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
5524                 .free = LDKKeysInterface_JCalls_free,
5525         };
5526         return ret;
5527 }
5528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
5529         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
5530         *res_ptr = LDKKeysInterface_init(env, clz, o);
5531         return (uint64_t)res_ptr;
5532 }
5533 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
5534         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5535         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5536         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5537         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
5539         return ret_arr;
5540 }
5541
5542 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
5543         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5544         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5545         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5546         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
5547         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5548         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5549         CVec_u8Z_free(ret_var);
5550         return ret_arr;
5551 }
5552
5553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
5554         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5555         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5556         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5557         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
5558         uintptr_t ret_ref = 0;
5559         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5560         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5562         ret_ref = (uintptr_t)ret_var.inner;
5563         if (ret_var.is_owned) {
5564                 ret_ref |= 1;
5565         }
5566         return ret_ref;
5567 }
5568
5569 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) {
5570         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5571         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5572         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5573         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5574         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
5575         return (uintptr_t)ret_ret;
5576 }
5577
5578 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
5579         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5580         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5581         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5582         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5583         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
5584         return ret_arr;
5585 }
5586
5587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
5588         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5589         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5590         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5591         LDKu8slice reader_ref;
5592         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
5593         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
5594         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
5595         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
5596         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
5597         return (uintptr_t)ret_conv;
5598 }
5599
5600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
5601         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5602         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5603         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5604         LDKCVec_u8Z invoice_preimage_ref;
5605         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
5606         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
5607         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
5608         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
5609         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
5610         return (uintptr_t)ret_conv;
5611 }
5612
5613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
5614         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5615         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5616         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5617         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5618         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
5619         return ret_arr;
5620 }
5621
5622 typedef struct LDKFeeEstimator_JCalls {
5623         atomic_size_t refcnt;
5624         JavaVM *vm;
5625         jweak o;
5626         jmethodID get_est_sat_per_1000_weight_meth;
5627 } LDKFeeEstimator_JCalls;
5628 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
5629         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5630         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5631                 JNIEnv *env;
5632                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5633                 if (get_jenv_res == JNI_EDETACHED) {
5634                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5635                 } else {
5636                         DO_ASSERT(get_jenv_res == JNI_OK);
5637                 }
5638                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5639                 if (get_jenv_res == JNI_EDETACHED) {
5640                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5641                 }
5642                 FREE(j_calls);
5643         }
5644 }
5645 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
5646         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5647         JNIEnv *env;
5648         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5649         if (get_jenv_res == JNI_EDETACHED) {
5650                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5651         } else {
5652                 DO_ASSERT(get_jenv_res == JNI_OK);
5653         }
5654         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
5655         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5656         CHECK(obj != NULL);
5657         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
5658         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5659                 (*env)->ExceptionDescribe(env);
5660                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
5661         }
5662         if (get_jenv_res == JNI_EDETACHED) {
5663                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5664         }
5665         return ret;
5666 }
5667 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
5668         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
5669         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5670 }
5671 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
5672         jclass c = (*env)->GetObjectClass(env, o);
5673         CHECK(c != NULL);
5674         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
5675         atomic_init(&calls->refcnt, 1);
5676         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5677         calls->o = (*env)->NewWeakGlobalRef(env, o);
5678         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
5679         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
5680
5681         LDKFeeEstimator ret = {
5682                 .this_arg = (void*) calls,
5683                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
5684                 .free = LDKFeeEstimator_JCalls_free,
5685         };
5686         return ret;
5687 }
5688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
5689         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
5690         *res_ptr = LDKFeeEstimator_init(env, clz, o);
5691         return (uint64_t)res_ptr;
5692 }
5693 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) {
5694         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5695         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5696         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
5697         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
5698         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
5699         return ret_val;
5700 }
5701
5702 typedef struct LDKLogger_JCalls {
5703         atomic_size_t refcnt;
5704         JavaVM *vm;
5705         jweak o;
5706         jmethodID log_meth;
5707 } LDKLogger_JCalls;
5708 static void LDKLogger_JCalls_free(void* this_arg) {
5709         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
5710         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5711                 JNIEnv *env;
5712                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5713                 if (get_jenv_res == JNI_EDETACHED) {
5714                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5715                 } else {
5716                         DO_ASSERT(get_jenv_res == JNI_OK);
5717                 }
5718                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5719                 if (get_jenv_res == JNI_EDETACHED) {
5720                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5721                 }
5722                 FREE(j_calls);
5723         }
5724 }
5725 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
5726         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
5727         JNIEnv *env;
5728         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5729         if (get_jenv_res == JNI_EDETACHED) {
5730                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5731         } else {
5732                 DO_ASSERT(get_jenv_res == JNI_OK);
5733         }
5734         LDKRecord record_var = *record;
5735         uintptr_t record_ref = 0;
5736         record_var = Record_clone(record);
5737         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5738         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5739         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
5740         record_ref = (uintptr_t)record_var.inner;
5741         if (record_var.is_owned) {
5742                 record_ref |= 1;
5743         }
5744         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5745         CHECK(obj != NULL);
5746         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
5747         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5748                 (*env)->ExceptionDescribe(env);
5749                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
5750         }
5751         if (get_jenv_res == JNI_EDETACHED) {
5752                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5753         }
5754 }
5755 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
5756         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
5757         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5758 }
5759 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
5760         jclass c = (*env)->GetObjectClass(env, o);
5761         CHECK(c != NULL);
5762         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
5763         atomic_init(&calls->refcnt, 1);
5764         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5765         calls->o = (*env)->NewWeakGlobalRef(env, o);
5766         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
5767         CHECK(calls->log_meth != NULL);
5768
5769         LDKLogger ret = {
5770                 .this_arg = (void*) calls,
5771                 .log = log_LDKLogger_jcall,
5772                 .free = LDKLogger_JCalls_free,
5773         };
5774         return ret;
5775 }
5776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
5777         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
5778         *res_ptr = LDKLogger_init(env, clz, o);
5779         return (uint64_t)res_ptr;
5780 }
5781 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5782         return ThirtyTwoBytes_clone(&owner->a);
5783 }
5784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5785         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5786         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5787         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
5788         return ret_arr;
5789 }
5790
5791 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5792         return &owner->b;
5793 }
5794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5795         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5796         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
5797         uintptr_t ret_ref = 0;
5798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5801         ret_ref = (uintptr_t)ret_var.inner & ~1;
5802         return ret_ref;
5803 }
5804
5805 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5806 CHECK(owner->result_ok);
5807         return &*owner->contents.result;
5808 }
5809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5810         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5811         uintptr_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
5812         return ret_ret;
5813 }
5814
5815 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5816 CHECK(!owner->result_ok);
5817         return DecodeError_clone(&*owner->contents.err);
5818 }
5819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5820         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5821         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
5822         uintptr_t ret_ref = 0;
5823         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5824         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5826         ret_ref = (uintptr_t)ret_var.inner;
5827         if (ret_var.is_owned) {
5828                 ret_ref |= 1;
5829         }
5830         return ret_ref;
5831 }
5832
5833 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5834 CHECK(owner->result_ok);
5835         return ChannelConfig_clone(&*owner->contents.result);
5836 }
5837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5838         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5839         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
5840         uintptr_t ret_ref = 0;
5841         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5842         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5844         ret_ref = (uintptr_t)ret_var.inner;
5845         if (ret_var.is_owned) {
5846                 ret_ref |= 1;
5847         }
5848         return ret_ref;
5849 }
5850
5851 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5852 CHECK(!owner->result_ok);
5853         return DecodeError_clone(&*owner->contents.err);
5854 }
5855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5856         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5857         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
5858         uintptr_t ret_ref = 0;
5859         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5860         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5862         ret_ref = (uintptr_t)ret_var.inner;
5863         if (ret_var.is_owned) {
5864                 ret_ref |= 1;
5865         }
5866         return ret_ref;
5867 }
5868
5869 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5870 CHECK(owner->result_ok);
5871         return OutPoint_clone(&*owner->contents.result);
5872 }
5873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5874         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5875         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
5876         uintptr_t ret_ref = 0;
5877         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5878         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5880         ret_ref = (uintptr_t)ret_var.inner;
5881         if (ret_var.is_owned) {
5882                 ret_ref |= 1;
5883         }
5884         return ret_ref;
5885 }
5886
5887 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5888 CHECK(!owner->result_ok);
5889         return DecodeError_clone(&*owner->contents.err);
5890 }
5891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5892         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5893         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
5894         uintptr_t ret_ref = 0;
5895         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5896         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5898         ret_ref = (uintptr_t)ret_var.inner;
5899         if (ret_var.is_owned) {
5900                 ret_ref |= 1;
5901         }
5902         return ret_ref;
5903 }
5904
5905 typedef struct LDKType_JCalls {
5906         atomic_size_t refcnt;
5907         JavaVM *vm;
5908         jweak o;
5909         jmethodID type_id_meth;
5910         jmethodID debug_str_meth;
5911         jmethodID write_meth;
5912 } LDKType_JCalls;
5913 static void LDKType_JCalls_free(void* this_arg) {
5914         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5915         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5916                 JNIEnv *env;
5917                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5918                 if (get_jenv_res == JNI_EDETACHED) {
5919                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5920                 } else {
5921                         DO_ASSERT(get_jenv_res == JNI_OK);
5922                 }
5923                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5924                 if (get_jenv_res == JNI_EDETACHED) {
5925                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5926                 }
5927                 FREE(j_calls);
5928         }
5929 }
5930 uint16_t type_id_LDKType_jcall(const void* this_arg) {
5931         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5932         JNIEnv *env;
5933         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5934         if (get_jenv_res == JNI_EDETACHED) {
5935                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5936         } else {
5937                 DO_ASSERT(get_jenv_res == JNI_OK);
5938         }
5939         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5940         CHECK(obj != NULL);
5941         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
5942         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5943                 (*env)->ExceptionDescribe(env);
5944                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
5945         }
5946         if (get_jenv_res == JNI_EDETACHED) {
5947                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5948         }
5949         return ret;
5950 }
5951 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
5952         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5953         JNIEnv *env;
5954         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5955         if (get_jenv_res == JNI_EDETACHED) {
5956                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5957         } else {
5958                 DO_ASSERT(get_jenv_res == JNI_OK);
5959         }
5960         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5961         CHECK(obj != NULL);
5962         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
5963         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5964                 (*env)->ExceptionDescribe(env);
5965                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
5966         }
5967         LDKStr ret_conv = java_to_owned_str(env, ret);
5968         if (get_jenv_res == JNI_EDETACHED) {
5969                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5970         }
5971         return ret_conv;
5972 }
5973 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5974         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5975         JNIEnv *env;
5976         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5977         if (get_jenv_res == JNI_EDETACHED) {
5978                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5979         } else {
5980                 DO_ASSERT(get_jenv_res == JNI_OK);
5981         }
5982         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5983         CHECK(obj != NULL);
5984         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5985         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5986                 (*env)->ExceptionDescribe(env);
5987                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
5988         }
5989         LDKCVec_u8Z ret_ref;
5990         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5991         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5992         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5993         if (get_jenv_res == JNI_EDETACHED) {
5994                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5995         }
5996         return ret_ref;
5997 }
5998 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5999         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
6000         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6001 }
6002 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
6003         jclass c = (*env)->GetObjectClass(env, o);
6004         CHECK(c != NULL);
6005         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
6006         atomic_init(&calls->refcnt, 1);
6007         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6008         calls->o = (*env)->NewWeakGlobalRef(env, o);
6009         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
6010         CHECK(calls->type_id_meth != NULL);
6011         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
6012         CHECK(calls->debug_str_meth != NULL);
6013         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6014         CHECK(calls->write_meth != NULL);
6015
6016         LDKType ret = {
6017                 .this_arg = (void*) calls,
6018                 .type_id = type_id_LDKType_jcall,
6019                 .debug_str = debug_str_LDKType_jcall,
6020                 .write = write_LDKType_jcall,
6021                 .cloned = LDKType_JCalls_cloned,
6022                 .free = LDKType_JCalls_free,
6023         };
6024         return ret;
6025 }
6026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
6027         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
6028         *res_ptr = LDKType_init(env, clz, o);
6029         return (uint64_t)res_ptr;
6030 }
6031 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
6032         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6033         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6034         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6035         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
6036         return ret_val;
6037 }
6038
6039 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
6040         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6041         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6042         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6043         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
6044         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
6045         Str_free(ret_str);
6046         return ret_conv;
6047 }
6048
6049 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6050         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6051         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6052         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6053         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6054         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6055         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6056         CVec_u8Z_free(ret_var);
6057         return ret_arr;
6058 }
6059
6060 static jclass LDKCOption_TypeZ_Some_class = NULL;
6061 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
6062 static jclass LDKCOption_TypeZ_None_class = NULL;
6063 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
6064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
6065         LDKCOption_TypeZ_Some_class =
6066                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
6067         CHECK(LDKCOption_TypeZ_Some_class != NULL);
6068         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
6069         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
6070         LDKCOption_TypeZ_None_class =
6071                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
6072         CHECK(LDKCOption_TypeZ_None_class != NULL);
6073         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
6074         CHECK(LDKCOption_TypeZ_None_meth != NULL);
6075 }
6076 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6077         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
6078         switch(obj->tag) {
6079                 case LDKCOption_TypeZ_Some: {
6080                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
6081                         *some_ret = Type_clone(&obj->some);
6082                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (uintptr_t)some_ret);
6083                 }
6084                 case LDKCOption_TypeZ_None: {
6085                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
6086                 }
6087                 default: abort();
6088         }
6089 }
6090 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
6091 CHECK(owner->result_ok);
6092         return COption_TypeZ_clone(&*owner->contents.result);
6093 }
6094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6095         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
6096         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
6097         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
6098         uintptr_t ret_ref = (uintptr_t)ret_copy;
6099         return ret_ref;
6100 }
6101
6102 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
6103 CHECK(!owner->result_ok);
6104         return DecodeError_clone(&*owner->contents.err);
6105 }
6106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6107         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
6108         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
6109         uintptr_t ret_ref = 0;
6110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6113         ret_ref = (uintptr_t)ret_var.inner;
6114         if (ret_var.is_owned) {
6115                 ret_ref |= 1;
6116         }
6117         return ret_ref;
6118 }
6119
6120 static jclass LDKPaymentError_Invoice_class = NULL;
6121 static jmethodID LDKPaymentError_Invoice_meth = NULL;
6122 static jclass LDKPaymentError_Routing_class = NULL;
6123 static jmethodID LDKPaymentError_Routing_meth = NULL;
6124 static jclass LDKPaymentError_Sending_class = NULL;
6125 static jmethodID LDKPaymentError_Sending_meth = NULL;
6126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
6127         LDKPaymentError_Invoice_class =
6128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
6129         CHECK(LDKPaymentError_Invoice_class != NULL);
6130         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
6131         CHECK(LDKPaymentError_Invoice_meth != NULL);
6132         LDKPaymentError_Routing_class =
6133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
6134         CHECK(LDKPaymentError_Routing_class != NULL);
6135         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
6136         CHECK(LDKPaymentError_Routing_meth != NULL);
6137         LDKPaymentError_Sending_class =
6138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
6139         CHECK(LDKPaymentError_Sending_class != NULL);
6140         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
6141         CHECK(LDKPaymentError_Sending_meth != NULL);
6142 }
6143 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6144         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6145         switch(obj->tag) {
6146                 case LDKPaymentError_Invoice: {
6147                         LDKStr invoice_str = obj->invoice;
6148                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
6149                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
6150                 }
6151                 case LDKPaymentError_Routing: {
6152                         LDKLightningError routing_var = obj->routing;
6153                         uintptr_t routing_ref = 0;
6154                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6155                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6156                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
6157                         routing_ref = (uintptr_t)routing_var.inner & ~1;
6158                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
6159                 }
6160                 case LDKPaymentError_Sending: {
6161                         uintptr_t sending_ref = ((uintptr_t)&obj->sending) | 1;
6162                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
6163                 }
6164                 default: abort();
6165         }
6166 }
6167 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6168 CHECK(owner->result_ok);
6169         return ThirtyTwoBytes_clone(&*owner->contents.result);
6170 }
6171 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6172         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6173         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6174         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
6175         return ret_arr;
6176 }
6177
6178 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6179 CHECK(!owner->result_ok);
6180         return PaymentError_clone(&*owner->contents.err);
6181 }
6182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6183         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6184         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
6185         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
6186         uintptr_t ret_ref = (uintptr_t)ret_copy;
6187         return ret_ref;
6188 }
6189
6190 static inline enum LDKSiPrefix CResult_SiPrefixNoneZ_get_ok(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
6191 CHECK(owner->result_ok);
6192         return SiPrefix_clone(&*owner->contents.result);
6193 }
6194 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6195         LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
6196         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixNoneZ_get_ok(owner_conv));
6197         return ret_conv;
6198 }
6199
6200 static inline void CResult_SiPrefixNoneZ_get_err(LDKCResult_SiPrefixNoneZ *NONNULL_PTR owner){
6201 CHECK(!owner->result_ok);
6202         return *owner->contents.err;
6203 }
6204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6205         LDKCResult_SiPrefixNoneZ* owner_conv = (LDKCResult_SiPrefixNoneZ*)(owner & ~1);
6206         CResult_SiPrefixNoneZ_get_err(owner_conv);
6207 }
6208
6209 static inline struct LDKInvoice CResult_InvoiceNoneZ_get_ok(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
6210 CHECK(owner->result_ok);
6211         return Invoice_clone(&*owner->contents.result);
6212 }
6213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6214         LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
6215         LDKInvoice ret_var = CResult_InvoiceNoneZ_get_ok(owner_conv);
6216         uintptr_t ret_ref = 0;
6217         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6218         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6220         ret_ref = (uintptr_t)ret_var.inner;
6221         if (ret_var.is_owned) {
6222                 ret_ref |= 1;
6223         }
6224         return ret_ref;
6225 }
6226
6227 static inline void CResult_InvoiceNoneZ_get_err(LDKCResult_InvoiceNoneZ *NONNULL_PTR owner){
6228 CHECK(!owner->result_ok);
6229         return *owner->contents.err;
6230 }
6231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6232         LDKCResult_InvoiceNoneZ* owner_conv = (LDKCResult_InvoiceNoneZ*)(owner & ~1);
6233         CResult_InvoiceNoneZ_get_err(owner_conv);
6234 }
6235
6236 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceNoneZ_get_ok(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
6237 CHECK(owner->result_ok);
6238         return SignedRawInvoice_clone(&*owner->contents.result);
6239 }
6240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6241         LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
6242         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceNoneZ_get_ok(owner_conv);
6243         uintptr_t ret_ref = 0;
6244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6247         ret_ref = (uintptr_t)ret_var.inner;
6248         if (ret_var.is_owned) {
6249                 ret_ref |= 1;
6250         }
6251         return ret_ref;
6252 }
6253
6254 static inline void CResult_SignedRawInvoiceNoneZ_get_err(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR owner){
6255 CHECK(!owner->result_ok);
6256         return *owner->contents.err;
6257 }
6258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6259         LDKCResult_SignedRawInvoiceNoneZ* owner_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(owner & ~1);
6260         CResult_SignedRawInvoiceNoneZ_get_err(owner_conv);
6261 }
6262
6263 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6264         return RawInvoice_clone(&owner->a);
6265 }
6266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6267         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6268         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
6269         uintptr_t ret_ref = 0;
6270         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6271         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6273         ret_ref = (uintptr_t)ret_var.inner;
6274         if (ret_var.is_owned) {
6275                 ret_ref |= 1;
6276         }
6277         return ret_ref;
6278 }
6279
6280 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6281         return ThirtyTwoBytes_clone(&owner->b);
6282 }
6283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6284         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6285         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6286         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
6287         return ret_arr;
6288 }
6289
6290 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6291         return InvoiceSignature_clone(&owner->c);
6292 }
6293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
6294         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6295         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
6296         uintptr_t ret_ref = 0;
6297         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6298         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6300         ret_ref = (uintptr_t)ret_var.inner;
6301         if (ret_var.is_owned) {
6302                 ret_ref |= 1;
6303         }
6304         return ret_ref;
6305 }
6306
6307 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6308 CHECK(owner->result_ok);
6309         return PayeePubKey_clone(&*owner->contents.result);
6310 }
6311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6312         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6313         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
6314         uintptr_t ret_ref = 0;
6315         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6316         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6318         ret_ref = (uintptr_t)ret_var.inner;
6319         if (ret_var.is_owned) {
6320                 ret_ref |= 1;
6321         }
6322         return ret_ref;
6323 }
6324
6325 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6326 CHECK(!owner->result_ok);
6327         return *owner->contents.err;
6328 }
6329 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6330         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6331         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
6332         return ret_conv;
6333 }
6334
6335 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
6336         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
6337         for (size_t i = 0; i < ret.datalen; i++) {
6338                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
6339         }
6340         return ret;
6341 }
6342 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6343 CHECK(owner->result_ok);
6344         return PositiveTimestamp_clone(&*owner->contents.result);
6345 }
6346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6347         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6348         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
6349         uintptr_t ret_ref = 0;
6350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6353         ret_ref = (uintptr_t)ret_var.inner;
6354         if (ret_var.is_owned) {
6355                 ret_ref |= 1;
6356         }
6357         return ret_ref;
6358 }
6359
6360 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6361 CHECK(!owner->result_ok);
6362         return CreationError_clone(&*owner->contents.err);
6363 }
6364 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6365         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6366         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
6367         return ret_conv;
6368 }
6369
6370 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6371 CHECK(owner->result_ok);
6372         return *owner->contents.result;
6373 }
6374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6375         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6376         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
6377 }
6378
6379 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6380 CHECK(!owner->result_ok);
6381         return SemanticError_clone(&*owner->contents.err);
6382 }
6383 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6384         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6385         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
6386         return ret_conv;
6387 }
6388
6389 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6390 CHECK(owner->result_ok);
6391         return Invoice_clone(&*owner->contents.result);
6392 }
6393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6394         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6395         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
6396         uintptr_t ret_ref = 0;
6397         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6398         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6400         ret_ref = (uintptr_t)ret_var.inner;
6401         if (ret_var.is_owned) {
6402                 ret_ref |= 1;
6403         }
6404         return ret_ref;
6405 }
6406
6407 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6408 CHECK(!owner->result_ok);
6409         return SemanticError_clone(&*owner->contents.err);
6410 }
6411 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6412         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6413         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
6414         return ret_conv;
6415 }
6416
6417 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6418 CHECK(owner->result_ok);
6419         return Description_clone(&*owner->contents.result);
6420 }
6421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6422         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6423         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
6424         uintptr_t ret_ref = 0;
6425         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6426         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6428         ret_ref = (uintptr_t)ret_var.inner;
6429         if (ret_var.is_owned) {
6430                 ret_ref |= 1;
6431         }
6432         return ret_ref;
6433 }
6434
6435 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6436 CHECK(!owner->result_ok);
6437         return CreationError_clone(&*owner->contents.err);
6438 }
6439 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6440         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6441         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
6442         return ret_conv;
6443 }
6444
6445 static inline struct LDKExpiryTime CResult_ExpiryTimeCreationErrorZ_get_ok(LDKCResult_ExpiryTimeCreationErrorZ *NONNULL_PTR owner){
6446 CHECK(owner->result_ok);
6447         return ExpiryTime_clone(&*owner->contents.result);
6448 }
6449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6450         LDKCResult_ExpiryTimeCreationErrorZ* owner_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(owner & ~1);
6451         LDKExpiryTime ret_var = CResult_ExpiryTimeCreationErrorZ_get_ok(owner_conv);
6452         uintptr_t ret_ref = 0;
6453         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6454         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6456         ret_ref = (uintptr_t)ret_var.inner;
6457         if (ret_var.is_owned) {
6458                 ret_ref |= 1;
6459         }
6460         return ret_ref;
6461 }
6462
6463 static inline enum LDKCreationError CResult_ExpiryTimeCreationErrorZ_get_err(LDKCResult_ExpiryTimeCreationErrorZ *NONNULL_PTR owner){
6464 CHECK(!owner->result_ok);
6465         return CreationError_clone(&*owner->contents.err);
6466 }
6467 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6468         LDKCResult_ExpiryTimeCreationErrorZ* owner_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(owner & ~1);
6469         jclass ret_conv = LDKCreationError_to_java(env, CResult_ExpiryTimeCreationErrorZ_get_err(owner_conv));
6470         return ret_conv;
6471 }
6472
6473 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6474 CHECK(owner->result_ok);
6475         return PrivateRoute_clone(&*owner->contents.result);
6476 }
6477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6478         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6479         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
6480         uintptr_t ret_ref = 0;
6481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6484         ret_ref = (uintptr_t)ret_var.inner;
6485         if (ret_var.is_owned) {
6486                 ret_ref |= 1;
6487         }
6488         return ret_ref;
6489 }
6490
6491 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6492 CHECK(!owner->result_ok);
6493         return CreationError_clone(&*owner->contents.err);
6494 }
6495 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6496         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6497         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
6498         return ret_conv;
6499 }
6500
6501 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6502 CHECK(owner->result_ok);
6503         return *owner->contents.result;
6504 }
6505 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6506         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6507         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
6508         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
6509         return ret_conv;
6510 }
6511
6512 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6513 CHECK(!owner->result_ok);
6514         return *owner->contents.err;
6515 }
6516 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6517         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6518         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
6519         return ret_conv;
6520 }
6521
6522 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6523 CHECK(owner->result_ok);
6524         return ChannelMonitorUpdate_clone(&*owner->contents.result);
6525 }
6526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6527         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6528         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
6529         uintptr_t ret_ref = 0;
6530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6533         ret_ref = (uintptr_t)ret_var.inner;
6534         if (ret_var.is_owned) {
6535                 ret_ref |= 1;
6536         }
6537         return ret_ref;
6538 }
6539
6540 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6541 CHECK(!owner->result_ok);
6542         return DecodeError_clone(&*owner->contents.err);
6543 }
6544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6545         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6546         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
6547         uintptr_t ret_ref = 0;
6548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6551         ret_ref = (uintptr_t)ret_var.inner;
6552         if (ret_var.is_owned) {
6553                 ret_ref |= 1;
6554         }
6555         return ret_ref;
6556 }
6557
6558 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
6559 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
6560 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
6561 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
6562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
6563         LDKCOption_MonitorEventZ_Some_class =
6564                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
6565         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
6566         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
6567         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
6568         LDKCOption_MonitorEventZ_None_class =
6569                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
6570         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
6571         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
6572         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
6573 }
6574 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6575         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
6576         switch(obj->tag) {
6577                 case LDKCOption_MonitorEventZ_Some: {
6578                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
6579                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
6580                 }
6581                 case LDKCOption_MonitorEventZ_None: {
6582                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
6583                 }
6584                 default: abort();
6585         }
6586 }
6587 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6588 CHECK(owner->result_ok);
6589         return COption_MonitorEventZ_clone(&*owner->contents.result);
6590 }
6591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6592         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6593         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
6594         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
6595         uintptr_t ret_ref = (uintptr_t)ret_copy;
6596         return ret_ref;
6597 }
6598
6599 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6600 CHECK(!owner->result_ok);
6601         return DecodeError_clone(&*owner->contents.err);
6602 }
6603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6604         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6605         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
6606         uintptr_t ret_ref = 0;
6607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6610         ret_ref = (uintptr_t)ret_var.inner;
6611         if (ret_var.is_owned) {
6612                 ret_ref |= 1;
6613         }
6614         return ret_ref;
6615 }
6616
6617 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6618 CHECK(owner->result_ok);
6619         return HTLCUpdate_clone(&*owner->contents.result);
6620 }
6621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6622         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6623         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
6624         uintptr_t ret_ref = 0;
6625         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6626         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6628         ret_ref = (uintptr_t)ret_var.inner;
6629         if (ret_var.is_owned) {
6630                 ret_ref |= 1;
6631         }
6632         return ret_ref;
6633 }
6634
6635 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6636 CHECK(!owner->result_ok);
6637         return DecodeError_clone(&*owner->contents.err);
6638 }
6639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6640         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6641         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
6642         uintptr_t ret_ref = 0;
6643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6646         ret_ref = (uintptr_t)ret_var.inner;
6647         if (ret_var.is_owned) {
6648                 ret_ref |= 1;
6649         }
6650         return ret_ref;
6651 }
6652
6653 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6654         return OutPoint_clone(&owner->a);
6655 }
6656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6657         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6658         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
6659         uintptr_t ret_ref = 0;
6660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6663         ret_ref = (uintptr_t)ret_var.inner;
6664         if (ret_var.is_owned) {
6665                 ret_ref |= 1;
6666         }
6667         return ret_ref;
6668 }
6669
6670 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6671         return CVec_u8Z_clone(&owner->b);
6672 }
6673 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6674         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6675         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
6676         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6677         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6678         CVec_u8Z_free(ret_var);
6679         return ret_arr;
6680 }
6681
6682 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6683         return owner->a;
6684 }
6685 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6686         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6687         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
6688         return ret_val;
6689 }
6690
6691 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6692         return CVec_u8Z_clone(&owner->b);
6693 }
6694 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6695         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6696         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
6697         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6698         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6699         CVec_u8Z_free(ret_var);
6700         return ret_arr;
6701 }
6702
6703 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
6704         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
6705         for (size_t i = 0; i < ret.datalen; i++) {
6706                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
6707         }
6708         return ret;
6709 }
6710 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6711         return ThirtyTwoBytes_clone(&owner->a);
6712 }
6713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6714         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6715         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6716         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
6717         return ret_arr;
6718 }
6719
6720 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6721         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
6722 }
6723 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6724         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6725         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
6726         int64_tArray ret_arr = NULL;
6727         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6728         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6729         for (size_t v = 0; v < ret_var.datalen; v++) {
6730                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6731                 *ret_conv_21_conv = ret_var.data[v];
6732                 ret_arr_ptr[v] = ((uintptr_t)ret_conv_21_conv);
6733         }
6734         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6735         FREE(ret_var.data);
6736         return ret_arr;
6737 }
6738
6739 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
6740         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 };
6741         for (size_t i = 0; i < ret.datalen; i++) {
6742                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
6743         }
6744         return ret;
6745 }
6746 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
6747         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
6748         for (size_t i = 0; i < ret.datalen; i++) {
6749                 ret.data[i] = Event_clone(&orig->data[i]);
6750         }
6751         return ret;
6752 }
6753 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6754         return owner->a;
6755 }
6756 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6757         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6758         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
6759         return ret_val;
6760 }
6761
6762 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6763         return TxOut_clone(&owner->b);
6764 }
6765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6766         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6767         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6768         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
6769         return (uintptr_t)ret_ref;
6770 }
6771
6772 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
6773         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
6774         for (size_t i = 0; i < ret.datalen; i++) {
6775                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
6776         }
6777         return ret;
6778 }
6779 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6780         return ThirtyTwoBytes_clone(&owner->a);
6781 }
6782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6783         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6784         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6785         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
6786         return ret_arr;
6787 }
6788
6789 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6790         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
6791 }
6792 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6793         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6794         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
6795         int64_tArray ret_arr = NULL;
6796         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6797         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6798         for (size_t u = 0; u < ret_var.datalen; u++) {
6799                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6800                 *ret_conv_20_conv = ret_var.data[u];
6801                 ret_arr_ptr[u] = ((uintptr_t)ret_conv_20_conv);
6802         }
6803         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6804         FREE(ret_var.data);
6805         return ret_arr;
6806 }
6807
6808 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
6809         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 };
6810         for (size_t i = 0; i < ret.datalen; i++) {
6811                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
6812         }
6813         return ret;
6814 }
6815 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
6816 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
6817 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
6818 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
6819 static jclass LDKBalance_ContentiousClaimable_class = NULL;
6820 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
6821 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
6822 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
6823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
6824         LDKBalance_ClaimableOnChannelClose_class =
6825                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
6826         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
6827         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
6828         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
6829         LDKBalance_ClaimableAwaitingConfirmations_class =
6830                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
6831         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
6832         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
6833         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
6834         LDKBalance_ContentiousClaimable_class =
6835                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
6836         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
6837         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
6838         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
6839         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
6840                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
6841         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
6842         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
6843         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
6844 }
6845 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6846         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6847         switch(obj->tag) {
6848                 case LDKBalance_ClaimableOnChannelClose: {
6849                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis);
6850                 }
6851                 case LDKBalance_ClaimableAwaitingConfirmations: {
6852                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height);
6853                 }
6854                 case LDKBalance_ContentiousClaimable: {
6855                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height);
6856                 }
6857                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
6858                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis, obj->maybe_claimable_htlc_awaiting_timeout.claimable_height);
6859                 }
6860                 default: abort();
6861         }
6862 }
6863 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
6864         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
6865         for (size_t i = 0; i < ret.datalen; i++) {
6866                 ret.data[i] = Balance_clone(&orig->data[i]);
6867         }
6868         return ret;
6869 }
6870 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6871 CHECK(owner->result_ok);
6872         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
6873 }
6874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6875         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6876         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6877         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
6878         return ((uintptr_t)ret_conv);
6879 }
6880
6881 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6882 CHECK(!owner->result_ok);
6883         return DecodeError_clone(&*owner->contents.err);
6884 }
6885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6886         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6887         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
6888         uintptr_t ret_ref = 0;
6889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6892         ret_ref = (uintptr_t)ret_var.inner;
6893         if (ret_var.is_owned) {
6894                 ret_ref |= 1;
6895         }
6896         return ret_ref;
6897 }
6898
6899 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
6900 CHECK(owner->result_ok);
6901         return *owner->contents.result;
6902 }
6903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6904         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
6905         CResult_NoneLightningErrorZ_get_ok(owner_conv);
6906 }
6907
6908 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
6909 CHECK(!owner->result_ok);
6910         return LightningError_clone(&*owner->contents.err);
6911 }
6912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6913         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
6914         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
6915         uintptr_t ret_ref = 0;
6916         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6917         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6919         ret_ref = (uintptr_t)ret_var.inner;
6920         if (ret_var.is_owned) {
6921                 ret_ref |= 1;
6922         }
6923         return ret_ref;
6924 }
6925
6926 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6927         return owner->a;
6928 }
6929 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6930         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6931         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
6932         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
6933         return ret_arr;
6934 }
6935
6936 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6937         return Type_clone(&owner->b);
6938 }
6939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6940         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6941         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
6942         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
6943         return (uintptr_t)ret_ret;
6944 }
6945
6946 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
6947         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
6948         for (size_t i = 0; i < ret.datalen; i++) {
6949                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
6950         }
6951         return ret;
6952 }
6953 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
6954 CHECK(owner->result_ok);
6955         return *owner->contents.result;
6956 }
6957 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6958         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
6959         jboolean ret_val = CResult_boolLightningErrorZ_get_ok(owner_conv);
6960         return ret_val;
6961 }
6962
6963 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
6964 CHECK(!owner->result_ok);
6965         return LightningError_clone(&*owner->contents.err);
6966 }
6967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6968         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
6969         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
6970         uintptr_t ret_ref = 0;
6971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6974         ret_ref = (uintptr_t)ret_var.inner;
6975         if (ret_var.is_owned) {
6976                 ret_ref |= 1;
6977         }
6978         return ret_ref;
6979 }
6980
6981 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6982         return ChannelAnnouncement_clone(&owner->a);
6983 }
6984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6985         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
6986         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
6987         uintptr_t ret_ref = 0;
6988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6991         ret_ref = (uintptr_t)ret_var.inner;
6992         if (ret_var.is_owned) {
6993                 ret_ref |= 1;
6994         }
6995         return ret_ref;
6996 }
6997
6998 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6999         return ChannelUpdate_clone(&owner->b);
7000 }
7001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7002         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7003         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
7004         uintptr_t ret_ref = 0;
7005         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7006         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7008         ret_ref = (uintptr_t)ret_var.inner;
7009         if (ret_var.is_owned) {
7010                 ret_ref |= 1;
7011         }
7012         return ret_ref;
7013 }
7014
7015 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7016         return ChannelUpdate_clone(&owner->c);
7017 }
7018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
7019         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7020         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
7021         uintptr_t ret_ref = 0;
7022         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7023         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7025         ret_ref = (uintptr_t)ret_var.inner;
7026         if (ret_var.is_owned) {
7027                 ret_ref |= 1;
7028         }
7029         return ret_ref;
7030 }
7031
7032 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
7033         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
7034         for (size_t i = 0; i < ret.datalen; i++) {
7035                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
7036         }
7037         return ret;
7038 }
7039 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
7040         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
7041         for (size_t i = 0; i < ret.datalen; i++) {
7042                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
7043         }
7044         return ret;
7045 }
7046 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7047 CHECK(owner->result_ok);
7048         return CVec_u8Z_clone(&*owner->contents.result);
7049 }
7050 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7051         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
7052         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
7053         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7054         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7055         CVec_u8Z_free(ret_var);
7056         return ret_arr;
7057 }
7058
7059 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7060 CHECK(!owner->result_ok);
7061         return PeerHandleError_clone(&*owner->contents.err);
7062 }
7063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7064         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
7065         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
7066         uintptr_t ret_ref = 0;
7067         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7068         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7070         ret_ref = (uintptr_t)ret_var.inner;
7071         if (ret_var.is_owned) {
7072                 ret_ref |= 1;
7073         }
7074         return ret_ref;
7075 }
7076
7077 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7078 CHECK(owner->result_ok);
7079         return *owner->contents.result;
7080 }
7081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7082         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
7083         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
7084 }
7085
7086 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7087 CHECK(!owner->result_ok);
7088         return PeerHandleError_clone(&*owner->contents.err);
7089 }
7090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7091         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
7092         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
7093         uintptr_t ret_ref = 0;
7094         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7095         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7097         ret_ref = (uintptr_t)ret_var.inner;
7098         if (ret_var.is_owned) {
7099                 ret_ref |= 1;
7100         }
7101         return ret_ref;
7102 }
7103
7104 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7105 CHECK(owner->result_ok);
7106         return *owner->contents.result;
7107 }
7108 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7109         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
7110         jboolean ret_val = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
7111         return ret_val;
7112 }
7113
7114 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7115 CHECK(!owner->result_ok);
7116         return PeerHandleError_clone(&*owner->contents.err);
7117 }
7118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7119         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
7120         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
7121         uintptr_t ret_ref = 0;
7122         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7123         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7125         ret_ref = (uintptr_t)ret_var.inner;
7126         if (ret_var.is_owned) {
7127                 ret_ref |= 1;
7128         }
7129         return ret_ref;
7130 }
7131
7132 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
7133 CHECK(owner->result_ok);
7134         return NodeId_clone(&*owner->contents.result);
7135 }
7136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7137         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
7138         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
7139         uintptr_t ret_ref = 0;
7140         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7141         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7143         ret_ref = (uintptr_t)ret_var.inner;
7144         if (ret_var.is_owned) {
7145                 ret_ref |= 1;
7146         }
7147         return ret_ref;
7148 }
7149
7150 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
7151 CHECK(!owner->result_ok);
7152         return DecodeError_clone(&*owner->contents.err);
7153 }
7154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7155         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
7156         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
7157         uintptr_t ret_ref = 0;
7158         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7159         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7161         ret_ref = (uintptr_t)ret_var.inner;
7162         if (ret_var.is_owned) {
7163                 ret_ref |= 1;
7164         }
7165         return ret_ref;
7166 }
7167
7168 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
7169 CHECK(owner->result_ok);
7170         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
7171 }
7172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7173         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
7174         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
7175         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
7176         uintptr_t ret_ref = (uintptr_t)ret_copy;
7177         return ret_ref;
7178 }
7179
7180 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
7181 CHECK(!owner->result_ok);
7182         return DecodeError_clone(&*owner->contents.err);
7183 }
7184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7185         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
7186         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
7187         uintptr_t ret_ref = 0;
7188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7191         ret_ref = (uintptr_t)ret_var.inner;
7192         if (ret_var.is_owned) {
7193                 ret_ref |= 1;
7194         }
7195         return ret_ref;
7196 }
7197
7198 typedef struct LDKAccess_JCalls {
7199         atomic_size_t refcnt;
7200         JavaVM *vm;
7201         jweak o;
7202         jmethodID get_utxo_meth;
7203 } LDKAccess_JCalls;
7204 static void LDKAccess_JCalls_free(void* this_arg) {
7205         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
7206         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7207                 JNIEnv *env;
7208                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7209                 if (get_jenv_res == JNI_EDETACHED) {
7210                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7211                 } else {
7212                         DO_ASSERT(get_jenv_res == JNI_OK);
7213                 }
7214                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7215                 if (get_jenv_res == JNI_EDETACHED) {
7216                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7217                 }
7218                 FREE(j_calls);
7219         }
7220 }
7221 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
7222         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
7223         JNIEnv *env;
7224         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7225         if (get_jenv_res == JNI_EDETACHED) {
7226                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7227         } else {
7228                 DO_ASSERT(get_jenv_res == JNI_OK);
7229         }
7230         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
7231         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
7232         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7233         CHECK(obj != NULL);
7234         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
7235         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7236                 (*env)->ExceptionDescribe(env);
7237                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
7238         }
7239         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7240         CHECK_ACCESS(ret_ptr);
7241         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
7242         FREE((void*)ret);
7243         if (get_jenv_res == JNI_EDETACHED) {
7244                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7245         }
7246         return ret_conv;
7247 }
7248 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
7249         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
7250         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7251 }
7252 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
7253         jclass c = (*env)->GetObjectClass(env, o);
7254         CHECK(c != NULL);
7255         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
7256         atomic_init(&calls->refcnt, 1);
7257         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7258         calls->o = (*env)->NewWeakGlobalRef(env, o);
7259         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
7260         CHECK(calls->get_utxo_meth != NULL);
7261
7262         LDKAccess ret = {
7263                 .this_arg = (void*) calls,
7264                 .get_utxo = get_utxo_LDKAccess_jcall,
7265                 .free = LDKAccess_JCalls_free,
7266         };
7267         return ret;
7268 }
7269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
7270         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
7271         *res_ptr = LDKAccess_init(env, clz, o);
7272         return (uint64_t)res_ptr;
7273 }
7274 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) {
7275         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7276         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7277         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
7278         unsigned char genesis_hash_arr[32];
7279         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
7280         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
7281         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
7282         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
7283         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
7284         return (uintptr_t)ret_conv;
7285 }
7286
7287 static jclass LDKCOption_AccessZ_Some_class = NULL;
7288 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
7289 static jclass LDKCOption_AccessZ_None_class = NULL;
7290 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
7291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
7292         LDKCOption_AccessZ_Some_class =
7293                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
7294         CHECK(LDKCOption_AccessZ_Some_class != NULL);
7295         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
7296         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
7297         LDKCOption_AccessZ_None_class =
7298                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
7299         CHECK(LDKCOption_AccessZ_None_class != NULL);
7300         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
7301         CHECK(LDKCOption_AccessZ_None_meth != NULL);
7302 }
7303 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7304         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
7305         switch(obj->tag) {
7306                 case LDKCOption_AccessZ_Some: {
7307                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
7308                         *some_ret = obj->some;
7309                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
7310                         if ((*some_ret).free == LDKAccess_JCalls_free) {
7311                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7312                                 LDKAccess_JCalls_cloned(&(*some_ret));
7313                         }
7314                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (uintptr_t)some_ret);
7315                 }
7316                 case LDKCOption_AccessZ_None: {
7317                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
7318                 }
7319                 default: abort();
7320         }
7321 }
7322 static inline struct LDKDirectionalChannelInfo CResult_DirectionalChannelInfoDecodeErrorZ_get_ok(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR owner){
7323 CHECK(owner->result_ok);
7324         return DirectionalChannelInfo_clone(&*owner->contents.result);
7325 }
7326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7327         LDKCResult_DirectionalChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(owner & ~1);
7328         LDKDirectionalChannelInfo ret_var = CResult_DirectionalChannelInfoDecodeErrorZ_get_ok(owner_conv);
7329         uintptr_t ret_ref = 0;
7330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7333         ret_ref = (uintptr_t)ret_var.inner;
7334         if (ret_var.is_owned) {
7335                 ret_ref |= 1;
7336         }
7337         return ret_ref;
7338 }
7339
7340 static inline struct LDKDecodeError CResult_DirectionalChannelInfoDecodeErrorZ_get_err(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR owner){
7341 CHECK(!owner->result_ok);
7342         return DecodeError_clone(&*owner->contents.err);
7343 }
7344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7345         LDKCResult_DirectionalChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(owner & ~1);
7346         LDKDecodeError ret_var = CResult_DirectionalChannelInfoDecodeErrorZ_get_err(owner_conv);
7347         uintptr_t ret_ref = 0;
7348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7351         ret_ref = (uintptr_t)ret_var.inner;
7352         if (ret_var.is_owned) {
7353                 ret_ref |= 1;
7354         }
7355         return ret_ref;
7356 }
7357
7358 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
7359 CHECK(owner->result_ok);
7360         return ChannelInfo_clone(&*owner->contents.result);
7361 }
7362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7363         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
7364         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
7365         uintptr_t ret_ref = 0;
7366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7369         ret_ref = (uintptr_t)ret_var.inner;
7370         if (ret_var.is_owned) {
7371                 ret_ref |= 1;
7372         }
7373         return ret_ref;
7374 }
7375
7376 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
7377 CHECK(!owner->result_ok);
7378         return DecodeError_clone(&*owner->contents.err);
7379 }
7380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7381         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
7382         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
7383         uintptr_t ret_ref = 0;
7384         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7385         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7387         ret_ref = (uintptr_t)ret_var.inner;
7388         if (ret_var.is_owned) {
7389                 ret_ref |= 1;
7390         }
7391         return ret_ref;
7392 }
7393
7394 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
7395 CHECK(owner->result_ok);
7396         return RoutingFees_clone(&*owner->contents.result);
7397 }
7398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7399         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
7400         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
7401         uintptr_t ret_ref = 0;
7402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7405         ret_ref = (uintptr_t)ret_var.inner;
7406         if (ret_var.is_owned) {
7407                 ret_ref |= 1;
7408         }
7409         return ret_ref;
7410 }
7411
7412 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
7413 CHECK(!owner->result_ok);
7414         return DecodeError_clone(&*owner->contents.err);
7415 }
7416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7417         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
7418         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
7419         uintptr_t ret_ref = 0;
7420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7423         ret_ref = (uintptr_t)ret_var.inner;
7424         if (ret_var.is_owned) {
7425                 ret_ref |= 1;
7426         }
7427         return ret_ref;
7428 }
7429
7430 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
7431 CHECK(owner->result_ok);
7432         return NodeAnnouncementInfo_clone(&*owner->contents.result);
7433 }
7434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7435         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
7436         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
7437         uintptr_t ret_ref = 0;
7438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7441         ret_ref = (uintptr_t)ret_var.inner;
7442         if (ret_var.is_owned) {
7443                 ret_ref |= 1;
7444         }
7445         return ret_ref;
7446 }
7447
7448 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
7449 CHECK(!owner->result_ok);
7450         return DecodeError_clone(&*owner->contents.err);
7451 }
7452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7453         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
7454         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
7455         uintptr_t ret_ref = 0;
7456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7459         ret_ref = (uintptr_t)ret_var.inner;
7460         if (ret_var.is_owned) {
7461                 ret_ref |= 1;
7462         }
7463         return ret_ref;
7464 }
7465
7466 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
7467         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
7468         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
7469         return ret;
7470 }
7471 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
7472 CHECK(owner->result_ok);
7473         return NodeInfo_clone(&*owner->contents.result);
7474 }
7475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7476         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
7477         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
7478         uintptr_t ret_ref = 0;
7479         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7480         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7482         ret_ref = (uintptr_t)ret_var.inner;
7483         if (ret_var.is_owned) {
7484                 ret_ref |= 1;
7485         }
7486         return ret_ref;
7487 }
7488
7489 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
7490 CHECK(!owner->result_ok);
7491         return DecodeError_clone(&*owner->contents.err);
7492 }
7493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7494         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
7495         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
7496         uintptr_t ret_ref = 0;
7497         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7498         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7500         ret_ref = (uintptr_t)ret_var.inner;
7501         if (ret_var.is_owned) {
7502                 ret_ref |= 1;
7503         }
7504         return ret_ref;
7505 }
7506
7507 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
7508 CHECK(owner->result_ok);
7509         return NetworkGraph_clone(&*owner->contents.result);
7510 }
7511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7512         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
7513         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
7514         uintptr_t ret_ref = 0;
7515         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7516         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7518         ret_ref = (uintptr_t)ret_var.inner;
7519         if (ret_var.is_owned) {
7520                 ret_ref |= 1;
7521         }
7522         return ret_ref;
7523 }
7524
7525 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
7526 CHECK(!owner->result_ok);
7527         return DecodeError_clone(&*owner->contents.err);
7528 }
7529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7530         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
7531         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
7532         uintptr_t ret_ref = 0;
7533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7536         ret_ref = (uintptr_t)ret_var.inner;
7537         if (ret_var.is_owned) {
7538                 ret_ref |= 1;
7539         }
7540         return ret_ref;
7541 }
7542
7543 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
7544 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
7545 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
7546 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
7547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
7548         LDKCOption_CVec_NetAddressZZ_Some_class =
7549                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
7550         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
7551         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
7552         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
7553         LDKCOption_CVec_NetAddressZZ_None_class =
7554                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
7555         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
7556         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
7557         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
7558 }
7559 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7560         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
7561         switch(obj->tag) {
7562                 case LDKCOption_CVec_NetAddressZZ_Some: {
7563                         LDKCVec_NetAddressZ some_var = obj->some;
7564                         int64_tArray some_arr = NULL;
7565                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
7566                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
7567                         for (size_t m = 0; m < some_var.datalen; m++) {
7568                                 uintptr_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
7569                                 some_arr_ptr[m] = some_conv_12_ref;
7570                         }
7571                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
7572                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
7573                 }
7574                 case LDKCOption_CVec_NetAddressZZ_None: {
7575                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
7576                 }
7577                 default: abort();
7578         }
7579 }
7580 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
7581 CHECK(owner->result_ok);
7582         return NetAddress_clone(&*owner->contents.result);
7583 }
7584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7585         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
7586         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
7587         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
7588         uintptr_t ret_ref = (uintptr_t)ret_copy;
7589         return ret_ref;
7590 }
7591
7592 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
7593 CHECK(!owner->result_ok);
7594         return DecodeError_clone(&*owner->contents.err);
7595 }
7596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7597         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
7598         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
7599         uintptr_t ret_ref = 0;
7600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7603         ret_ref = (uintptr_t)ret_var.inner;
7604         if (ret_var.is_owned) {
7605                 ret_ref |= 1;
7606         }
7607         return ret_ref;
7608 }
7609
7610 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
7611         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
7612         for (size_t i = 0; i < ret.datalen; i++) {
7613                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
7614         }
7615         return ret;
7616 }
7617 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
7618         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
7619         for (size_t i = 0; i < ret.datalen; i++) {
7620                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
7621         }
7622         return ret;
7623 }
7624 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
7625         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
7626         for (size_t i = 0; i < ret.datalen; i++) {
7627                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
7628         }
7629         return ret;
7630 }
7631 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
7632         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
7633         for (size_t i = 0; i < ret.datalen; i++) {
7634                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
7635         }
7636         return ret;
7637 }
7638 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
7639 CHECK(owner->result_ok);
7640         return AcceptChannel_clone(&*owner->contents.result);
7641 }
7642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7643         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
7644         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
7645         uintptr_t ret_ref = 0;
7646         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7647         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7649         ret_ref = (uintptr_t)ret_var.inner;
7650         if (ret_var.is_owned) {
7651                 ret_ref |= 1;
7652         }
7653         return ret_ref;
7654 }
7655
7656 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
7657 CHECK(!owner->result_ok);
7658         return DecodeError_clone(&*owner->contents.err);
7659 }
7660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7661         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
7662         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
7663         uintptr_t ret_ref = 0;
7664         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7665         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7667         ret_ref = (uintptr_t)ret_var.inner;
7668         if (ret_var.is_owned) {
7669                 ret_ref |= 1;
7670         }
7671         return ret_ref;
7672 }
7673
7674 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
7675 CHECK(owner->result_ok);
7676         return AnnouncementSignatures_clone(&*owner->contents.result);
7677 }
7678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7679         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
7680         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
7681         uintptr_t ret_ref = 0;
7682         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7683         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7685         ret_ref = (uintptr_t)ret_var.inner;
7686         if (ret_var.is_owned) {
7687                 ret_ref |= 1;
7688         }
7689         return ret_ref;
7690 }
7691
7692 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
7693 CHECK(!owner->result_ok);
7694         return DecodeError_clone(&*owner->contents.err);
7695 }
7696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7697         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
7698         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
7699         uintptr_t ret_ref = 0;
7700         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7701         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7703         ret_ref = (uintptr_t)ret_var.inner;
7704         if (ret_var.is_owned) {
7705                 ret_ref |= 1;
7706         }
7707         return ret_ref;
7708 }
7709
7710 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
7711 CHECK(owner->result_ok);
7712         return ChannelReestablish_clone(&*owner->contents.result);
7713 }
7714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7715         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
7716         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
7717         uintptr_t ret_ref = 0;
7718         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7719         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7721         ret_ref = (uintptr_t)ret_var.inner;
7722         if (ret_var.is_owned) {
7723                 ret_ref |= 1;
7724         }
7725         return ret_ref;
7726 }
7727
7728 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
7729 CHECK(!owner->result_ok);
7730         return DecodeError_clone(&*owner->contents.err);
7731 }
7732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7733         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
7734         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
7735         uintptr_t ret_ref = 0;
7736         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7737         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7739         ret_ref = (uintptr_t)ret_var.inner;
7740         if (ret_var.is_owned) {
7741                 ret_ref |= 1;
7742         }
7743         return ret_ref;
7744 }
7745
7746 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
7747 CHECK(owner->result_ok);
7748         return ClosingSigned_clone(&*owner->contents.result);
7749 }
7750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7751         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
7752         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
7753         uintptr_t ret_ref = 0;
7754         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7755         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7757         ret_ref = (uintptr_t)ret_var.inner;
7758         if (ret_var.is_owned) {
7759                 ret_ref |= 1;
7760         }
7761         return ret_ref;
7762 }
7763
7764 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
7765 CHECK(!owner->result_ok);
7766         return DecodeError_clone(&*owner->contents.err);
7767 }
7768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7769         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
7770         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
7771         uintptr_t ret_ref = 0;
7772         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7773         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7775         ret_ref = (uintptr_t)ret_var.inner;
7776         if (ret_var.is_owned) {
7777                 ret_ref |= 1;
7778         }
7779         return ret_ref;
7780 }
7781
7782 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
7783 CHECK(owner->result_ok);
7784         return ClosingSignedFeeRange_clone(&*owner->contents.result);
7785 }
7786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7787         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
7788         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
7789         uintptr_t ret_ref = 0;
7790         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7791         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7793         ret_ref = (uintptr_t)ret_var.inner;
7794         if (ret_var.is_owned) {
7795                 ret_ref |= 1;
7796         }
7797         return ret_ref;
7798 }
7799
7800 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
7801 CHECK(!owner->result_ok);
7802         return DecodeError_clone(&*owner->contents.err);
7803 }
7804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7805         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
7806         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
7807         uintptr_t ret_ref = 0;
7808         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7809         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7811         ret_ref = (uintptr_t)ret_var.inner;
7812         if (ret_var.is_owned) {
7813                 ret_ref |= 1;
7814         }
7815         return ret_ref;
7816 }
7817
7818 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
7819 CHECK(owner->result_ok);
7820         return CommitmentSigned_clone(&*owner->contents.result);
7821 }
7822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7823         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
7824         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
7825         uintptr_t ret_ref = 0;
7826         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7827         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7829         ret_ref = (uintptr_t)ret_var.inner;
7830         if (ret_var.is_owned) {
7831                 ret_ref |= 1;
7832         }
7833         return ret_ref;
7834 }
7835
7836 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
7837 CHECK(!owner->result_ok);
7838         return DecodeError_clone(&*owner->contents.err);
7839 }
7840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7841         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
7842         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
7843         uintptr_t ret_ref = 0;
7844         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7845         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7847         ret_ref = (uintptr_t)ret_var.inner;
7848         if (ret_var.is_owned) {
7849                 ret_ref |= 1;
7850         }
7851         return ret_ref;
7852 }
7853
7854 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
7855 CHECK(owner->result_ok);
7856         return FundingCreated_clone(&*owner->contents.result);
7857 }
7858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7859         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
7860         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
7861         uintptr_t ret_ref = 0;
7862         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7863         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7865         ret_ref = (uintptr_t)ret_var.inner;
7866         if (ret_var.is_owned) {
7867                 ret_ref |= 1;
7868         }
7869         return ret_ref;
7870 }
7871
7872 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
7873 CHECK(!owner->result_ok);
7874         return DecodeError_clone(&*owner->contents.err);
7875 }
7876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7877         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
7878         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
7879         uintptr_t ret_ref = 0;
7880         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7881         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7883         ret_ref = (uintptr_t)ret_var.inner;
7884         if (ret_var.is_owned) {
7885                 ret_ref |= 1;
7886         }
7887         return ret_ref;
7888 }
7889
7890 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7891 CHECK(owner->result_ok);
7892         return FundingSigned_clone(&*owner->contents.result);
7893 }
7894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7895         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7896         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
7897         uintptr_t ret_ref = 0;
7898         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7899         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7901         ret_ref = (uintptr_t)ret_var.inner;
7902         if (ret_var.is_owned) {
7903                 ret_ref |= 1;
7904         }
7905         return ret_ref;
7906 }
7907
7908 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7909 CHECK(!owner->result_ok);
7910         return DecodeError_clone(&*owner->contents.err);
7911 }
7912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7913         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7914         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
7915         uintptr_t ret_ref = 0;
7916         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7917         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7919         ret_ref = (uintptr_t)ret_var.inner;
7920         if (ret_var.is_owned) {
7921                 ret_ref |= 1;
7922         }
7923         return ret_ref;
7924 }
7925
7926 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
7927 CHECK(owner->result_ok);
7928         return FundingLocked_clone(&*owner->contents.result);
7929 }
7930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7931         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
7932         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
7933         uintptr_t ret_ref = 0;
7934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7937         ret_ref = (uintptr_t)ret_var.inner;
7938         if (ret_var.is_owned) {
7939                 ret_ref |= 1;
7940         }
7941         return ret_ref;
7942 }
7943
7944 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
7945 CHECK(!owner->result_ok);
7946         return DecodeError_clone(&*owner->contents.err);
7947 }
7948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7949         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
7950         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
7951         uintptr_t ret_ref = 0;
7952         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7953         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7955         ret_ref = (uintptr_t)ret_var.inner;
7956         if (ret_var.is_owned) {
7957                 ret_ref |= 1;
7958         }
7959         return ret_ref;
7960 }
7961
7962 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7963 CHECK(owner->result_ok);
7964         return Init_clone(&*owner->contents.result);
7965 }
7966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7967         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7968         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
7969         uintptr_t ret_ref = 0;
7970         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7971         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7973         ret_ref = (uintptr_t)ret_var.inner;
7974         if (ret_var.is_owned) {
7975                 ret_ref |= 1;
7976         }
7977         return ret_ref;
7978 }
7979
7980 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7981 CHECK(!owner->result_ok);
7982         return DecodeError_clone(&*owner->contents.err);
7983 }
7984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7985         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7986         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
7987         uintptr_t ret_ref = 0;
7988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7991         ret_ref = (uintptr_t)ret_var.inner;
7992         if (ret_var.is_owned) {
7993                 ret_ref |= 1;
7994         }
7995         return ret_ref;
7996 }
7997
7998 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7999 CHECK(owner->result_ok);
8000         return OpenChannel_clone(&*owner->contents.result);
8001 }
8002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8003         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8004         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
8005         uintptr_t ret_ref = 0;
8006         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8007         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8009         ret_ref = (uintptr_t)ret_var.inner;
8010         if (ret_var.is_owned) {
8011                 ret_ref |= 1;
8012         }
8013         return ret_ref;
8014 }
8015
8016 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8017 CHECK(!owner->result_ok);
8018         return DecodeError_clone(&*owner->contents.err);
8019 }
8020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8021         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8022         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
8023         uintptr_t ret_ref = 0;
8024         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8025         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8027         ret_ref = (uintptr_t)ret_var.inner;
8028         if (ret_var.is_owned) {
8029                 ret_ref |= 1;
8030         }
8031         return ret_ref;
8032 }
8033
8034 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8035 CHECK(owner->result_ok);
8036         return RevokeAndACK_clone(&*owner->contents.result);
8037 }
8038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8039         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8040         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
8041         uintptr_t ret_ref = 0;
8042         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8043         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8045         ret_ref = (uintptr_t)ret_var.inner;
8046         if (ret_var.is_owned) {
8047                 ret_ref |= 1;
8048         }
8049         return ret_ref;
8050 }
8051
8052 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8053 CHECK(!owner->result_ok);
8054         return DecodeError_clone(&*owner->contents.err);
8055 }
8056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8057         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8058         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
8059         uintptr_t ret_ref = 0;
8060         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8061         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8063         ret_ref = (uintptr_t)ret_var.inner;
8064         if (ret_var.is_owned) {
8065                 ret_ref |= 1;
8066         }
8067         return ret_ref;
8068 }
8069
8070 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8071 CHECK(owner->result_ok);
8072         return Shutdown_clone(&*owner->contents.result);
8073 }
8074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8075         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
8076         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
8077         uintptr_t ret_ref = 0;
8078         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8079         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8081         ret_ref = (uintptr_t)ret_var.inner;
8082         if (ret_var.is_owned) {
8083                 ret_ref |= 1;
8084         }
8085         return ret_ref;
8086 }
8087
8088 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8089 CHECK(!owner->result_ok);
8090         return DecodeError_clone(&*owner->contents.err);
8091 }
8092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8093         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
8094         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
8095         uintptr_t ret_ref = 0;
8096         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8097         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8099         ret_ref = (uintptr_t)ret_var.inner;
8100         if (ret_var.is_owned) {
8101                 ret_ref |= 1;
8102         }
8103         return ret_ref;
8104 }
8105
8106 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8107 CHECK(owner->result_ok);
8108         return UpdateFailHTLC_clone(&*owner->contents.result);
8109 }
8110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8111         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
8112         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
8113         uintptr_t ret_ref = 0;
8114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8117         ret_ref = (uintptr_t)ret_var.inner;
8118         if (ret_var.is_owned) {
8119                 ret_ref |= 1;
8120         }
8121         return ret_ref;
8122 }
8123
8124 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8125 CHECK(!owner->result_ok);
8126         return DecodeError_clone(&*owner->contents.err);
8127 }
8128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8129         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
8130         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
8131         uintptr_t ret_ref = 0;
8132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8135         ret_ref = (uintptr_t)ret_var.inner;
8136         if (ret_var.is_owned) {
8137                 ret_ref |= 1;
8138         }
8139         return ret_ref;
8140 }
8141
8142 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8143 CHECK(owner->result_ok);
8144         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
8145 }
8146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8147         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
8148         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
8149         uintptr_t ret_ref = 0;
8150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8153         ret_ref = (uintptr_t)ret_var.inner;
8154         if (ret_var.is_owned) {
8155                 ret_ref |= 1;
8156         }
8157         return ret_ref;
8158 }
8159
8160 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8161 CHECK(!owner->result_ok);
8162         return DecodeError_clone(&*owner->contents.err);
8163 }
8164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8165         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
8166         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
8167         uintptr_t ret_ref = 0;
8168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8171         ret_ref = (uintptr_t)ret_var.inner;
8172         if (ret_var.is_owned) {
8173                 ret_ref |= 1;
8174         }
8175         return ret_ref;
8176 }
8177
8178 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8179 CHECK(owner->result_ok);
8180         return UpdateFee_clone(&*owner->contents.result);
8181 }
8182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8183         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
8184         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
8185         uintptr_t ret_ref = 0;
8186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8189         ret_ref = (uintptr_t)ret_var.inner;
8190         if (ret_var.is_owned) {
8191                 ret_ref |= 1;
8192         }
8193         return ret_ref;
8194 }
8195
8196 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8197 CHECK(!owner->result_ok);
8198         return DecodeError_clone(&*owner->contents.err);
8199 }
8200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8201         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
8202         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
8203         uintptr_t ret_ref = 0;
8204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8207         ret_ref = (uintptr_t)ret_var.inner;
8208         if (ret_var.is_owned) {
8209                 ret_ref |= 1;
8210         }
8211         return ret_ref;
8212 }
8213
8214 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
8215 CHECK(owner->result_ok);
8216         return UpdateFulfillHTLC_clone(&*owner->contents.result);
8217 }
8218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8219         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
8220         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
8221         uintptr_t ret_ref = 0;
8222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8225         ret_ref = (uintptr_t)ret_var.inner;
8226         if (ret_var.is_owned) {
8227                 ret_ref |= 1;
8228         }
8229         return ret_ref;
8230 }
8231
8232 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
8233 CHECK(!owner->result_ok);
8234         return DecodeError_clone(&*owner->contents.err);
8235 }
8236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8237         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
8238         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
8239         uintptr_t ret_ref = 0;
8240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8243         ret_ref = (uintptr_t)ret_var.inner;
8244         if (ret_var.is_owned) {
8245                 ret_ref |= 1;
8246         }
8247         return ret_ref;
8248 }
8249
8250 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
8251 CHECK(owner->result_ok);
8252         return UpdateAddHTLC_clone(&*owner->contents.result);
8253 }
8254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8255         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
8256         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
8257         uintptr_t ret_ref = 0;
8258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8261         ret_ref = (uintptr_t)ret_var.inner;
8262         if (ret_var.is_owned) {
8263                 ret_ref |= 1;
8264         }
8265         return ret_ref;
8266 }
8267
8268 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
8269 CHECK(!owner->result_ok);
8270         return DecodeError_clone(&*owner->contents.err);
8271 }
8272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8273         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
8274         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
8275         uintptr_t ret_ref = 0;
8276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8279         ret_ref = (uintptr_t)ret_var.inner;
8280         if (ret_var.is_owned) {
8281                 ret_ref |= 1;
8282         }
8283         return ret_ref;
8284 }
8285
8286 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
8287 CHECK(owner->result_ok);
8288         return Ping_clone(&*owner->contents.result);
8289 }
8290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8291         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
8292         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
8293         uintptr_t ret_ref = 0;
8294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8297         ret_ref = (uintptr_t)ret_var.inner;
8298         if (ret_var.is_owned) {
8299                 ret_ref |= 1;
8300         }
8301         return ret_ref;
8302 }
8303
8304 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
8305 CHECK(!owner->result_ok);
8306         return DecodeError_clone(&*owner->contents.err);
8307 }
8308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8309         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
8310         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
8311         uintptr_t ret_ref = 0;
8312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8315         ret_ref = (uintptr_t)ret_var.inner;
8316         if (ret_var.is_owned) {
8317                 ret_ref |= 1;
8318         }
8319         return ret_ref;
8320 }
8321
8322 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
8323 CHECK(owner->result_ok);
8324         return Pong_clone(&*owner->contents.result);
8325 }
8326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8327         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
8328         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
8329         uintptr_t ret_ref = 0;
8330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8333         ret_ref = (uintptr_t)ret_var.inner;
8334         if (ret_var.is_owned) {
8335                 ret_ref |= 1;
8336         }
8337         return ret_ref;
8338 }
8339
8340 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
8341 CHECK(!owner->result_ok);
8342         return DecodeError_clone(&*owner->contents.err);
8343 }
8344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8345         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
8346         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
8347         uintptr_t ret_ref = 0;
8348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8351         ret_ref = (uintptr_t)ret_var.inner;
8352         if (ret_var.is_owned) {
8353                 ret_ref |= 1;
8354         }
8355         return ret_ref;
8356 }
8357
8358 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8359 CHECK(owner->result_ok);
8360         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
8361 }
8362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8363         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
8364         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
8365         uintptr_t ret_ref = 0;
8366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8369         ret_ref = (uintptr_t)ret_var.inner;
8370         if (ret_var.is_owned) {
8371                 ret_ref |= 1;
8372         }
8373         return ret_ref;
8374 }
8375
8376 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8377 CHECK(!owner->result_ok);
8378         return DecodeError_clone(&*owner->contents.err);
8379 }
8380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8381         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
8382         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
8383         uintptr_t ret_ref = 0;
8384         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8385         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8387         ret_ref = (uintptr_t)ret_var.inner;
8388         if (ret_var.is_owned) {
8389                 ret_ref |= 1;
8390         }
8391         return ret_ref;
8392 }
8393
8394 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8395 CHECK(owner->result_ok);
8396         return ChannelAnnouncement_clone(&*owner->contents.result);
8397 }
8398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8399         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
8400         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
8401         uintptr_t ret_ref = 0;
8402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8405         ret_ref = (uintptr_t)ret_var.inner;
8406         if (ret_var.is_owned) {
8407                 ret_ref |= 1;
8408         }
8409         return ret_ref;
8410 }
8411
8412 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8413 CHECK(!owner->result_ok);
8414         return DecodeError_clone(&*owner->contents.err);
8415 }
8416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8417         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
8418         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
8419         uintptr_t ret_ref = 0;
8420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8423         ret_ref = (uintptr_t)ret_var.inner;
8424         if (ret_var.is_owned) {
8425                 ret_ref |= 1;
8426         }
8427         return ret_ref;
8428 }
8429
8430 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8431 CHECK(owner->result_ok);
8432         return UnsignedChannelUpdate_clone(&*owner->contents.result);
8433 }
8434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8435         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
8436         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
8437         uintptr_t ret_ref = 0;
8438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8441         ret_ref = (uintptr_t)ret_var.inner;
8442         if (ret_var.is_owned) {
8443                 ret_ref |= 1;
8444         }
8445         return ret_ref;
8446 }
8447
8448 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8449 CHECK(!owner->result_ok);
8450         return DecodeError_clone(&*owner->contents.err);
8451 }
8452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8453         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
8454         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
8455         uintptr_t ret_ref = 0;
8456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8459         ret_ref = (uintptr_t)ret_var.inner;
8460         if (ret_var.is_owned) {
8461                 ret_ref |= 1;
8462         }
8463         return ret_ref;
8464 }
8465
8466 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8467 CHECK(owner->result_ok);
8468         return ChannelUpdate_clone(&*owner->contents.result);
8469 }
8470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8471         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
8472         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
8473         uintptr_t ret_ref = 0;
8474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8477         ret_ref = (uintptr_t)ret_var.inner;
8478         if (ret_var.is_owned) {
8479                 ret_ref |= 1;
8480         }
8481         return ret_ref;
8482 }
8483
8484 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8485 CHECK(!owner->result_ok);
8486         return DecodeError_clone(&*owner->contents.err);
8487 }
8488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8489         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
8490         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
8491         uintptr_t ret_ref = 0;
8492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8495         ret_ref = (uintptr_t)ret_var.inner;
8496         if (ret_var.is_owned) {
8497                 ret_ref |= 1;
8498         }
8499         return ret_ref;
8500 }
8501
8502 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
8503 CHECK(owner->result_ok);
8504         return ErrorMessage_clone(&*owner->contents.result);
8505 }
8506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8507         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
8508         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
8509         uintptr_t ret_ref = 0;
8510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8513         ret_ref = (uintptr_t)ret_var.inner;
8514         if (ret_var.is_owned) {
8515                 ret_ref |= 1;
8516         }
8517         return ret_ref;
8518 }
8519
8520 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
8521 CHECK(!owner->result_ok);
8522         return DecodeError_clone(&*owner->contents.err);
8523 }
8524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8525         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
8526         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
8527         uintptr_t ret_ref = 0;
8528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8531         ret_ref = (uintptr_t)ret_var.inner;
8532         if (ret_var.is_owned) {
8533                 ret_ref |= 1;
8534         }
8535         return ret_ref;
8536 }
8537
8538 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8539 CHECK(owner->result_ok);
8540         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
8541 }
8542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8543         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
8544         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
8545         uintptr_t ret_ref = 0;
8546         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8547         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8549         ret_ref = (uintptr_t)ret_var.inner;
8550         if (ret_var.is_owned) {
8551                 ret_ref |= 1;
8552         }
8553         return ret_ref;
8554 }
8555
8556 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8557 CHECK(!owner->result_ok);
8558         return DecodeError_clone(&*owner->contents.err);
8559 }
8560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8561         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
8562         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
8563         uintptr_t ret_ref = 0;
8564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8567         ret_ref = (uintptr_t)ret_var.inner;
8568         if (ret_var.is_owned) {
8569                 ret_ref |= 1;
8570         }
8571         return ret_ref;
8572 }
8573
8574 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8575 CHECK(owner->result_ok);
8576         return NodeAnnouncement_clone(&*owner->contents.result);
8577 }
8578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8579         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
8580         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
8581         uintptr_t ret_ref = 0;
8582         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8583         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8585         ret_ref = (uintptr_t)ret_var.inner;
8586         if (ret_var.is_owned) {
8587                 ret_ref |= 1;
8588         }
8589         return ret_ref;
8590 }
8591
8592 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8593 CHECK(!owner->result_ok);
8594         return DecodeError_clone(&*owner->contents.err);
8595 }
8596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8597         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
8598         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
8599         uintptr_t ret_ref = 0;
8600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8603         ret_ref = (uintptr_t)ret_var.inner;
8604         if (ret_var.is_owned) {
8605                 ret_ref |= 1;
8606         }
8607         return ret_ref;
8608 }
8609
8610 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
8611 CHECK(owner->result_ok);
8612         return QueryShortChannelIds_clone(&*owner->contents.result);
8613 }
8614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8615         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
8616         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
8617         uintptr_t ret_ref = 0;
8618         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8619         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8621         ret_ref = (uintptr_t)ret_var.inner;
8622         if (ret_var.is_owned) {
8623                 ret_ref |= 1;
8624         }
8625         return ret_ref;
8626 }
8627
8628 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
8629 CHECK(!owner->result_ok);
8630         return DecodeError_clone(&*owner->contents.err);
8631 }
8632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8633         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
8634         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
8635         uintptr_t ret_ref = 0;
8636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8639         ret_ref = (uintptr_t)ret_var.inner;
8640         if (ret_var.is_owned) {
8641                 ret_ref |= 1;
8642         }
8643         return ret_ref;
8644 }
8645
8646 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
8647 CHECK(owner->result_ok);
8648         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
8649 }
8650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8651         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
8652         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
8653         uintptr_t ret_ref = 0;
8654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8657         ret_ref = (uintptr_t)ret_var.inner;
8658         if (ret_var.is_owned) {
8659                 ret_ref |= 1;
8660         }
8661         return ret_ref;
8662 }
8663
8664 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
8665 CHECK(!owner->result_ok);
8666         return DecodeError_clone(&*owner->contents.err);
8667 }
8668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8669         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
8670         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
8671         uintptr_t ret_ref = 0;
8672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8675         ret_ref = (uintptr_t)ret_var.inner;
8676         if (ret_var.is_owned) {
8677                 ret_ref |= 1;
8678         }
8679         return ret_ref;
8680 }
8681
8682 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8683 CHECK(owner->result_ok);
8684         return QueryChannelRange_clone(&*owner->contents.result);
8685 }
8686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8687         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
8688         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
8689         uintptr_t ret_ref = 0;
8690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8693         ret_ref = (uintptr_t)ret_var.inner;
8694         if (ret_var.is_owned) {
8695                 ret_ref |= 1;
8696         }
8697         return ret_ref;
8698 }
8699
8700 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8701 CHECK(!owner->result_ok);
8702         return DecodeError_clone(&*owner->contents.err);
8703 }
8704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8705         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
8706         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
8707         uintptr_t ret_ref = 0;
8708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8711         ret_ref = (uintptr_t)ret_var.inner;
8712         if (ret_var.is_owned) {
8713                 ret_ref |= 1;
8714         }
8715         return ret_ref;
8716 }
8717
8718 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8719 CHECK(owner->result_ok);
8720         return ReplyChannelRange_clone(&*owner->contents.result);
8721 }
8722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8723         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
8724         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
8725         uintptr_t ret_ref = 0;
8726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8729         ret_ref = (uintptr_t)ret_var.inner;
8730         if (ret_var.is_owned) {
8731                 ret_ref |= 1;
8732         }
8733         return ret_ref;
8734 }
8735
8736 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8737 CHECK(!owner->result_ok);
8738         return DecodeError_clone(&*owner->contents.err);
8739 }
8740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8741         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
8742         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
8743         uintptr_t ret_ref = 0;
8744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8747         ret_ref = (uintptr_t)ret_var.inner;
8748         if (ret_var.is_owned) {
8749                 ret_ref |= 1;
8750         }
8751         return ret_ref;
8752 }
8753
8754 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
8755 CHECK(owner->result_ok);
8756         return GossipTimestampFilter_clone(&*owner->contents.result);
8757 }
8758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8759         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
8760         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
8761         uintptr_t ret_ref = 0;
8762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8765         ret_ref = (uintptr_t)ret_var.inner;
8766         if (ret_var.is_owned) {
8767                 ret_ref |= 1;
8768         }
8769         return ret_ref;
8770 }
8771
8772 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
8773 CHECK(!owner->result_ok);
8774         return DecodeError_clone(&*owner->contents.err);
8775 }
8776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8777         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
8778         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
8779         uintptr_t ret_ref = 0;
8780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8783         ret_ref = (uintptr_t)ret_var.inner;
8784         if (ret_var.is_owned) {
8785                 ret_ref |= 1;
8786         }
8787         return ret_ref;
8788 }
8789
8790 static jclass LDKSignOrCreationError_SignError_class = NULL;
8791 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
8792 static jclass LDKSignOrCreationError_CreationError_class = NULL;
8793 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
8794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
8795         LDKSignOrCreationError_SignError_class =
8796                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
8797         CHECK(LDKSignOrCreationError_SignError_class != NULL);
8798         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
8799         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
8800         LDKSignOrCreationError_CreationError_class =
8801                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
8802         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
8803         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
8804         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
8805 }
8806 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8807         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
8808         switch(obj->tag) {
8809                 case LDKSignOrCreationError_SignError: {
8810                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
8811                 }
8812                 case LDKSignOrCreationError_CreationError: {
8813                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
8814                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
8815                 }
8816                 default: abort();
8817         }
8818 }
8819 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
8820 CHECK(owner->result_ok);
8821         return Invoice_clone(&*owner->contents.result);
8822 }
8823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8824         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
8825         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
8826         uintptr_t ret_ref = 0;
8827         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8828         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8830         ret_ref = (uintptr_t)ret_var.inner;
8831         if (ret_var.is_owned) {
8832                 ret_ref |= 1;
8833         }
8834         return ret_ref;
8835 }
8836
8837 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
8838 CHECK(!owner->result_ok);
8839         return SignOrCreationError_clone(&*owner->contents.err);
8840 }
8841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8842         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
8843         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
8844         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
8845         uintptr_t ret_ref = (uintptr_t)ret_copy;
8846         return ret_ref;
8847 }
8848
8849 typedef struct LDKFilter_JCalls {
8850         atomic_size_t refcnt;
8851         JavaVM *vm;
8852         jweak o;
8853         jmethodID register_tx_meth;
8854         jmethodID register_output_meth;
8855 } LDKFilter_JCalls;
8856 static void LDKFilter_JCalls_free(void* this_arg) {
8857         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8858         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8859                 JNIEnv *env;
8860                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8861                 if (get_jenv_res == JNI_EDETACHED) {
8862                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8863                 } else {
8864                         DO_ASSERT(get_jenv_res == JNI_OK);
8865                 }
8866                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8867                 if (get_jenv_res == JNI_EDETACHED) {
8868                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8869                 }
8870                 FREE(j_calls);
8871         }
8872 }
8873 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
8874         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8875         JNIEnv *env;
8876         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8877         if (get_jenv_res == JNI_EDETACHED) {
8878                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8879         } else {
8880                 DO_ASSERT(get_jenv_res == JNI_OK);
8881         }
8882         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
8883         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
8884         LDKu8slice script_pubkey_var = script_pubkey;
8885         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
8886         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
8887         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8888         CHECK(obj != NULL);
8889         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
8890         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8891                 (*env)->ExceptionDescribe(env);
8892                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
8893         }
8894         if (get_jenv_res == JNI_EDETACHED) {
8895                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8896         }
8897 }
8898 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
8899         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8900         JNIEnv *env;
8901         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8902         if (get_jenv_res == JNI_EDETACHED) {
8903                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8904         } else {
8905                 DO_ASSERT(get_jenv_res == JNI_OK);
8906         }
8907         LDKWatchedOutput output_var = output;
8908         uintptr_t output_ref = 0;
8909         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8910         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8911         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
8912         output_ref = (uintptr_t)output_var.inner;
8913         if (output_var.is_owned) {
8914                 output_ref |= 1;
8915         }
8916         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8917         CHECK(obj != NULL);
8918         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
8919         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8920                 (*env)->ExceptionDescribe(env);
8921                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
8922         }
8923         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8924         CHECK_ACCESS(ret_ptr);
8925         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
8926         FREE((void*)ret);
8927         if (get_jenv_res == JNI_EDETACHED) {
8928                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8929         }
8930         return ret_conv;
8931 }
8932 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
8933         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
8934         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8935 }
8936 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
8937         jclass c = (*env)->GetObjectClass(env, o);
8938         CHECK(c != NULL);
8939         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
8940         atomic_init(&calls->refcnt, 1);
8941         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8942         calls->o = (*env)->NewWeakGlobalRef(env, o);
8943         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
8944         CHECK(calls->register_tx_meth != NULL);
8945         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
8946         CHECK(calls->register_output_meth != NULL);
8947
8948         LDKFilter ret = {
8949                 .this_arg = (void*) calls,
8950                 .register_tx = register_tx_LDKFilter_jcall,
8951                 .register_output = register_output_LDKFilter_jcall,
8952                 .free = LDKFilter_JCalls_free,
8953         };
8954         return ret;
8955 }
8956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
8957         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
8958         *res_ptr = LDKFilter_init(env, clz, o);
8959         return (uint64_t)res_ptr;
8960 }
8961 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) {
8962         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8963         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8964         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8965         unsigned char txid_arr[32];
8966         CHECK((*env)->GetArrayLength(env, txid) == 32);
8967         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
8968         unsigned char (*txid_ref)[32] = &txid_arr;
8969         LDKu8slice script_pubkey_ref;
8970         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
8971         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
8972         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
8973         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
8974 }
8975
8976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
8977         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8978         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8979         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8980         LDKWatchedOutput output_conv;
8981         output_conv.inner = (void*)(output & (~1));
8982         output_conv.is_owned = (output & 1) || (output == 0);
8983         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
8984         output_conv = WatchedOutput_clone(&output_conv);
8985         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8986         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
8987         uintptr_t ret_ref = (uintptr_t)ret_copy;
8988         return ret_ref;
8989 }
8990
8991 static jclass LDKCOption_FilterZ_Some_class = NULL;
8992 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
8993 static jclass LDKCOption_FilterZ_None_class = NULL;
8994 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
8995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
8996         LDKCOption_FilterZ_Some_class =
8997                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
8998         CHECK(LDKCOption_FilterZ_Some_class != NULL);
8999         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
9000         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
9001         LDKCOption_FilterZ_None_class =
9002                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
9003         CHECK(LDKCOption_FilterZ_None_class != NULL);
9004         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
9005         CHECK(LDKCOption_FilterZ_None_meth != NULL);
9006 }
9007 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9008         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
9009         switch(obj->tag) {
9010                 case LDKCOption_FilterZ_Some: {
9011                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
9012                         *some_ret = obj->some;
9013                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
9014                         if ((*some_ret).free == LDKFilter_JCalls_free) {
9015                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9016                                 LDKFilter_JCalls_cloned(&(*some_ret));
9017                         }
9018                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (uintptr_t)some_ret);
9019                 }
9020                 case LDKCOption_FilterZ_None: {
9021                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
9022                 }
9023                 default: abort();
9024         }
9025 }
9026 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9027 CHECK(owner->result_ok);
9028         return &*owner->contents.result;
9029 }
9030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9031         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
9032         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
9033         uintptr_t ret_ref = 0;
9034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9037         ret_ref = (uintptr_t)ret_var.inner & ~1;
9038         return ret_ref;
9039 }
9040
9041 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9042 CHECK(!owner->result_ok);
9043         return *owner->contents.err;
9044 }
9045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9046         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
9047         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
9048 }
9049
9050 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
9051         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
9052         for (size_t i = 0; i < ret.datalen; i++) {
9053                 ret.data[i] = OutPoint_clone(&orig->data[i]);
9054         }
9055         return ret;
9056 }
9057 typedef struct LDKMessageSendEventsProvider_JCalls {
9058         atomic_size_t refcnt;
9059         JavaVM *vm;
9060         jweak o;
9061         jmethodID get_and_clear_pending_msg_events_meth;
9062 } LDKMessageSendEventsProvider_JCalls;
9063 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
9064         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9065         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9066                 JNIEnv *env;
9067                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9068                 if (get_jenv_res == JNI_EDETACHED) {
9069                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9070                 } else {
9071                         DO_ASSERT(get_jenv_res == JNI_OK);
9072                 }
9073                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9074                 if (get_jenv_res == JNI_EDETACHED) {
9075                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9076                 }
9077                 FREE(j_calls);
9078         }
9079 }
9080 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
9081         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9082         JNIEnv *env;
9083         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9084         if (get_jenv_res == JNI_EDETACHED) {
9085                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9086         } else {
9087                 DO_ASSERT(get_jenv_res == JNI_OK);
9088         }
9089         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9090         CHECK(obj != NULL);
9091         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
9092         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9093                 (*env)->ExceptionDescribe(env);
9094                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
9095         }
9096         LDKCVec_MessageSendEventZ ret_constr;
9097         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9098         if (ret_constr.datalen > 0)
9099                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9100         else
9101                 ret_constr.data = NULL;
9102         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9103         for (size_t s = 0; s < ret_constr.datalen; s++) {
9104                 int64_t ret_conv_18 = ret_vals[s];
9105                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
9106                 CHECK_ACCESS(ret_conv_18_ptr);
9107                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
9108                 FREE((void*)ret_conv_18);
9109                 ret_constr.data[s] = ret_conv_18_conv;
9110         }
9111         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9112         if (get_jenv_res == JNI_EDETACHED) {
9113                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9114         }
9115         return ret_constr;
9116 }
9117 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
9118         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
9119         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9120 }
9121 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
9122         jclass c = (*env)->GetObjectClass(env, o);
9123         CHECK(c != NULL);
9124         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
9125         atomic_init(&calls->refcnt, 1);
9126         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9127         calls->o = (*env)->NewWeakGlobalRef(env, o);
9128         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
9129         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
9130
9131         LDKMessageSendEventsProvider ret = {
9132                 .this_arg = (void*) calls,
9133                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
9134                 .free = LDKMessageSendEventsProvider_JCalls_free,
9135         };
9136         return ret;
9137 }
9138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
9139         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
9140         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
9141         return (uint64_t)res_ptr;
9142 }
9143 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
9144         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9145         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9146         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
9147         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
9148         int64_tArray ret_arr = NULL;
9149         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9150         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9151         for (size_t s = 0; s < ret_var.datalen; s++) {
9152                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
9153                 *ret_conv_18_copy = ret_var.data[s];
9154                 uintptr_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
9155                 ret_arr_ptr[s] = ret_conv_18_ref;
9156         }
9157         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9158         FREE(ret_var.data);
9159         return ret_arr;
9160 }
9161
9162 typedef struct LDKEventHandler_JCalls {
9163         atomic_size_t refcnt;
9164         JavaVM *vm;
9165         jweak o;
9166         jmethodID handle_event_meth;
9167 } LDKEventHandler_JCalls;
9168 static void LDKEventHandler_JCalls_free(void* this_arg) {
9169         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
9170         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9171                 JNIEnv *env;
9172                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9173                 if (get_jenv_res == JNI_EDETACHED) {
9174                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9175                 } else {
9176                         DO_ASSERT(get_jenv_res == JNI_OK);
9177                 }
9178                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9179                 if (get_jenv_res == JNI_EDETACHED) {
9180                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9181                 }
9182                 FREE(j_calls);
9183         }
9184 }
9185 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
9186         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
9187         JNIEnv *env;
9188         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9189         if (get_jenv_res == JNI_EDETACHED) {
9190                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9191         } else {
9192                 DO_ASSERT(get_jenv_res == JNI_OK);
9193         }
9194         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
9195         *ret_event = Event_clone(event);
9196         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9197         CHECK(obj != NULL);
9198         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (uintptr_t)ret_event);
9199         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9200                 (*env)->ExceptionDescribe(env);
9201                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
9202         }
9203         if (get_jenv_res == JNI_EDETACHED) {
9204                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9205         }
9206 }
9207 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
9208         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
9209         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9210 }
9211 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
9212         jclass c = (*env)->GetObjectClass(env, o);
9213         CHECK(c != NULL);
9214         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
9215         atomic_init(&calls->refcnt, 1);
9216         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9217         calls->o = (*env)->NewWeakGlobalRef(env, o);
9218         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
9219         CHECK(calls->handle_event_meth != NULL);
9220
9221         LDKEventHandler ret = {
9222                 .this_arg = (void*) calls,
9223                 .handle_event = handle_event_LDKEventHandler_jcall,
9224                 .free = LDKEventHandler_JCalls_free,
9225         };
9226         return ret;
9227 }
9228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
9229         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
9230         *res_ptr = LDKEventHandler_init(env, clz, o);
9231         return (uint64_t)res_ptr;
9232 }
9233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
9234         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9235         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9236         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
9237         LDKEvent* event_conv = (LDKEvent*)event;
9238         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
9239 }
9240
9241 typedef struct LDKEventsProvider_JCalls {
9242         atomic_size_t refcnt;
9243         JavaVM *vm;
9244         jweak o;
9245         jmethodID process_pending_events_meth;
9246 } LDKEventsProvider_JCalls;
9247 static void LDKEventsProvider_JCalls_free(void* this_arg) {
9248         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
9249         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9250                 JNIEnv *env;
9251                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9252                 if (get_jenv_res == JNI_EDETACHED) {
9253                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9254                 } else {
9255                         DO_ASSERT(get_jenv_res == JNI_OK);
9256                 }
9257                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9258                 if (get_jenv_res == JNI_EDETACHED) {
9259                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9260                 }
9261                 FREE(j_calls);
9262         }
9263 }
9264 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
9265         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
9266         JNIEnv *env;
9267         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9268         if (get_jenv_res == JNI_EDETACHED) {
9269                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9270         } else {
9271                 DO_ASSERT(get_jenv_res == JNI_OK);
9272         }
9273         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
9274         *handler_ret = handler;
9275         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9276         CHECK(obj != NULL);
9277         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uintptr_t)handler_ret);
9278         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9279                 (*env)->ExceptionDescribe(env);
9280                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
9281         }
9282         if (get_jenv_res == JNI_EDETACHED) {
9283                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9284         }
9285 }
9286 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
9287         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
9288         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9289 }
9290 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
9291         jclass c = (*env)->GetObjectClass(env, o);
9292         CHECK(c != NULL);
9293         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
9294         atomic_init(&calls->refcnt, 1);
9295         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9296         calls->o = (*env)->NewWeakGlobalRef(env, o);
9297         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
9298         CHECK(calls->process_pending_events_meth != NULL);
9299
9300         LDKEventsProvider ret = {
9301                 .this_arg = (void*) calls,
9302                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
9303                 .free = LDKEventsProvider_JCalls_free,
9304         };
9305         return ret;
9306 }
9307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
9308         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
9309         *res_ptr = LDKEventsProvider_init(env, clz, o);
9310         return (uint64_t)res_ptr;
9311 }
9312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
9313         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9314         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9315         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
9316         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
9317         CHECK_ACCESS(handler_ptr);
9318         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
9319         if (handler_conv.free == LDKEventHandler_JCalls_free) {
9320                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9321                 LDKEventHandler_JCalls_cloned(&handler_conv);
9322         }
9323         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
9324 }
9325
9326 typedef struct LDKListen_JCalls {
9327         atomic_size_t refcnt;
9328         JavaVM *vm;
9329         jweak o;
9330         jmethodID block_connected_meth;
9331         jmethodID block_disconnected_meth;
9332 } LDKListen_JCalls;
9333 static void LDKListen_JCalls_free(void* this_arg) {
9334         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9335         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9336                 JNIEnv *env;
9337                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9338                 if (get_jenv_res == JNI_EDETACHED) {
9339                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9340                 } else {
9341                         DO_ASSERT(get_jenv_res == JNI_OK);
9342                 }
9343                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9344                 if (get_jenv_res == JNI_EDETACHED) {
9345                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9346                 }
9347                 FREE(j_calls);
9348         }
9349 }
9350 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
9351         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9352         JNIEnv *env;
9353         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9354         if (get_jenv_res == JNI_EDETACHED) {
9355                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9356         } else {
9357                 DO_ASSERT(get_jenv_res == JNI_OK);
9358         }
9359         LDKu8slice block_var = block;
9360         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
9361         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
9362         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9363         CHECK(obj != NULL);
9364         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
9365         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9366                 (*env)->ExceptionDescribe(env);
9367                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
9368         }
9369         if (get_jenv_res == JNI_EDETACHED) {
9370                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9371         }
9372 }
9373 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
9374         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9375         JNIEnv *env;
9376         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9377         if (get_jenv_res == JNI_EDETACHED) {
9378                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9379         } else {
9380                 DO_ASSERT(get_jenv_res == JNI_OK);
9381         }
9382         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
9383         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
9384         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9385         CHECK(obj != NULL);
9386         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
9387         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9388                 (*env)->ExceptionDescribe(env);
9389                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
9390         }
9391         if (get_jenv_res == JNI_EDETACHED) {
9392                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9393         }
9394 }
9395 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
9396         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
9397         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9398 }
9399 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
9400         jclass c = (*env)->GetObjectClass(env, o);
9401         CHECK(c != NULL);
9402         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
9403         atomic_init(&calls->refcnt, 1);
9404         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9405         calls->o = (*env)->NewWeakGlobalRef(env, o);
9406         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
9407         CHECK(calls->block_connected_meth != NULL);
9408         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
9409         CHECK(calls->block_disconnected_meth != NULL);
9410
9411         LDKListen ret = {
9412                 .this_arg = (void*) calls,
9413                 .block_connected = block_connected_LDKListen_jcall,
9414                 .block_disconnected = block_disconnected_LDKListen_jcall,
9415                 .free = LDKListen_JCalls_free,
9416         };
9417         return ret;
9418 }
9419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
9420         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
9421         *res_ptr = LDKListen_init(env, clz, o);
9422         return (uint64_t)res_ptr;
9423 }
9424 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) {
9425         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9426         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9427         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9428         LDKu8slice block_ref;
9429         block_ref.datalen = (*env)->GetArrayLength(env, block);
9430         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
9431         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
9432         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
9433 }
9434
9435 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) {
9436         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9437         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9438         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9439         unsigned char header_arr[80];
9440         CHECK((*env)->GetArrayLength(env, header) == 80);
9441         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
9442         unsigned char (*header_ref)[80] = &header_arr;
9443         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
9444 }
9445
9446 typedef struct LDKConfirm_JCalls {
9447         atomic_size_t refcnt;
9448         JavaVM *vm;
9449         jweak o;
9450         jmethodID transactions_confirmed_meth;
9451         jmethodID transaction_unconfirmed_meth;
9452         jmethodID best_block_updated_meth;
9453         jmethodID get_relevant_txids_meth;
9454 } LDKConfirm_JCalls;
9455 static void LDKConfirm_JCalls_free(void* this_arg) {
9456         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9457         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9458                 JNIEnv *env;
9459                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9460                 if (get_jenv_res == JNI_EDETACHED) {
9461                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9462                 } else {
9463                         DO_ASSERT(get_jenv_res == JNI_OK);
9464                 }
9465                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9466                 if (get_jenv_res == JNI_EDETACHED) {
9467                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9468                 }
9469                 FREE(j_calls);
9470         }
9471 }
9472 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
9473         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9474         JNIEnv *env;
9475         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9476         if (get_jenv_res == JNI_EDETACHED) {
9477                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9478         } else {
9479                 DO_ASSERT(get_jenv_res == JNI_OK);
9480         }
9481         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
9482         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
9483         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
9484         int64_tArray txdata_arr = NULL;
9485         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
9486         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
9487         for (size_t c = 0; c < txdata_var.datalen; c++) {
9488                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9489                 *txdata_conv_28_conv = txdata_var.data[c];
9490                 txdata_arr_ptr[c] = ((uintptr_t)txdata_conv_28_conv);
9491         }
9492         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
9493         FREE(txdata_var.data);
9494         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9495         CHECK(obj != NULL);
9496         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
9497         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9498                 (*env)->ExceptionDescribe(env);
9499                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
9500         }
9501         if (get_jenv_res == JNI_EDETACHED) {
9502                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9503         }
9504 }
9505 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
9506         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9507         JNIEnv *env;
9508         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9509         if (get_jenv_res == JNI_EDETACHED) {
9510                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9511         } else {
9512                 DO_ASSERT(get_jenv_res == JNI_OK);
9513         }
9514         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
9515         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
9516         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9517         CHECK(obj != NULL);
9518         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
9519         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9520                 (*env)->ExceptionDescribe(env);
9521                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
9522         }
9523         if (get_jenv_res == JNI_EDETACHED) {
9524                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9525         }
9526 }
9527 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
9528         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9529         JNIEnv *env;
9530         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9531         if (get_jenv_res == JNI_EDETACHED) {
9532                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9533         } else {
9534                 DO_ASSERT(get_jenv_res == JNI_OK);
9535         }
9536         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
9537         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
9538         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9539         CHECK(obj != NULL);
9540         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
9541         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9542                 (*env)->ExceptionDescribe(env);
9543                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
9544         }
9545         if (get_jenv_res == JNI_EDETACHED) {
9546                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9547         }
9548 }
9549 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
9550         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9551         JNIEnv *env;
9552         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9553         if (get_jenv_res == JNI_EDETACHED) {
9554                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9555         } else {
9556                 DO_ASSERT(get_jenv_res == JNI_OK);
9557         }
9558         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9559         CHECK(obj != NULL);
9560         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
9561         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9562                 (*env)->ExceptionDescribe(env);
9563                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
9564         }
9565         LDKCVec_TxidZ ret_constr;
9566         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9567         if (ret_constr.datalen > 0)
9568                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9569         else
9570                 ret_constr.data = NULL;
9571         for (size_t i = 0; i < ret_constr.datalen; i++) {
9572                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
9573                 LDKThirtyTwoBytes ret_conv_8_ref;
9574                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
9575                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
9576                 ret_constr.data[i] = ret_conv_8_ref;
9577         }
9578         if (get_jenv_res == JNI_EDETACHED) {
9579                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9580         }
9581         return ret_constr;
9582 }
9583 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
9584         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
9585         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9586 }
9587 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
9588         jclass c = (*env)->GetObjectClass(env, o);
9589         CHECK(c != NULL);
9590         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
9591         atomic_init(&calls->refcnt, 1);
9592         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9593         calls->o = (*env)->NewWeakGlobalRef(env, o);
9594         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
9595         CHECK(calls->transactions_confirmed_meth != NULL);
9596         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
9597         CHECK(calls->transaction_unconfirmed_meth != NULL);
9598         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
9599         CHECK(calls->best_block_updated_meth != NULL);
9600         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
9601         CHECK(calls->get_relevant_txids_meth != NULL);
9602
9603         LDKConfirm ret = {
9604                 .this_arg = (void*) calls,
9605                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
9606                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
9607                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
9608                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
9609                 .free = LDKConfirm_JCalls_free,
9610         };
9611         return ret;
9612 }
9613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
9614         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
9615         *res_ptr = LDKConfirm_init(env, clz, o);
9616         return (uint64_t)res_ptr;
9617 }
9618 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) {
9619         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9620         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9621         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9622         unsigned char header_arr[80];
9623         CHECK((*env)->GetArrayLength(env, header) == 80);
9624         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
9625         unsigned char (*header_ref)[80] = &header_arr;
9626         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9627         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
9628         if (txdata_constr.datalen > 0)
9629                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9630         else
9631                 txdata_constr.data = NULL;
9632         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
9633         for (size_t c = 0; c < txdata_constr.datalen; c++) {
9634                 int64_t txdata_conv_28 = txdata_vals[c];
9635                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
9636                 CHECK_ACCESS(txdata_conv_28_ptr);
9637                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
9638                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
9639                 txdata_constr.data[c] = txdata_conv_28_conv;
9640         }
9641         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
9642         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
9643 }
9644
9645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
9646         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9647         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9648         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9649         unsigned char txid_arr[32];
9650         CHECK((*env)->GetArrayLength(env, txid) == 32);
9651         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
9652         unsigned char (*txid_ref)[32] = &txid_arr;
9653         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
9654 }
9655
9656 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) {
9657         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9658         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9659         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9660         unsigned char header_arr[80];
9661         CHECK((*env)->GetArrayLength(env, header) == 80);
9662         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
9663         unsigned char (*header_ref)[80] = &header_arr;
9664         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
9665 }
9666
9667 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
9668         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9669         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9670         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9671         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
9672         jobjectArray ret_arr = NULL;
9673         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
9674         ;
9675         for (size_t i = 0; i < ret_var.datalen; i++) {
9676                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
9677                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
9678                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
9679         }
9680         
9681         FREE(ret_var.data);
9682         return ret_arr;
9683 }
9684
9685 typedef struct LDKPersist_JCalls {
9686         atomic_size_t refcnt;
9687         JavaVM *vm;
9688         jweak o;
9689         jmethodID persist_new_channel_meth;
9690         jmethodID update_persisted_channel_meth;
9691 } LDKPersist_JCalls;
9692 static void LDKPersist_JCalls_free(void* this_arg) {
9693         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9694         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9695                 JNIEnv *env;
9696                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9697                 if (get_jenv_res == JNI_EDETACHED) {
9698                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9699                 } else {
9700                         DO_ASSERT(get_jenv_res == JNI_OK);
9701                 }
9702                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9703                 if (get_jenv_res == JNI_EDETACHED) {
9704                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9705                 }
9706                 FREE(j_calls);
9707         }
9708 }
9709 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
9710         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9711         JNIEnv *env;
9712         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9713         if (get_jenv_res == JNI_EDETACHED) {
9714                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9715         } else {
9716                 DO_ASSERT(get_jenv_res == JNI_OK);
9717         }
9718         LDKOutPoint channel_id_var = channel_id;
9719         uintptr_t channel_id_ref = 0;
9720         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9721         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9722         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
9723         channel_id_ref = (uintptr_t)channel_id_var.inner;
9724         if (channel_id_var.is_owned) {
9725                 channel_id_ref |= 1;
9726         }
9727         LDKChannelMonitor data_var = *data;
9728         uintptr_t data_ref = 0;
9729         data_var = ChannelMonitor_clone(data);
9730         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9731         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9732         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
9733         data_ref = (uintptr_t)data_var.inner;
9734         if (data_var.is_owned) {
9735                 data_ref |= 1;
9736         }
9737         LDKMonitorUpdateId update_id_var = update_id;
9738         uintptr_t update_id_ref = 0;
9739         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9740         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9741         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
9742         update_id_ref = (uintptr_t)update_id_var.inner;
9743         if (update_id_var.is_owned) {
9744                 update_id_ref |= 1;
9745         }
9746         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9747         CHECK(obj != NULL);
9748         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
9749         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9750                 (*env)->ExceptionDescribe(env);
9751                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
9752         }
9753         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9754         CHECK_ACCESS(ret_ptr);
9755         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
9756         FREE((void*)ret);
9757         if (get_jenv_res == JNI_EDETACHED) {
9758                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9759         }
9760         return ret_conv;
9761 }
9762 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
9763         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9764         JNIEnv *env;
9765         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9766         if (get_jenv_res == JNI_EDETACHED) {
9767                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9768         } else {
9769                 DO_ASSERT(get_jenv_res == JNI_OK);
9770         }
9771         LDKOutPoint channel_id_var = channel_id;
9772         uintptr_t channel_id_ref = 0;
9773         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9774         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9775         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
9776         channel_id_ref = (uintptr_t)channel_id_var.inner;
9777         if (channel_id_var.is_owned) {
9778                 channel_id_ref |= 1;
9779         }
9780         LDKChannelMonitorUpdate update_var = *update;
9781         uintptr_t update_ref = 0;
9782         if ((uintptr_t)update_var.inner > 4096) {
9783                 update_var = ChannelMonitorUpdate_clone(update);
9784                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9785                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9786         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
9787                 update_ref = (uintptr_t)update_var.inner;
9788                 if (update_var.is_owned) {
9789                         update_ref |= 1;
9790                 }
9791         }
9792         LDKChannelMonitor data_var = *data;
9793         uintptr_t data_ref = 0;
9794         data_var = ChannelMonitor_clone(data);
9795         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9796         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9797         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
9798         data_ref = (uintptr_t)data_var.inner;
9799         if (data_var.is_owned) {
9800                 data_ref |= 1;
9801         }
9802         LDKMonitorUpdateId update_id_var = update_id;
9803         uintptr_t update_id_ref = 0;
9804         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9805         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9806         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
9807         update_id_ref = (uintptr_t)update_id_var.inner;
9808         if (update_id_var.is_owned) {
9809                 update_id_ref |= 1;
9810         }
9811         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9812         CHECK(obj != NULL);
9813         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
9814         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9815                 (*env)->ExceptionDescribe(env);
9816                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
9817         }
9818         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9819         CHECK_ACCESS(ret_ptr);
9820         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
9821         FREE((void*)ret);
9822         if (get_jenv_res == JNI_EDETACHED) {
9823                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9824         }
9825         return ret_conv;
9826 }
9827 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
9828         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
9829         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9830 }
9831 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
9832         jclass c = (*env)->GetObjectClass(env, o);
9833         CHECK(c != NULL);
9834         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
9835         atomic_init(&calls->refcnt, 1);
9836         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9837         calls->o = (*env)->NewWeakGlobalRef(env, o);
9838         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
9839         CHECK(calls->persist_new_channel_meth != NULL);
9840         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
9841         CHECK(calls->update_persisted_channel_meth != NULL);
9842
9843         LDKPersist ret = {
9844                 .this_arg = (void*) calls,
9845                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
9846                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
9847                 .free = LDKPersist_JCalls_free,
9848         };
9849         return ret;
9850 }
9851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
9852         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
9853         *res_ptr = LDKPersist_init(env, clz, o);
9854         return (uint64_t)res_ptr;
9855 }
9856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1persist_1new_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_id, int64_t data, int64_t update_id) {
9857         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9858         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9859         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9860         LDKOutPoint channel_id_conv;
9861         channel_id_conv.inner = (void*)(channel_id & (~1));
9862         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9863         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9864         channel_id_conv = OutPoint_clone(&channel_id_conv);
9865         LDKChannelMonitor data_conv;
9866         data_conv.inner = (void*)(data & (~1));
9867         data_conv.is_owned = false;
9868         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9869         LDKMonitorUpdateId update_id_conv;
9870         update_id_conv.inner = (void*)(update_id & (~1));
9871         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9872         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9873         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9874         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9875         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
9876         return (uintptr_t)ret_conv;
9877 }
9878
9879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persist_1update_1persisted_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_id, int64_t update, int64_t data, int64_t update_id) {
9880         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9881         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9882         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9883         LDKOutPoint channel_id_conv;
9884         channel_id_conv.inner = (void*)(channel_id & (~1));
9885         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9886         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9887         channel_id_conv = OutPoint_clone(&channel_id_conv);
9888         LDKChannelMonitorUpdate update_conv;
9889         update_conv.inner = (void*)(update & (~1));
9890         update_conv.is_owned = false;
9891         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
9892         LDKChannelMonitor data_conv;
9893         data_conv.inner = (void*)(data & (~1));
9894         data_conv.is_owned = false;
9895         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9896         LDKMonitorUpdateId update_id_conv;
9897         update_id_conv.inner = (void*)(update_id & (~1));
9898         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9899         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9900         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9901         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9902         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
9903         return (uintptr_t)ret_conv;
9904 }
9905
9906 typedef struct LDKChannelMessageHandler_JCalls {
9907         atomic_size_t refcnt;
9908         JavaVM *vm;
9909         jweak o;
9910         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9911         jmethodID handle_open_channel_meth;
9912         jmethodID handle_accept_channel_meth;
9913         jmethodID handle_funding_created_meth;
9914         jmethodID handle_funding_signed_meth;
9915         jmethodID handle_funding_locked_meth;
9916         jmethodID handle_shutdown_meth;
9917         jmethodID handle_closing_signed_meth;
9918         jmethodID handle_update_add_htlc_meth;
9919         jmethodID handle_update_fulfill_htlc_meth;
9920         jmethodID handle_update_fail_htlc_meth;
9921         jmethodID handle_update_fail_malformed_htlc_meth;
9922         jmethodID handle_commitment_signed_meth;
9923         jmethodID handle_revoke_and_ack_meth;
9924         jmethodID handle_update_fee_meth;
9925         jmethodID handle_announcement_signatures_meth;
9926         jmethodID peer_disconnected_meth;
9927         jmethodID peer_connected_meth;
9928         jmethodID handle_channel_reestablish_meth;
9929         jmethodID handle_channel_update_meth;
9930         jmethodID handle_error_meth;
9931 } LDKChannelMessageHandler_JCalls;
9932 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
9933         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9934         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9935                 JNIEnv *env;
9936                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9937                 if (get_jenv_res == JNI_EDETACHED) {
9938                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9939                 } else {
9940                         DO_ASSERT(get_jenv_res == JNI_OK);
9941                 }
9942                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9943                 if (get_jenv_res == JNI_EDETACHED) {
9944                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9945                 }
9946                 FREE(j_calls);
9947         }
9948 }
9949 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
9950         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9951         JNIEnv *env;
9952         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9953         if (get_jenv_res == JNI_EDETACHED) {
9954                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9955         } else {
9956                 DO_ASSERT(get_jenv_res == JNI_OK);
9957         }
9958         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9959         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9960         LDKInitFeatures their_features_var = their_features;
9961         uintptr_t their_features_ref = 0;
9962         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9963         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9964         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9965         their_features_ref = (uintptr_t)their_features_var.inner;
9966         if (their_features_var.is_owned) {
9967                 their_features_ref |= 1;
9968         }
9969         LDKOpenChannel msg_var = *msg;
9970         uintptr_t msg_ref = 0;
9971         msg_var = OpenChannel_clone(msg);
9972         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9973         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9974         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9975         msg_ref = (uintptr_t)msg_var.inner;
9976         if (msg_var.is_owned) {
9977                 msg_ref |= 1;
9978         }
9979         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9980         CHECK(obj != NULL);
9981         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
9982         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9983                 (*env)->ExceptionDescribe(env);
9984                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
9985         }
9986         if (get_jenv_res == JNI_EDETACHED) {
9987                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9988         }
9989 }
9990 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
9991         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9992         JNIEnv *env;
9993         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9994         if (get_jenv_res == JNI_EDETACHED) {
9995                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9996         } else {
9997                 DO_ASSERT(get_jenv_res == JNI_OK);
9998         }
9999         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10000         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10001         LDKInitFeatures their_features_var = their_features;
10002         uintptr_t their_features_ref = 0;
10003         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10004         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10005         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10006         their_features_ref = (uintptr_t)their_features_var.inner;
10007         if (their_features_var.is_owned) {
10008                 their_features_ref |= 1;
10009         }
10010         LDKAcceptChannel msg_var = *msg;
10011         uintptr_t msg_ref = 0;
10012         msg_var = AcceptChannel_clone(msg);
10013         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10014         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10015         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10016         msg_ref = (uintptr_t)msg_var.inner;
10017         if (msg_var.is_owned) {
10018                 msg_ref |= 1;
10019         }
10020         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10021         CHECK(obj != NULL);
10022         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
10023         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10024                 (*env)->ExceptionDescribe(env);
10025                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
10026         }
10027         if (get_jenv_res == JNI_EDETACHED) {
10028                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10029         }
10030 }
10031 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
10032         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10033         JNIEnv *env;
10034         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10035         if (get_jenv_res == JNI_EDETACHED) {
10036                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10037         } else {
10038                 DO_ASSERT(get_jenv_res == JNI_OK);
10039         }
10040         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10041         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10042         LDKFundingCreated msg_var = *msg;
10043         uintptr_t msg_ref = 0;
10044         msg_var = FundingCreated_clone(msg);
10045         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10046         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10047         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10048         msg_ref = (uintptr_t)msg_var.inner;
10049         if (msg_var.is_owned) {
10050                 msg_ref |= 1;
10051         }
10052         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10053         CHECK(obj != NULL);
10054         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
10055         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10056                 (*env)->ExceptionDescribe(env);
10057                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
10058         }
10059         if (get_jenv_res == JNI_EDETACHED) {
10060                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10061         }
10062 }
10063 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
10064         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10065         JNIEnv *env;
10066         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10067         if (get_jenv_res == JNI_EDETACHED) {
10068                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10069         } else {
10070                 DO_ASSERT(get_jenv_res == JNI_OK);
10071         }
10072         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10073         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10074         LDKFundingSigned msg_var = *msg;
10075         uintptr_t msg_ref = 0;
10076         msg_var = FundingSigned_clone(msg);
10077         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10078         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10079         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10080         msg_ref = (uintptr_t)msg_var.inner;
10081         if (msg_var.is_owned) {
10082                 msg_ref |= 1;
10083         }
10084         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10085         CHECK(obj != NULL);
10086         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
10087         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10088                 (*env)->ExceptionDescribe(env);
10089                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
10090         }
10091         if (get_jenv_res == JNI_EDETACHED) {
10092                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10093         }
10094 }
10095 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
10096         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10097         JNIEnv *env;
10098         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10099         if (get_jenv_res == JNI_EDETACHED) {
10100                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10101         } else {
10102                 DO_ASSERT(get_jenv_res == JNI_OK);
10103         }
10104         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10105         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10106         LDKFundingLocked msg_var = *msg;
10107         uintptr_t msg_ref = 0;
10108         msg_var = FundingLocked_clone(msg);
10109         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10110         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10111         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10112         msg_ref = (uintptr_t)msg_var.inner;
10113         if (msg_var.is_owned) {
10114                 msg_ref |= 1;
10115         }
10116         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10117         CHECK(obj != NULL);
10118         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
10119         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10120                 (*env)->ExceptionDescribe(env);
10121                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
10122         }
10123         if (get_jenv_res == JNI_EDETACHED) {
10124                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10125         }
10126 }
10127 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
10128         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10129         JNIEnv *env;
10130         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10131         if (get_jenv_res == JNI_EDETACHED) {
10132                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10133         } else {
10134                 DO_ASSERT(get_jenv_res == JNI_OK);
10135         }
10136         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10137         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10138         LDKInitFeatures their_features_var = *their_features;
10139         uintptr_t their_features_ref = 0;
10140         their_features_var = InitFeatures_clone(their_features);
10141         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10142         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10143         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10144         their_features_ref = (uintptr_t)their_features_var.inner;
10145         if (their_features_var.is_owned) {
10146                 their_features_ref |= 1;
10147         }
10148         LDKShutdown msg_var = *msg;
10149         uintptr_t msg_ref = 0;
10150         msg_var = Shutdown_clone(msg);
10151         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10152         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10153         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10154         msg_ref = (uintptr_t)msg_var.inner;
10155         if (msg_var.is_owned) {
10156                 msg_ref |= 1;
10157         }
10158         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10159         CHECK(obj != NULL);
10160         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
10161         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10162                 (*env)->ExceptionDescribe(env);
10163                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
10164         }
10165         if (get_jenv_res == JNI_EDETACHED) {
10166                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10167         }
10168 }
10169 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
10170         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10171         JNIEnv *env;
10172         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10173         if (get_jenv_res == JNI_EDETACHED) {
10174                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10175         } else {
10176                 DO_ASSERT(get_jenv_res == JNI_OK);
10177         }
10178         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10179         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10180         LDKClosingSigned msg_var = *msg;
10181         uintptr_t msg_ref = 0;
10182         msg_var = ClosingSigned_clone(msg);
10183         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10184         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10185         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10186         msg_ref = (uintptr_t)msg_var.inner;
10187         if (msg_var.is_owned) {
10188                 msg_ref |= 1;
10189         }
10190         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10191         CHECK(obj != NULL);
10192         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
10193         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10194                 (*env)->ExceptionDescribe(env);
10195                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
10196         }
10197         if (get_jenv_res == JNI_EDETACHED) {
10198                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10199         }
10200 }
10201 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
10202         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10203         JNIEnv *env;
10204         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10205         if (get_jenv_res == JNI_EDETACHED) {
10206                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10207         } else {
10208                 DO_ASSERT(get_jenv_res == JNI_OK);
10209         }
10210         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10211         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10212         LDKUpdateAddHTLC msg_var = *msg;
10213         uintptr_t msg_ref = 0;
10214         msg_var = UpdateAddHTLC_clone(msg);
10215         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10216         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10217         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10218         msg_ref = (uintptr_t)msg_var.inner;
10219         if (msg_var.is_owned) {
10220                 msg_ref |= 1;
10221         }
10222         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10223         CHECK(obj != NULL);
10224         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
10225         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10226                 (*env)->ExceptionDescribe(env);
10227                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
10228         }
10229         if (get_jenv_res == JNI_EDETACHED) {
10230                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10231         }
10232 }
10233 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
10234         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10235         JNIEnv *env;
10236         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10237         if (get_jenv_res == JNI_EDETACHED) {
10238                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10239         } else {
10240                 DO_ASSERT(get_jenv_res == JNI_OK);
10241         }
10242         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10243         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10244         LDKUpdateFulfillHTLC msg_var = *msg;
10245         uintptr_t msg_ref = 0;
10246         msg_var = UpdateFulfillHTLC_clone(msg);
10247         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10248         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10249         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10250         msg_ref = (uintptr_t)msg_var.inner;
10251         if (msg_var.is_owned) {
10252                 msg_ref |= 1;
10253         }
10254         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10255         CHECK(obj != NULL);
10256         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
10257         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10258                 (*env)->ExceptionDescribe(env);
10259                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
10260         }
10261         if (get_jenv_res == JNI_EDETACHED) {
10262                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10263         }
10264 }
10265 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
10266         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10267         JNIEnv *env;
10268         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10269         if (get_jenv_res == JNI_EDETACHED) {
10270                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10271         } else {
10272                 DO_ASSERT(get_jenv_res == JNI_OK);
10273         }
10274         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10275         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10276         LDKUpdateFailHTLC msg_var = *msg;
10277         uintptr_t msg_ref = 0;
10278         msg_var = UpdateFailHTLC_clone(msg);
10279         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10280         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10281         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10282         msg_ref = (uintptr_t)msg_var.inner;
10283         if (msg_var.is_owned) {
10284                 msg_ref |= 1;
10285         }
10286         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10287         CHECK(obj != NULL);
10288         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
10289         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10290                 (*env)->ExceptionDescribe(env);
10291                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
10292         }
10293         if (get_jenv_res == JNI_EDETACHED) {
10294                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10295         }
10296 }
10297 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
10298         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10299         JNIEnv *env;
10300         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10301         if (get_jenv_res == JNI_EDETACHED) {
10302                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10303         } else {
10304                 DO_ASSERT(get_jenv_res == JNI_OK);
10305         }
10306         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10307         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10308         LDKUpdateFailMalformedHTLC msg_var = *msg;
10309         uintptr_t msg_ref = 0;
10310         msg_var = UpdateFailMalformedHTLC_clone(msg);
10311         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10312         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10313         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10314         msg_ref = (uintptr_t)msg_var.inner;
10315         if (msg_var.is_owned) {
10316                 msg_ref |= 1;
10317         }
10318         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10319         CHECK(obj != NULL);
10320         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
10321         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10322                 (*env)->ExceptionDescribe(env);
10323                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
10324         }
10325         if (get_jenv_res == JNI_EDETACHED) {
10326                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10327         }
10328 }
10329 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
10330         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10331         JNIEnv *env;
10332         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10333         if (get_jenv_res == JNI_EDETACHED) {
10334                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10335         } else {
10336                 DO_ASSERT(get_jenv_res == JNI_OK);
10337         }
10338         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10339         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10340         LDKCommitmentSigned msg_var = *msg;
10341         uintptr_t msg_ref = 0;
10342         msg_var = CommitmentSigned_clone(msg);
10343         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10344         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10345         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10346         msg_ref = (uintptr_t)msg_var.inner;
10347         if (msg_var.is_owned) {
10348                 msg_ref |= 1;
10349         }
10350         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10351         CHECK(obj != NULL);
10352         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
10353         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10354                 (*env)->ExceptionDescribe(env);
10355                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
10356         }
10357         if (get_jenv_res == JNI_EDETACHED) {
10358                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10359         }
10360 }
10361 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
10362         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10363         JNIEnv *env;
10364         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10365         if (get_jenv_res == JNI_EDETACHED) {
10366                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10367         } else {
10368                 DO_ASSERT(get_jenv_res == JNI_OK);
10369         }
10370         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10371         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10372         LDKRevokeAndACK msg_var = *msg;
10373         uintptr_t msg_ref = 0;
10374         msg_var = RevokeAndACK_clone(msg);
10375         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10376         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10377         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10378         msg_ref = (uintptr_t)msg_var.inner;
10379         if (msg_var.is_owned) {
10380                 msg_ref |= 1;
10381         }
10382         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10383         CHECK(obj != NULL);
10384         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
10385         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10386                 (*env)->ExceptionDescribe(env);
10387                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
10388         }
10389         if (get_jenv_res == JNI_EDETACHED) {
10390                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10391         }
10392 }
10393 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
10394         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10395         JNIEnv *env;
10396         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10397         if (get_jenv_res == JNI_EDETACHED) {
10398                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10399         } else {
10400                 DO_ASSERT(get_jenv_res == JNI_OK);
10401         }
10402         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10403         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10404         LDKUpdateFee msg_var = *msg;
10405         uintptr_t msg_ref = 0;
10406         msg_var = UpdateFee_clone(msg);
10407         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10408         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10409         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10410         msg_ref = (uintptr_t)msg_var.inner;
10411         if (msg_var.is_owned) {
10412                 msg_ref |= 1;
10413         }
10414         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10415         CHECK(obj != NULL);
10416         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
10417         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10418                 (*env)->ExceptionDescribe(env);
10419                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
10420         }
10421         if (get_jenv_res == JNI_EDETACHED) {
10422                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10423         }
10424 }
10425 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
10426         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10427         JNIEnv *env;
10428         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10429         if (get_jenv_res == JNI_EDETACHED) {
10430                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10431         } else {
10432                 DO_ASSERT(get_jenv_res == JNI_OK);
10433         }
10434         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10435         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10436         LDKAnnouncementSignatures msg_var = *msg;
10437         uintptr_t msg_ref = 0;
10438         msg_var = AnnouncementSignatures_clone(msg);
10439         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10440         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10441         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10442         msg_ref = (uintptr_t)msg_var.inner;
10443         if (msg_var.is_owned) {
10444                 msg_ref |= 1;
10445         }
10446         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10447         CHECK(obj != NULL);
10448         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
10449         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10450                 (*env)->ExceptionDescribe(env);
10451                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
10452         }
10453         if (get_jenv_res == JNI_EDETACHED) {
10454                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10455         }
10456 }
10457 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
10458         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10459         JNIEnv *env;
10460         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10461         if (get_jenv_res == JNI_EDETACHED) {
10462                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10463         } else {
10464                 DO_ASSERT(get_jenv_res == JNI_OK);
10465         }
10466         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10467         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10468         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10469         CHECK(obj != NULL);
10470         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
10471         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10472                 (*env)->ExceptionDescribe(env);
10473                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
10474         }
10475         if (get_jenv_res == JNI_EDETACHED) {
10476                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10477         }
10478 }
10479 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
10480         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10481         JNIEnv *env;
10482         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10483         if (get_jenv_res == JNI_EDETACHED) {
10484                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10485         } else {
10486                 DO_ASSERT(get_jenv_res == JNI_OK);
10487         }
10488         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10489         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10490         LDKInit msg_var = *msg;
10491         uintptr_t msg_ref = 0;
10492         msg_var = Init_clone(msg);
10493         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10494         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10495         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10496         msg_ref = (uintptr_t)msg_var.inner;
10497         if (msg_var.is_owned) {
10498                 msg_ref |= 1;
10499         }
10500         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10501         CHECK(obj != NULL);
10502         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
10503         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10504                 (*env)->ExceptionDescribe(env);
10505                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
10506         }
10507         if (get_jenv_res == JNI_EDETACHED) {
10508                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10509         }
10510 }
10511 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
10512         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10513         JNIEnv *env;
10514         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10515         if (get_jenv_res == JNI_EDETACHED) {
10516                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10517         } else {
10518                 DO_ASSERT(get_jenv_res == JNI_OK);
10519         }
10520         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10521         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10522         LDKChannelReestablish msg_var = *msg;
10523         uintptr_t msg_ref = 0;
10524         msg_var = ChannelReestablish_clone(msg);
10525         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10526         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10527         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10528         msg_ref = (uintptr_t)msg_var.inner;
10529         if (msg_var.is_owned) {
10530                 msg_ref |= 1;
10531         }
10532         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10533         CHECK(obj != NULL);
10534         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
10535         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10536                 (*env)->ExceptionDescribe(env);
10537                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
10538         }
10539         if (get_jenv_res == JNI_EDETACHED) {
10540                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10541         }
10542 }
10543 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
10544         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10545         JNIEnv *env;
10546         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10547         if (get_jenv_res == JNI_EDETACHED) {
10548                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10549         } else {
10550                 DO_ASSERT(get_jenv_res == JNI_OK);
10551         }
10552         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10553         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10554         LDKChannelUpdate msg_var = *msg;
10555         uintptr_t msg_ref = 0;
10556         msg_var = ChannelUpdate_clone(msg);
10557         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10558         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10559         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10560         msg_ref = (uintptr_t)msg_var.inner;
10561         if (msg_var.is_owned) {
10562                 msg_ref |= 1;
10563         }
10564         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10565         CHECK(obj != NULL);
10566         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
10567         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10568                 (*env)->ExceptionDescribe(env);
10569                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
10570         }
10571         if (get_jenv_res == JNI_EDETACHED) {
10572                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10573         }
10574 }
10575 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
10576         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10577         JNIEnv *env;
10578         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10579         if (get_jenv_res == JNI_EDETACHED) {
10580                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10581         } else {
10582                 DO_ASSERT(get_jenv_res == JNI_OK);
10583         }
10584         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10585         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10586         LDKErrorMessage msg_var = *msg;
10587         uintptr_t msg_ref = 0;
10588         msg_var = ErrorMessage_clone(msg);
10589         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10590         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10591         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10592         msg_ref = (uintptr_t)msg_var.inner;
10593         if (msg_var.is_owned) {
10594                 msg_ref |= 1;
10595         }
10596         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10597         CHECK(obj != NULL);
10598         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
10599         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10600                 (*env)->ExceptionDescribe(env);
10601                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
10602         }
10603         if (get_jenv_res == JNI_EDETACHED) {
10604                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10605         }
10606 }
10607 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
10608         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
10609         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10610         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
10611 }
10612 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
10613         jclass c = (*env)->GetObjectClass(env, o);
10614         CHECK(c != NULL);
10615         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
10616         atomic_init(&calls->refcnt, 1);
10617         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10618         calls->o = (*env)->NewWeakGlobalRef(env, o);
10619         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
10620         CHECK(calls->handle_open_channel_meth != NULL);
10621         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
10622         CHECK(calls->handle_accept_channel_meth != NULL);
10623         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
10624         CHECK(calls->handle_funding_created_meth != NULL);
10625         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
10626         CHECK(calls->handle_funding_signed_meth != NULL);
10627         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
10628         CHECK(calls->handle_funding_locked_meth != NULL);
10629         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
10630         CHECK(calls->handle_shutdown_meth != NULL);
10631         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
10632         CHECK(calls->handle_closing_signed_meth != NULL);
10633         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
10634         CHECK(calls->handle_update_add_htlc_meth != NULL);
10635         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
10636         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
10637         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
10638         CHECK(calls->handle_update_fail_htlc_meth != NULL);
10639         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
10640         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
10641         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
10642         CHECK(calls->handle_commitment_signed_meth != NULL);
10643         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
10644         CHECK(calls->handle_revoke_and_ack_meth != NULL);
10645         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
10646         CHECK(calls->handle_update_fee_meth != NULL);
10647         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
10648         CHECK(calls->handle_announcement_signatures_meth != NULL);
10649         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
10650         CHECK(calls->peer_disconnected_meth != NULL);
10651         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
10652         CHECK(calls->peer_connected_meth != NULL);
10653         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
10654         CHECK(calls->handle_channel_reestablish_meth != NULL);
10655         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
10656         CHECK(calls->handle_channel_update_meth != NULL);
10657         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
10658         CHECK(calls->handle_error_meth != NULL);
10659
10660         LDKChannelMessageHandler ret = {
10661                 .this_arg = (void*) calls,
10662                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
10663                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
10664                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
10665                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
10666                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
10667                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
10668                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
10669                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
10670                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
10671                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
10672                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
10673                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
10674                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
10675                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
10676                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
10677                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
10678                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
10679                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
10680                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
10681                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
10682                 .free = LDKChannelMessageHandler_JCalls_free,
10683                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
10684         };
10685         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
10686         return ret;
10687 }
10688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
10689         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
10690         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
10691         return (uint64_t)res_ptr;
10692 }
10693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
10694         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
10695         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
10696         DO_ASSERT((res_ptr & 1) == 0);
10697         return (int64_t)(res_ptr | 1);
10698 }
10699 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) {
10700         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10701         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10702         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10703         LDKPublicKey their_node_id_ref;
10704         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10705         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10706         LDKInitFeatures their_features_conv;
10707         their_features_conv.inner = (void*)(their_features & (~1));
10708         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
10709         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
10710         their_features_conv = InitFeatures_clone(&their_features_conv);
10711         LDKOpenChannel msg_conv;
10712         msg_conv.inner = (void*)(msg & (~1));
10713         msg_conv.is_owned = false;
10714         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10715         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
10716 }
10717
10718 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) {
10719         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10720         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10721         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10722         LDKPublicKey their_node_id_ref;
10723         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10724         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10725         LDKInitFeatures their_features_conv;
10726         their_features_conv.inner = (void*)(their_features & (~1));
10727         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
10728         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
10729         their_features_conv = InitFeatures_clone(&their_features_conv);
10730         LDKAcceptChannel msg_conv;
10731         msg_conv.inner = (void*)(msg & (~1));
10732         msg_conv.is_owned = false;
10733         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10734         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
10735 }
10736
10737 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) {
10738         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10739         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10740         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10741         LDKPublicKey their_node_id_ref;
10742         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10743         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10744         LDKFundingCreated msg_conv;
10745         msg_conv.inner = (void*)(msg & (~1));
10746         msg_conv.is_owned = false;
10747         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10748         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10749 }
10750
10751 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) {
10752         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10753         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10754         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10755         LDKPublicKey their_node_id_ref;
10756         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10757         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10758         LDKFundingSigned msg_conv;
10759         msg_conv.inner = (void*)(msg & (~1));
10760         msg_conv.is_owned = false;
10761         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10762         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10763 }
10764
10765 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) {
10766         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10767         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10768         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10769         LDKPublicKey their_node_id_ref;
10770         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10771         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10772         LDKFundingLocked msg_conv;
10773         msg_conv.inner = (void*)(msg & (~1));
10774         msg_conv.is_owned = false;
10775         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10776         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10777 }
10778
10779 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) {
10780         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10781         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10782         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10783         LDKPublicKey their_node_id_ref;
10784         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10785         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10786         LDKInitFeatures their_features_conv;
10787         their_features_conv.inner = (void*)(their_features & (~1));
10788         their_features_conv.is_owned = false;
10789         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
10790         LDKShutdown msg_conv;
10791         msg_conv.inner = (void*)(msg & (~1));
10792         msg_conv.is_owned = false;
10793         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10794         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
10795 }
10796
10797 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) {
10798         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10799         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10800         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10801         LDKPublicKey their_node_id_ref;
10802         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10803         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10804         LDKClosingSigned msg_conv;
10805         msg_conv.inner = (void*)(msg & (~1));
10806         msg_conv.is_owned = false;
10807         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10808         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10809 }
10810
10811 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) {
10812         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10813         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10814         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10815         LDKPublicKey their_node_id_ref;
10816         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10817         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10818         LDKUpdateAddHTLC msg_conv;
10819         msg_conv.inner = (void*)(msg & (~1));
10820         msg_conv.is_owned = false;
10821         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10822         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10823 }
10824
10825 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) {
10826         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10827         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10828         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10829         LDKPublicKey their_node_id_ref;
10830         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10831         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10832         LDKUpdateFulfillHTLC msg_conv;
10833         msg_conv.inner = (void*)(msg & (~1));
10834         msg_conv.is_owned = false;
10835         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10836         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10837 }
10838
10839 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) {
10840         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10841         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10842         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10843         LDKPublicKey their_node_id_ref;
10844         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10845         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10846         LDKUpdateFailHTLC msg_conv;
10847         msg_conv.inner = (void*)(msg & (~1));
10848         msg_conv.is_owned = false;
10849         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10850         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10851 }
10852
10853 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) {
10854         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10855         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10856         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10857         LDKPublicKey their_node_id_ref;
10858         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10859         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10860         LDKUpdateFailMalformedHTLC msg_conv;
10861         msg_conv.inner = (void*)(msg & (~1));
10862         msg_conv.is_owned = false;
10863         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10864         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10865 }
10866
10867 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) {
10868         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10869         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10870         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10871         LDKPublicKey their_node_id_ref;
10872         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10873         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10874         LDKCommitmentSigned msg_conv;
10875         msg_conv.inner = (void*)(msg & (~1));
10876         msg_conv.is_owned = false;
10877         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10878         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10879 }
10880
10881 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) {
10882         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10883         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10884         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10885         LDKPublicKey their_node_id_ref;
10886         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10887         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10888         LDKRevokeAndACK msg_conv;
10889         msg_conv.inner = (void*)(msg & (~1));
10890         msg_conv.is_owned = false;
10891         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10892         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10893 }
10894
10895 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) {
10896         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10897         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10898         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10899         LDKPublicKey their_node_id_ref;
10900         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10901         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10902         LDKUpdateFee msg_conv;
10903         msg_conv.inner = (void*)(msg & (~1));
10904         msg_conv.is_owned = false;
10905         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10906         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10907 }
10908
10909 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) {
10910         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10911         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10912         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10913         LDKPublicKey their_node_id_ref;
10914         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10915         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10916         LDKAnnouncementSignatures msg_conv;
10917         msg_conv.inner = (void*)(msg & (~1));
10918         msg_conv.is_owned = false;
10919         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10920         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10921 }
10922
10923 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) {
10924         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10925         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10926         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10927         LDKPublicKey their_node_id_ref;
10928         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10929         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10930         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
10931 }
10932
10933 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) {
10934         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10935         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10936         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10937         LDKPublicKey their_node_id_ref;
10938         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10939         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10940         LDKInit msg_conv;
10941         msg_conv.inner = (void*)(msg & (~1));
10942         msg_conv.is_owned = false;
10943         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10944         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10945 }
10946
10947 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) {
10948         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10949         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10950         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10951         LDKPublicKey their_node_id_ref;
10952         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10953         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10954         LDKChannelReestablish msg_conv;
10955         msg_conv.inner = (void*)(msg & (~1));
10956         msg_conv.is_owned = false;
10957         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10958         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10959 }
10960
10961 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) {
10962         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10963         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10964         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10965         LDKPublicKey their_node_id_ref;
10966         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10967         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10968         LDKChannelUpdate msg_conv;
10969         msg_conv.inner = (void*)(msg & (~1));
10970         msg_conv.is_owned = false;
10971         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10972         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10973 }
10974
10975 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) {
10976         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10977         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10978         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10979         LDKPublicKey their_node_id_ref;
10980         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
10981         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
10982         LDKErrorMessage msg_conv;
10983         msg_conv.inner = (void*)(msg & (~1));
10984         msg_conv.is_owned = false;
10985         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10986         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10987 }
10988
10989 typedef struct LDKRoutingMessageHandler_JCalls {
10990         atomic_size_t refcnt;
10991         JavaVM *vm;
10992         jweak o;
10993         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
10994         jmethodID handle_node_announcement_meth;
10995         jmethodID handle_channel_announcement_meth;
10996         jmethodID handle_channel_update_meth;
10997         jmethodID get_next_channel_announcements_meth;
10998         jmethodID get_next_node_announcements_meth;
10999         jmethodID sync_routing_table_meth;
11000         jmethodID handle_reply_channel_range_meth;
11001         jmethodID handle_reply_short_channel_ids_end_meth;
11002         jmethodID handle_query_channel_range_meth;
11003         jmethodID handle_query_short_channel_ids_meth;
11004 } LDKRoutingMessageHandler_JCalls;
11005 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
11006         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11007         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11008                 JNIEnv *env;
11009                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11010                 if (get_jenv_res == JNI_EDETACHED) {
11011                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11012                 } else {
11013                         DO_ASSERT(get_jenv_res == JNI_OK);
11014                 }
11015                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11016                 if (get_jenv_res == JNI_EDETACHED) {
11017                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11018                 }
11019                 FREE(j_calls);
11020         }
11021 }
11022 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
11023         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11024         JNIEnv *env;
11025         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11026         if (get_jenv_res == JNI_EDETACHED) {
11027                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11028         } else {
11029                 DO_ASSERT(get_jenv_res == JNI_OK);
11030         }
11031         LDKNodeAnnouncement msg_var = *msg;
11032         uintptr_t msg_ref = 0;
11033         msg_var = NodeAnnouncement_clone(msg);
11034         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11035         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11036         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11037         msg_ref = (uintptr_t)msg_var.inner;
11038         if (msg_var.is_owned) {
11039                 msg_ref |= 1;
11040         }
11041         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11042         CHECK(obj != NULL);
11043         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
11044         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11045                 (*env)->ExceptionDescribe(env);
11046                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11047         }
11048         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11049         CHECK_ACCESS(ret_ptr);
11050         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11051         FREE((void*)ret);
11052         if (get_jenv_res == JNI_EDETACHED) {
11053                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11054         }
11055         return ret_conv;
11056 }
11057 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
11058         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11059         JNIEnv *env;
11060         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11061         if (get_jenv_res == JNI_EDETACHED) {
11062                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11063         } else {
11064                 DO_ASSERT(get_jenv_res == JNI_OK);
11065         }
11066         LDKChannelAnnouncement msg_var = *msg;
11067         uintptr_t msg_ref = 0;
11068         msg_var = ChannelAnnouncement_clone(msg);
11069         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11070         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11071         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11072         msg_ref = (uintptr_t)msg_var.inner;
11073         if (msg_var.is_owned) {
11074                 msg_ref |= 1;
11075         }
11076         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11077         CHECK(obj != NULL);
11078         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
11079         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11080                 (*env)->ExceptionDescribe(env);
11081                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11082         }
11083         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11084         CHECK_ACCESS(ret_ptr);
11085         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11086         FREE((void*)ret);
11087         if (get_jenv_res == JNI_EDETACHED) {
11088                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11089         }
11090         return ret_conv;
11091 }
11092 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
11093         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11094         JNIEnv *env;
11095         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11096         if (get_jenv_res == JNI_EDETACHED) {
11097                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11098         } else {
11099                 DO_ASSERT(get_jenv_res == JNI_OK);
11100         }
11101         LDKChannelUpdate msg_var = *msg;
11102         uintptr_t msg_ref = 0;
11103         msg_var = ChannelUpdate_clone(msg);
11104         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11105         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11106         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11107         msg_ref = (uintptr_t)msg_var.inner;
11108         if (msg_var.is_owned) {
11109                 msg_ref |= 1;
11110         }
11111         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11112         CHECK(obj != NULL);
11113         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
11114         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11115                 (*env)->ExceptionDescribe(env);
11116                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
11117         }
11118         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11119         CHECK_ACCESS(ret_ptr);
11120         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11121         FREE((void*)ret);
11122         if (get_jenv_res == JNI_EDETACHED) {
11123                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11124         }
11125         return ret_conv;
11126 }
11127 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
11128         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11129         JNIEnv *env;
11130         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11131         if (get_jenv_res == JNI_EDETACHED) {
11132                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11133         } else {
11134                 DO_ASSERT(get_jenv_res == JNI_OK);
11135         }
11136         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11137         CHECK(obj != NULL);
11138         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
11139         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11140                 (*env)->ExceptionDescribe(env);
11141                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
11142         }
11143         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
11144         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11145         if (ret_constr.datalen > 0)
11146                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11147         else
11148                 ret_constr.data = NULL;
11149         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11150         for (size_t h = 0; h < ret_constr.datalen; h++) {
11151                 int64_t ret_conv_59 = ret_vals[h];
11152                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
11153                 CHECK_ACCESS(ret_conv_59_ptr);
11154                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
11155                 FREE((void*)ret_conv_59);
11156                 ret_constr.data[h] = ret_conv_59_conv;
11157         }
11158         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11159         if (get_jenv_res == JNI_EDETACHED) {
11160                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11161         }
11162         return ret_constr;
11163 }
11164 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
11165         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11166         JNIEnv *env;
11167         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11168         if (get_jenv_res == JNI_EDETACHED) {
11169                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11170         } else {
11171                 DO_ASSERT(get_jenv_res == JNI_OK);
11172         }
11173         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
11174         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
11175         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11176         CHECK(obj != NULL);
11177         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
11178         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11179                 (*env)->ExceptionDescribe(env);
11180                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
11181         }
11182         LDKCVec_NodeAnnouncementZ ret_constr;
11183         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11184         if (ret_constr.datalen > 0)
11185                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11186         else
11187                 ret_constr.data = NULL;
11188         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11189         for (size_t s = 0; s < ret_constr.datalen; s++) {
11190                 int64_t ret_conv_18 = ret_vals[s];
11191                 LDKNodeAnnouncement ret_conv_18_conv;
11192                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
11193                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
11194                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
11195                 ret_constr.data[s] = ret_conv_18_conv;
11196         }
11197         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11198         if (get_jenv_res == JNI_EDETACHED) {
11199                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11200         }
11201         return ret_constr;
11202 }
11203 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
11204         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11205         JNIEnv *env;
11206         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11207         if (get_jenv_res == JNI_EDETACHED) {
11208                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11209         } else {
11210                 DO_ASSERT(get_jenv_res == JNI_OK);
11211         }
11212         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11213         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11214         LDKInit init_var = *init;
11215         uintptr_t init_ref = 0;
11216         init_var = Init_clone(init);
11217         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11218         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11219         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
11220         init_ref = (uintptr_t)init_var.inner;
11221         if (init_var.is_owned) {
11222                 init_ref |= 1;
11223         }
11224         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11225         CHECK(obj != NULL);
11226         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
11227         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11228                 (*env)->ExceptionDescribe(env);
11229                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
11230         }
11231         if (get_jenv_res == JNI_EDETACHED) {
11232                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11233         }
11234 }
11235 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
11236         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11237         JNIEnv *env;
11238         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11239         if (get_jenv_res == JNI_EDETACHED) {
11240                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11241         } else {
11242                 DO_ASSERT(get_jenv_res == JNI_OK);
11243         }
11244         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11245         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11246         LDKReplyChannelRange msg_var = msg;
11247         uintptr_t msg_ref = 0;
11248         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11249         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11250         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11251         msg_ref = (uintptr_t)msg_var.inner;
11252         if (msg_var.is_owned) {
11253                 msg_ref |= 1;
11254         }
11255         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11256         CHECK(obj != NULL);
11257         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
11258         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11259                 (*env)->ExceptionDescribe(env);
11260                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
11261         }
11262         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11263         CHECK_ACCESS(ret_ptr);
11264         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11265         FREE((void*)ret);
11266         if (get_jenv_res == JNI_EDETACHED) {
11267                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11268         }
11269         return ret_conv;
11270 }
11271 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
11272         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11273         JNIEnv *env;
11274         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11275         if (get_jenv_res == JNI_EDETACHED) {
11276                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11277         } else {
11278                 DO_ASSERT(get_jenv_res == JNI_OK);
11279         }
11280         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11281         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11282         LDKReplyShortChannelIdsEnd msg_var = msg;
11283         uintptr_t msg_ref = 0;
11284         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11285         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11286         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11287         msg_ref = (uintptr_t)msg_var.inner;
11288         if (msg_var.is_owned) {
11289                 msg_ref |= 1;
11290         }
11291         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11292         CHECK(obj != NULL);
11293         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
11294         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11295                 (*env)->ExceptionDescribe(env);
11296                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
11297         }
11298         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11299         CHECK_ACCESS(ret_ptr);
11300         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11301         FREE((void*)ret);
11302         if (get_jenv_res == JNI_EDETACHED) {
11303                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11304         }
11305         return ret_conv;
11306 }
11307 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
11308         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11309         JNIEnv *env;
11310         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11311         if (get_jenv_res == JNI_EDETACHED) {
11312                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11313         } else {
11314                 DO_ASSERT(get_jenv_res == JNI_OK);
11315         }
11316         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11317         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11318         LDKQueryChannelRange msg_var = msg;
11319         uintptr_t msg_ref = 0;
11320         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11321         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11322         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11323         msg_ref = (uintptr_t)msg_var.inner;
11324         if (msg_var.is_owned) {
11325                 msg_ref |= 1;
11326         }
11327         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11328         CHECK(obj != NULL);
11329         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
11330         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11331                 (*env)->ExceptionDescribe(env);
11332                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
11333         }
11334         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11335         CHECK_ACCESS(ret_ptr);
11336         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11337         FREE((void*)ret);
11338         if (get_jenv_res == JNI_EDETACHED) {
11339                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11340         }
11341         return ret_conv;
11342 }
11343 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
11344         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11345         JNIEnv *env;
11346         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11347         if (get_jenv_res == JNI_EDETACHED) {
11348                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11349         } else {
11350                 DO_ASSERT(get_jenv_res == JNI_OK);
11351         }
11352         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11353         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11354         LDKQueryShortChannelIds msg_var = msg;
11355         uintptr_t msg_ref = 0;
11356         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11357         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11358         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11359         msg_ref = (uintptr_t)msg_var.inner;
11360         if (msg_var.is_owned) {
11361                 msg_ref |= 1;
11362         }
11363         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11364         CHECK(obj != NULL);
11365         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
11366         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11367                 (*env)->ExceptionDescribe(env);
11368                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
11369         }
11370         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11371         CHECK_ACCESS(ret_ptr);
11372         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11373         FREE((void*)ret);
11374         if (get_jenv_res == JNI_EDETACHED) {
11375                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11376         }
11377         return ret_conv;
11378 }
11379 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
11380         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
11381         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11382         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
11383 }
11384 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11385         jclass c = (*env)->GetObjectClass(env, o);
11386         CHECK(c != NULL);
11387         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
11388         atomic_init(&calls->refcnt, 1);
11389         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11390         calls->o = (*env)->NewWeakGlobalRef(env, o);
11391         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
11392         CHECK(calls->handle_node_announcement_meth != NULL);
11393         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
11394         CHECK(calls->handle_channel_announcement_meth != NULL);
11395         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
11396         CHECK(calls->handle_channel_update_meth != NULL);
11397         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
11398         CHECK(calls->get_next_channel_announcements_meth != NULL);
11399         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
11400         CHECK(calls->get_next_node_announcements_meth != NULL);
11401         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
11402         CHECK(calls->sync_routing_table_meth != NULL);
11403         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
11404         CHECK(calls->handle_reply_channel_range_meth != NULL);
11405         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
11406         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
11407         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
11408         CHECK(calls->handle_query_channel_range_meth != NULL);
11409         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
11410         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
11411
11412         LDKRoutingMessageHandler ret = {
11413                 .this_arg = (void*) calls,
11414                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
11415                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
11416                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
11417                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
11418                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
11419                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
11420                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
11421                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
11422                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
11423                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
11424                 .free = LDKRoutingMessageHandler_JCalls_free,
11425                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
11426         };
11427         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
11428         return ret;
11429 }
11430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11431         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
11432         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
11433         return (uint64_t)res_ptr;
11434 }
11435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
11436         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
11437         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
11438         DO_ASSERT((res_ptr & 1) == 0);
11439         return (int64_t)(res_ptr | 1);
11440 }
11441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
11442         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11443         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11444         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11445         LDKNodeAnnouncement msg_conv;
11446         msg_conv.inner = (void*)(msg & (~1));
11447         msg_conv.is_owned = false;
11448         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11449         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11450         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
11451         return (uintptr_t)ret_conv;
11452 }
11453
11454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
11455         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11456         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11457         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11458         LDKChannelAnnouncement msg_conv;
11459         msg_conv.inner = (void*)(msg & (~1));
11460         msg_conv.is_owned = false;
11461         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11462         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11463         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
11464         return (uintptr_t)ret_conv;
11465 }
11466
11467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
11468         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11469         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11470         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11471         LDKChannelUpdate msg_conv;
11472         msg_conv.inner = (void*)(msg & (~1));
11473         msg_conv.is_owned = false;
11474         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11475         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11476         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
11477         return (uintptr_t)ret_conv;
11478 }
11479
11480 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) {
11481         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11482         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11483         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11484         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
11485         int64_tArray ret_arr = NULL;
11486         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11487         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11488         for (size_t h = 0; h < ret_var.datalen; h++) {
11489                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11490                 *ret_conv_59_conv = ret_var.data[h];
11491                 ret_arr_ptr[h] = ((uintptr_t)ret_conv_59_conv);
11492         }
11493         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11494         FREE(ret_var.data);
11495         return ret_arr;
11496 }
11497
11498 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) {
11499         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11500         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11501         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11502         LDKPublicKey starting_point_ref;
11503         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
11504         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
11505         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
11506         int64_tArray ret_arr = NULL;
11507         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11508         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11509         for (size_t s = 0; s < ret_var.datalen; s++) {
11510                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
11511                 uintptr_t ret_conv_18_ref = 0;
11512                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11513                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11514                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
11515                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
11516                 if (ret_conv_18_var.is_owned) {
11517                         ret_conv_18_ref |= 1;
11518                 }
11519                 ret_arr_ptr[s] = ret_conv_18_ref;
11520         }
11521         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11522         FREE(ret_var.data);
11523         return ret_arr;
11524 }
11525
11526 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) {
11527         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11528         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11529         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11530         LDKPublicKey their_node_id_ref;
11531         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11532         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11533         LDKInit init_conv;
11534         init_conv.inner = (void*)(init & (~1));
11535         init_conv.is_owned = false;
11536         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
11537         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
11538 }
11539
11540 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) {
11541         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11542         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11543         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11544         LDKPublicKey their_node_id_ref;
11545         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11546         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11547         LDKReplyChannelRange msg_conv;
11548         msg_conv.inner = (void*)(msg & (~1));
11549         msg_conv.is_owned = (msg & 1) || (msg == 0);
11550         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11551         msg_conv = ReplyChannelRange_clone(&msg_conv);
11552         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11553         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
11554         return (uintptr_t)ret_conv;
11555 }
11556
11557 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) {
11558         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11559         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11560         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11561         LDKPublicKey their_node_id_ref;
11562         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11563         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11564         LDKReplyShortChannelIdsEnd msg_conv;
11565         msg_conv.inner = (void*)(msg & (~1));
11566         msg_conv.is_owned = (msg & 1) || (msg == 0);
11567         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11568         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
11569         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11570         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
11571         return (uintptr_t)ret_conv;
11572 }
11573
11574 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) {
11575         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11576         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11577         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11578         LDKPublicKey their_node_id_ref;
11579         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11580         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11581         LDKQueryChannelRange msg_conv;
11582         msg_conv.inner = (void*)(msg & (~1));
11583         msg_conv.is_owned = (msg & 1) || (msg == 0);
11584         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11585         msg_conv = QueryChannelRange_clone(&msg_conv);
11586         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11587         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
11588         return (uintptr_t)ret_conv;
11589 }
11590
11591 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) {
11592         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11593         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11594         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
11595         LDKPublicKey their_node_id_ref;
11596         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11597         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11598         LDKQueryShortChannelIds msg_conv;
11599         msg_conv.inner = (void*)(msg & (~1));
11600         msg_conv.is_owned = (msg & 1) || (msg == 0);
11601         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11602         msg_conv = QueryShortChannelIds_clone(&msg_conv);
11603         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11604         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
11605         return (uintptr_t)ret_conv;
11606 }
11607
11608 typedef struct LDKCustomMessageReader_JCalls {
11609         atomic_size_t refcnt;
11610         JavaVM *vm;
11611         jweak o;
11612         jmethodID read_meth;
11613 } LDKCustomMessageReader_JCalls;
11614 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
11615         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
11616         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11617                 JNIEnv *env;
11618                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11619                 if (get_jenv_res == JNI_EDETACHED) {
11620                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11621                 } else {
11622                         DO_ASSERT(get_jenv_res == JNI_OK);
11623                 }
11624                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11625                 if (get_jenv_res == JNI_EDETACHED) {
11626                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11627                 }
11628                 FREE(j_calls);
11629         }
11630 }
11631 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
11632         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
11633         JNIEnv *env;
11634         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11635         if (get_jenv_res == JNI_EDETACHED) {
11636                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11637         } else {
11638                 DO_ASSERT(get_jenv_res == JNI_OK);
11639         }
11640         LDKu8slice buffer_var = buffer;
11641         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
11642         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
11643         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11644         CHECK(obj != NULL);
11645         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr);
11646         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11647                 (*env)->ExceptionDescribe(env);
11648                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
11649         }
11650         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11651         CHECK_ACCESS(ret_ptr);
11652         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
11653         FREE((void*)ret);
11654         if (get_jenv_res == JNI_EDETACHED) {
11655                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11656         }
11657         return ret_conv;
11658 }
11659 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
11660         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
11661         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11662 }
11663 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
11664         jclass c = (*env)->GetObjectClass(env, o);
11665         CHECK(c != NULL);
11666         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
11667         atomic_init(&calls->refcnt, 1);
11668         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11669         calls->o = (*env)->NewWeakGlobalRef(env, o);
11670         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
11671         CHECK(calls->read_meth != NULL);
11672
11673         LDKCustomMessageReader ret = {
11674                 .this_arg = (void*) calls,
11675                 .read = read_LDKCustomMessageReader_jcall,
11676                 .free = LDKCustomMessageReader_JCalls_free,
11677         };
11678         return ret;
11679 }
11680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
11681         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
11682         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
11683         return (uint64_t)res_ptr;
11684 }
11685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1read(JNIEnv *env, jclass clz, int64_t this_arg, int16_t message_type, int8_tArray buffer) {
11686         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11687         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11688         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
11689         LDKu8slice buffer_ref;
11690         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
11691         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
11692         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
11693         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
11694         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
11695         return (uintptr_t)ret_conv;
11696 }
11697
11698 typedef struct LDKCustomMessageHandler_JCalls {
11699         atomic_size_t refcnt;
11700         JavaVM *vm;
11701         jweak o;
11702         LDKCustomMessageReader_JCalls* CustomMessageReader;
11703         jmethodID handle_custom_message_meth;
11704         jmethodID get_and_clear_pending_msg_meth;
11705 } LDKCustomMessageHandler_JCalls;
11706 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
11707         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
11708         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11709                 JNIEnv *env;
11710                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11711                 if (get_jenv_res == JNI_EDETACHED) {
11712                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11713                 } else {
11714                         DO_ASSERT(get_jenv_res == JNI_OK);
11715                 }
11716                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11717                 if (get_jenv_res == JNI_EDETACHED) {
11718                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11719                 }
11720                 FREE(j_calls);
11721         }
11722 }
11723 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
11724         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
11725         JNIEnv *env;
11726         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11727         if (get_jenv_res == JNI_EDETACHED) {
11728                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11729         } else {
11730                 DO_ASSERT(get_jenv_res == JNI_OK);
11731         }
11732         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
11733         *msg_ret = msg;
11734         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
11735         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
11736         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11737         CHECK(obj != NULL);
11738         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (uintptr_t)msg_ret, sender_node_id_arr);
11739         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11740                 (*env)->ExceptionDescribe(env);
11741                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
11742         }
11743         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11744         CHECK_ACCESS(ret_ptr);
11745         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
11746         FREE((void*)ret);
11747         if (get_jenv_res == JNI_EDETACHED) {
11748                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11749         }
11750         return ret_conv;
11751 }
11752 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
11753         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
11754         JNIEnv *env;
11755         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11756         if (get_jenv_res == JNI_EDETACHED) {
11757                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11758         } else {
11759                 DO_ASSERT(get_jenv_res == JNI_OK);
11760         }
11761         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11762         CHECK(obj != NULL);
11763         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
11764         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11765                 (*env)->ExceptionDescribe(env);
11766                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
11767         }
11768         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
11769         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11770         if (ret_constr.datalen > 0)
11771                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
11772         else
11773                 ret_constr.data = NULL;
11774         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11775         for (size_t z = 0; z < ret_constr.datalen; z++) {
11776                 int64_t ret_conv_25 = ret_vals[z];
11777                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
11778                 CHECK_ACCESS(ret_conv_25_ptr);
11779                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
11780                 FREE((void*)ret_conv_25);
11781                 ret_constr.data[z] = ret_conv_25_conv;
11782         }
11783         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11784         if (get_jenv_res == JNI_EDETACHED) {
11785                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11786         }
11787         return ret_constr;
11788 }
11789 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
11790         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
11791         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11792         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
11793 }
11794 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
11795         jclass c = (*env)->GetObjectClass(env, o);
11796         CHECK(c != NULL);
11797         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
11798         atomic_init(&calls->refcnt, 1);
11799         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11800         calls->o = (*env)->NewWeakGlobalRef(env, o);
11801         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
11802         CHECK(calls->handle_custom_message_meth != NULL);
11803         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
11804         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
11805
11806         LDKCustomMessageHandler ret = {
11807                 .this_arg = (void*) calls,
11808                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
11809                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
11810                 .free = LDKCustomMessageHandler_JCalls_free,
11811                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
11812         };
11813         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
11814         return ret;
11815 }
11816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
11817         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
11818         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
11819         return (uint64_t)res_ptr;
11820 }
11821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
11822         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
11823         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
11824         DO_ASSERT((res_ptr & 1) == 0);
11825         return (int64_t)(res_ptr | 1);
11826 }
11827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg, int8_tArray sender_node_id) {
11828         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11829         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11830         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
11831         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
11832         CHECK_ACCESS(msg_ptr);
11833         LDKType msg_conv = *(LDKType*)(msg_ptr);
11834         if (msg_conv.free == LDKType_JCalls_free) {
11835                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11836                 LDKType_JCalls_cloned(&msg_conv);
11837         }
11838         LDKPublicKey sender_node_id_ref;
11839         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
11840         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
11841         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11842         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
11843         return (uintptr_t)ret_conv;
11844 }
11845
11846 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
11847         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11848         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11849         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
11850         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
11851         int64_tArray ret_arr = NULL;
11852         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11853         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11854         for (size_t z = 0; z < ret_var.datalen; z++) {
11855                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
11856                 *ret_conv_25_conv = ret_var.data[z];
11857                 ret_arr_ptr[z] = ((uintptr_t)ret_conv_25_conv);
11858         }
11859         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11860         FREE(ret_var.data);
11861         return ret_arr;
11862 }
11863
11864 typedef struct LDKSocketDescriptor_JCalls {
11865         atomic_size_t refcnt;
11866         JavaVM *vm;
11867         jweak o;
11868         jmethodID send_data_meth;
11869         jmethodID disconnect_socket_meth;
11870         jmethodID eq_meth;
11871         jmethodID hash_meth;
11872 } LDKSocketDescriptor_JCalls;
11873 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
11874         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
11875         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11876                 JNIEnv *env;
11877                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11878                 if (get_jenv_res == JNI_EDETACHED) {
11879                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11880                 } else {
11881                         DO_ASSERT(get_jenv_res == JNI_OK);
11882                 }
11883                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11884                 if (get_jenv_res == JNI_EDETACHED) {
11885                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11886                 }
11887                 FREE(j_calls);
11888         }
11889 }
11890 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
11891         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
11892         JNIEnv *env;
11893         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11894         if (get_jenv_res == JNI_EDETACHED) {
11895                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11896         } else {
11897                 DO_ASSERT(get_jenv_res == JNI_OK);
11898         }
11899         LDKu8slice data_var = data;
11900         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
11901         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
11902         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11903         CHECK(obj != NULL);
11904         intptr_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
11905         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11906                 (*env)->ExceptionDescribe(env);
11907                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
11908         }
11909         if (get_jenv_res == JNI_EDETACHED) {
11910                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11911         }
11912         return ret;
11913 }
11914 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
11915         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
11916         JNIEnv *env;
11917         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11918         if (get_jenv_res == JNI_EDETACHED) {
11919                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11920         } else {
11921                 DO_ASSERT(get_jenv_res == JNI_OK);
11922         }
11923         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11924         CHECK(obj != NULL);
11925         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
11926         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11927                 (*env)->ExceptionDescribe(env);
11928                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
11929         }
11930         if (get_jenv_res == JNI_EDETACHED) {
11931                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11932         }
11933 }
11934 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
11935         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
11936         JNIEnv *env;
11937         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11938         if (get_jenv_res == JNI_EDETACHED) {
11939                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11940         } else {
11941                 DO_ASSERT(get_jenv_res == JNI_OK);
11942         }
11943         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
11944         *other_arg_clone = SocketDescriptor_clone(other_arg);
11945         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11946         CHECK(obj != NULL);
11947         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uintptr_t)other_arg_clone);
11948         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11949                 (*env)->ExceptionDescribe(env);
11950                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
11951         }
11952         if (get_jenv_res == JNI_EDETACHED) {
11953                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11954         }
11955         return ret;
11956 }
11957 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
11958         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
11959         JNIEnv *env;
11960         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11961         if (get_jenv_res == JNI_EDETACHED) {
11962                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11963         } else {
11964                 DO_ASSERT(get_jenv_res == JNI_OK);
11965         }
11966         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11967         CHECK(obj != NULL);
11968         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
11969         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11970                 (*env)->ExceptionDescribe(env);
11971                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
11972         }
11973         if (get_jenv_res == JNI_EDETACHED) {
11974                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11975         }
11976         return ret;
11977 }
11978 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
11979         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
11980         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11981 }
11982 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
11983         jclass c = (*env)->GetObjectClass(env, o);
11984         CHECK(c != NULL);
11985         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
11986         atomic_init(&calls->refcnt, 1);
11987         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11988         calls->o = (*env)->NewWeakGlobalRef(env, o);
11989         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
11990         CHECK(calls->send_data_meth != NULL);
11991         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
11992         CHECK(calls->disconnect_socket_meth != NULL);
11993         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
11994         CHECK(calls->eq_meth != NULL);
11995         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
11996         CHECK(calls->hash_meth != NULL);
11997
11998         LDKSocketDescriptor ret = {
11999                 .this_arg = (void*) calls,
12000                 .send_data = send_data_LDKSocketDescriptor_jcall,
12001                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
12002                 .eq = eq_LDKSocketDescriptor_jcall,
12003                 .hash = hash_LDKSocketDescriptor_jcall,
12004                 .cloned = LDKSocketDescriptor_JCalls_cloned,
12005                 .free = LDKSocketDescriptor_JCalls_free,
12006         };
12007         return ret;
12008 }
12009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
12010         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12011         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
12012         return (uint64_t)res_ptr;
12013 }
12014 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1data(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray data, jboolean resume_read) {
12015         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12016         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12017         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12018         LDKu8slice data_ref;
12019         data_ref.datalen = (*env)->GetArrayLength(env, data);
12020         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
12021         intptr_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
12022         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
12023         return ret_val;
12024 }
12025
12026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
12027         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12028         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12029         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12030         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
12031 }
12032
12033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
12034         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12035         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12036         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12037         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
12038         return ret_val;
12039 }
12040
12041 typedef struct LDKScore_JCalls {
12042         atomic_size_t refcnt;
12043         JavaVM *vm;
12044         jweak o;
12045         jmethodID channel_penalty_msat_meth;
12046         jmethodID payment_path_failed_meth;
12047         jmethodID payment_path_successful_meth;
12048         jmethodID write_meth;
12049 } LDKScore_JCalls;
12050 static void LDKScore_JCalls_free(void* this_arg) {
12051         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12052         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12053                 JNIEnv *env;
12054                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12055                 if (get_jenv_res == JNI_EDETACHED) {
12056                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12057                 } else {
12058                         DO_ASSERT(get_jenv_res == JNI_OK);
12059                 }
12060                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12061                 if (get_jenv_res == JNI_EDETACHED) {
12062                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12063                 }
12064                 FREE(j_calls);
12065         }
12066 }
12067 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, LDKCOption_u64Z channel_capacity_msat, const LDKNodeId * source, const LDKNodeId * target) {
12068         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12069         JNIEnv *env;
12070         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12071         if (get_jenv_res == JNI_EDETACHED) {
12072                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12073         } else {
12074                 DO_ASSERT(get_jenv_res == JNI_OK);
12075         }
12076         LDKCOption_u64Z *channel_capacity_msat_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12077         *channel_capacity_msat_copy = channel_capacity_msat;
12078         uintptr_t channel_capacity_msat_ref = (uintptr_t)channel_capacity_msat_copy;
12079         LDKNodeId source_var = *source;
12080         uintptr_t source_ref = 0;
12081         source_var = NodeId_clone(source);
12082         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12083         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12084         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
12085         source_ref = (uintptr_t)source_var.inner;
12086         if (source_var.is_owned) {
12087                 source_ref |= 1;
12088         }
12089         LDKNodeId target_var = *target;
12090         uintptr_t target_ref = 0;
12091         target_var = NodeId_clone(target);
12092         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12093         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12094         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
12095         target_ref = (uintptr_t)target_var.inner;
12096         if (target_var.is_owned) {
12097                 target_ref |= 1;
12098         }
12099         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12100         CHECK(obj != NULL);
12101         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id, send_amt_msat, channel_capacity_msat_ref, source_ref, target_ref);
12102         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12103                 (*env)->ExceptionDescribe(env);
12104                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
12105         }
12106         if (get_jenv_res == JNI_EDETACHED) {
12107                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12108         }
12109         return ret;
12110 }
12111 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
12112         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12113         JNIEnv *env;
12114         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12115         if (get_jenv_res == JNI_EDETACHED) {
12116                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12117         } else {
12118                 DO_ASSERT(get_jenv_res == JNI_OK);
12119         }
12120         LDKCVec_RouteHopZ path_var = path;
12121         int64_tArray path_arr = NULL;
12122         path_arr = (*env)->NewLongArray(env, path_var.datalen);
12123         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
12124         for (size_t k = 0; k < path_var.datalen; k++) {
12125                 LDKRouteHop path_conv_10_var = path_var.data[k];
12126                 uintptr_t path_conv_10_ref = 0;
12127                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12128                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12129                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
12130                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
12131                 if (path_conv_10_var.is_owned) {
12132                         path_conv_10_ref |= 1;
12133                 }
12134                 path_arr_ptr[k] = path_conv_10_ref;
12135         }
12136         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
12137         FREE(path_var.data);
12138         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12139         CHECK(obj != NULL);
12140         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id);
12141         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12142                 (*env)->ExceptionDescribe(env);
12143                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
12144         }
12145         if (get_jenv_res == JNI_EDETACHED) {
12146                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12147         }
12148 }
12149 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
12150         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12151         JNIEnv *env;
12152         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12153         if (get_jenv_res == JNI_EDETACHED) {
12154                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12155         } else {
12156                 DO_ASSERT(get_jenv_res == JNI_OK);
12157         }
12158         LDKCVec_RouteHopZ path_var = path;
12159         int64_tArray path_arr = NULL;
12160         path_arr = (*env)->NewLongArray(env, path_var.datalen);
12161         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
12162         for (size_t k = 0; k < path_var.datalen; k++) {
12163                 LDKRouteHop path_conv_10_var = path_var.data[k];
12164                 uintptr_t path_conv_10_ref = 0;
12165                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12166                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12167                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
12168                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
12169                 if (path_conv_10_var.is_owned) {
12170                         path_conv_10_ref |= 1;
12171                 }
12172                 path_arr_ptr[k] = path_conv_10_ref;
12173         }
12174         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
12175         FREE(path_var.data);
12176         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12177         CHECK(obj != NULL);
12178         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
12179         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12180                 (*env)->ExceptionDescribe(env);
12181                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
12182         }
12183         if (get_jenv_res == JNI_EDETACHED) {
12184                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12185         }
12186 }
12187 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
12188         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
12189         JNIEnv *env;
12190         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12191         if (get_jenv_res == JNI_EDETACHED) {
12192                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12193         } else {
12194                 DO_ASSERT(get_jenv_res == JNI_OK);
12195         }
12196         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12197         CHECK(obj != NULL);
12198         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
12199         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12200                 (*env)->ExceptionDescribe(env);
12201                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
12202         }
12203         LDKCVec_u8Z ret_ref;
12204         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
12205         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
12206         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
12207         if (get_jenv_res == JNI_EDETACHED) {
12208                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12209         }
12210         return ret_ref;
12211 }
12212 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
12213         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
12214         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12215 }
12216 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
12217         jclass c = (*env)->GetObjectClass(env, o);
12218         CHECK(c != NULL);
12219         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
12220         atomic_init(&calls->refcnt, 1);
12221         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12222         calls->o = (*env)->NewWeakGlobalRef(env, o);
12223         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJJ)J");
12224         CHECK(calls->channel_penalty_msat_meth != NULL);
12225         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
12226         CHECK(calls->payment_path_failed_meth != NULL);
12227         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
12228         CHECK(calls->payment_path_successful_meth != NULL);
12229         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
12230         CHECK(calls->write_meth != NULL);
12231
12232         LDKScore ret = {
12233                 .this_arg = (void*) calls,
12234                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
12235                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
12236                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
12237                 .write = write_LDKScore_jcall,
12238                 .free = LDKScore_JCalls_free,
12239         };
12240         return ret;
12241 }
12242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
12243         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
12244         *res_ptr = LDKScore_init(env, clz, o);
12245         return (uint64_t)res_ptr;
12246 }
12247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t send_amt_msat, int64_t channel_capacity_msat, int64_t source, int64_t target) {
12248         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12249         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12250         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
12251         void* channel_capacity_msat_ptr = (void*)(((uintptr_t)channel_capacity_msat) & ~1);
12252         CHECK_ACCESS(channel_capacity_msat_ptr);
12253         LDKCOption_u64Z channel_capacity_msat_conv = *(LDKCOption_u64Z*)(channel_capacity_msat_ptr);
12254         channel_capacity_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)channel_capacity_msat) & ~1));
12255         LDKNodeId source_conv;
12256         source_conv.inner = (void*)(source & (~1));
12257         source_conv.is_owned = false;
12258         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
12259         LDKNodeId target_conv;
12260         target_conv.inner = (void*)(target & (~1));
12261         target_conv.is_owned = false;
12262         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
12263         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, send_amt_msat, channel_capacity_msat_conv, &source_conv, &target_conv);
12264         return ret_val;
12265 }
12266
12267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
12268         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12269         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12270         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
12271         LDKCVec_RouteHopZ path_constr;
12272         path_constr.datalen = (*env)->GetArrayLength(env, path);
12273         if (path_constr.datalen > 0)
12274                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12275         else
12276                 path_constr.data = NULL;
12277         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
12278         for (size_t k = 0; k < path_constr.datalen; k++) {
12279                 int64_t path_conv_10 = path_vals[k];
12280                 LDKRouteHop path_conv_10_conv;
12281                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
12282                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
12283                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
12284                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
12285                 path_constr.data[k] = path_conv_10_conv;
12286         }
12287         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
12288         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
12289 }
12290
12291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
12292         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12293         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12294         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
12295         LDKCVec_RouteHopZ path_constr;
12296         path_constr.datalen = (*env)->GetArrayLength(env, path);
12297         if (path_constr.datalen > 0)
12298                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12299         else
12300                 path_constr.data = NULL;
12301         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
12302         for (size_t k = 0; k < path_constr.datalen; k++) {
12303                 int64_t path_conv_10 = path_vals[k];
12304                 LDKRouteHop path_conv_10_conv;
12305                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
12306                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
12307                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
12308                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
12309                 path_constr.data[k] = path_conv_10_conv;
12310         }
12311         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
12312         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
12313 }
12314
12315 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
12316         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12317         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12318         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
12319         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
12320         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
12321         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
12322         CVec_u8Z_free(ret_var);
12323         return ret_arr;
12324 }
12325
12326 typedef struct LDKLockableScore_JCalls {
12327         atomic_size_t refcnt;
12328         JavaVM *vm;
12329         jweak o;
12330         jmethodID lock_meth;
12331 } LDKLockableScore_JCalls;
12332 static void LDKLockableScore_JCalls_free(void* this_arg) {
12333         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
12334         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12335                 JNIEnv *env;
12336                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12337                 if (get_jenv_res == JNI_EDETACHED) {
12338                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12339                 } else {
12340                         DO_ASSERT(get_jenv_res == JNI_OK);
12341                 }
12342                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12343                 if (get_jenv_res == JNI_EDETACHED) {
12344                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12345                 }
12346                 FREE(j_calls);
12347         }
12348 }
12349 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
12350         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
12351         JNIEnv *env;
12352         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12353         if (get_jenv_res == JNI_EDETACHED) {
12354                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12355         } else {
12356                 DO_ASSERT(get_jenv_res == JNI_OK);
12357         }
12358         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12359         CHECK(obj != NULL);
12360         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
12361         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12362                 (*env)->ExceptionDescribe(env);
12363                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
12364         }
12365         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12366         CHECK_ACCESS(ret_ptr);
12367         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
12368         if (ret_conv.free == LDKScore_JCalls_free) {
12369                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12370                 LDKScore_JCalls_cloned(&ret_conv);
12371         }// Warning: we may need a move here but no clone is available for LDKScore
12372         
12373         if (get_jenv_res == JNI_EDETACHED) {
12374                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12375         }
12376         return ret_conv;
12377 }
12378 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
12379         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
12380         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12381 }
12382 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
12383         jclass c = (*env)->GetObjectClass(env, o);
12384         CHECK(c != NULL);
12385         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
12386         atomic_init(&calls->refcnt, 1);
12387         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12388         calls->o = (*env)->NewWeakGlobalRef(env, o);
12389         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
12390         CHECK(calls->lock_meth != NULL);
12391
12392         LDKLockableScore ret = {
12393                 .this_arg = (void*) calls,
12394                 .lock = lock_LDKLockableScore_jcall,
12395                 .free = LDKLockableScore_JCalls_free,
12396         };
12397         return ret;
12398 }
12399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
12400         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
12401         *res_ptr = LDKLockableScore_init(env, clz, o);
12402         return (uint64_t)res_ptr;
12403 }
12404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
12405         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12406         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12407         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
12408         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
12409         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
12410         return (uintptr_t)ret_ret;
12411 }
12412
12413 typedef struct LDKChannelManagerPersister_JCalls {
12414         atomic_size_t refcnt;
12415         JavaVM *vm;
12416         jweak o;
12417         jmethodID persist_manager_meth;
12418 } LDKChannelManagerPersister_JCalls;
12419 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
12420         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
12421         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12422                 JNIEnv *env;
12423                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12424                 if (get_jenv_res == JNI_EDETACHED) {
12425                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12426                 } else {
12427                         DO_ASSERT(get_jenv_res == JNI_OK);
12428                 }
12429                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12430                 if (get_jenv_res == JNI_EDETACHED) {
12431                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12432                 }
12433                 FREE(j_calls);
12434         }
12435 }
12436 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
12437         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
12438         JNIEnv *env;
12439         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12440         if (get_jenv_res == JNI_EDETACHED) {
12441                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12442         } else {
12443                 DO_ASSERT(get_jenv_res == JNI_OK);
12444         }
12445         LDKChannelManager channel_manager_var = *channel_manager;
12446         uintptr_t channel_manager_ref = 0;
12447         // Warning: we may need a move here but no clone is available for LDKChannelManager
12448         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12449         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12450         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
12451         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
12452         if (channel_manager_var.is_owned) {
12453                 channel_manager_ref |= 1;
12454         }
12455         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12456         CHECK(obj != NULL);
12457         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
12458         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12459                 (*env)->ExceptionDescribe(env);
12460                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
12461         }
12462         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12463         CHECK_ACCESS(ret_ptr);
12464         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
12465         FREE((void*)ret);
12466         if (get_jenv_res == JNI_EDETACHED) {
12467                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12468         }
12469         return ret_conv;
12470 }
12471 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
12472         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
12473         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12474 }
12475 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
12476         jclass c = (*env)->GetObjectClass(env, o);
12477         CHECK(c != NULL);
12478         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
12479         atomic_init(&calls->refcnt, 1);
12480         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12481         calls->o = (*env)->NewWeakGlobalRef(env, o);
12482         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
12483         CHECK(calls->persist_manager_meth != NULL);
12484
12485         LDKChannelManagerPersister ret = {
12486                 .this_arg = (void*) calls,
12487                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
12488                 .free = LDKChannelManagerPersister_JCalls_free,
12489         };
12490         return ret;
12491 }
12492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
12493         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
12494         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
12495         return (uint64_t)res_ptr;
12496 }
12497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
12498         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12499         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12500         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
12501         LDKChannelManager channel_manager_conv;
12502         channel_manager_conv.inner = (void*)(channel_manager & (~1));
12503         channel_manager_conv.is_owned = false;
12504         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
12505         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
12506         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
12507         return (uintptr_t)ret_conv;
12508 }
12509
12510 static jclass LDKFallback_SegWitProgram_class = NULL;
12511 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
12512 static jclass LDKFallback_PubKeyHash_class = NULL;
12513 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
12514 static jclass LDKFallback_ScriptHash_class = NULL;
12515 static jmethodID LDKFallback_ScriptHash_meth = NULL;
12516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
12517         LDKFallback_SegWitProgram_class =
12518                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
12519         CHECK(LDKFallback_SegWitProgram_class != NULL);
12520         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
12521         CHECK(LDKFallback_SegWitProgram_meth != NULL);
12522         LDKFallback_PubKeyHash_class =
12523                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
12524         CHECK(LDKFallback_PubKeyHash_class != NULL);
12525         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
12526         CHECK(LDKFallback_PubKeyHash_meth != NULL);
12527         LDKFallback_ScriptHash_class =
12528                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
12529         CHECK(LDKFallback_ScriptHash_class != NULL);
12530         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
12531         CHECK(LDKFallback_ScriptHash_meth != NULL);
12532 }
12533 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
12534         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
12535         switch(obj->tag) {
12536                 case LDKFallback_SegWitProgram: {
12537                         uint8_t version_val = obj->seg_wit_program.version._0;
12538                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
12539                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
12540                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
12541                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
12542                 }
12543                 case LDKFallback_PubKeyHash: {
12544                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
12545                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
12546                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
12547                 }
12548                 case LDKFallback_ScriptHash: {
12549                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
12550                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
12551                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
12552                 }
12553                 default: abort();
12554         }
12555 }
12556 typedef struct LDKPayer_JCalls {
12557         atomic_size_t refcnt;
12558         JavaVM *vm;
12559         jweak o;
12560         jmethodID node_id_meth;
12561         jmethodID first_hops_meth;
12562         jmethodID send_payment_meth;
12563         jmethodID send_spontaneous_payment_meth;
12564         jmethodID retry_payment_meth;
12565         jmethodID abandon_payment_meth;
12566 } LDKPayer_JCalls;
12567 static void LDKPayer_JCalls_free(void* this_arg) {
12568         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
12569         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12570                 JNIEnv *env;
12571                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12572                 if (get_jenv_res == JNI_EDETACHED) {
12573                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12574                 } else {
12575                         DO_ASSERT(get_jenv_res == JNI_OK);
12576                 }
12577                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12578                 if (get_jenv_res == JNI_EDETACHED) {
12579                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12580                 }
12581                 FREE(j_calls);
12582         }
12583 }
12584 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
12585         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
12586         JNIEnv *env;
12587         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12588         if (get_jenv_res == JNI_EDETACHED) {
12589                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12590         } else {
12591                 DO_ASSERT(get_jenv_res == JNI_OK);
12592         }
12593         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12594         CHECK(obj != NULL);
12595         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
12596         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12597                 (*env)->ExceptionDescribe(env);
12598                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
12599         }
12600         LDKPublicKey ret_ref;
12601         CHECK((*env)->GetArrayLength(env, ret) == 33);
12602         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
12603         if (get_jenv_res == JNI_EDETACHED) {
12604                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12605         }
12606         return ret_ref;
12607 }
12608 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
12609         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
12610         JNIEnv *env;
12611         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12612         if (get_jenv_res == JNI_EDETACHED) {
12613                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12614         } else {
12615                 DO_ASSERT(get_jenv_res == JNI_OK);
12616         }
12617         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12618         CHECK(obj != NULL);
12619         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
12620         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12621                 (*env)->ExceptionDescribe(env);
12622                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
12623         }
12624         LDKCVec_ChannelDetailsZ ret_constr;
12625         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12626         if (ret_constr.datalen > 0)
12627                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12628         else
12629                 ret_constr.data = NULL;
12630         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12631         for (size_t q = 0; q < ret_constr.datalen; q++) {
12632                 int64_t ret_conv_16 = ret_vals[q];
12633                 LDKChannelDetails ret_conv_16_conv;
12634                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
12635                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
12636                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
12637                 ret_constr.data[q] = ret_conv_16_conv;
12638         }
12639         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12640         if (get_jenv_res == JNI_EDETACHED) {
12641                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12642         }
12643         return ret_constr;
12644 }
12645 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
12646         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
12647         JNIEnv *env;
12648         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12649         if (get_jenv_res == JNI_EDETACHED) {
12650                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12651         } else {
12652                 DO_ASSERT(get_jenv_res == JNI_OK);
12653         }
12654         LDKRoute route_var = *route;
12655         uintptr_t route_ref = 0;
12656         route_var = Route_clone(route);
12657         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12658         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12659         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
12660         route_ref = (uintptr_t)route_var.inner;
12661         if (route_var.is_owned) {
12662                 route_ref |= 1;
12663         }
12664         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
12665         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
12666         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
12667         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
12668         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12669         CHECK(obj != NULL);
12670         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
12671         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12672                 (*env)->ExceptionDescribe(env);
12673                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
12674         }
12675         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12676         CHECK_ACCESS(ret_ptr);
12677         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
12678         FREE((void*)ret);
12679         if (get_jenv_res == JNI_EDETACHED) {
12680                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12681         }
12682         return ret_conv;
12683 }
12684 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
12685         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
12686         JNIEnv *env;
12687         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12688         if (get_jenv_res == JNI_EDETACHED) {
12689                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12690         } else {
12691                 DO_ASSERT(get_jenv_res == JNI_OK);
12692         }
12693         LDKRoute route_var = *route;
12694         uintptr_t route_ref = 0;
12695         route_var = Route_clone(route);
12696         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12697         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12698         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
12699         route_ref = (uintptr_t)route_var.inner;
12700         if (route_var.is_owned) {
12701                 route_ref |= 1;
12702         }
12703         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
12704         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
12705         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12706         CHECK(obj != NULL);
12707         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
12708         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12709                 (*env)->ExceptionDescribe(env);
12710                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
12711         }
12712         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12713         CHECK_ACCESS(ret_ptr);
12714         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
12715         FREE((void*)ret);
12716         if (get_jenv_res == JNI_EDETACHED) {
12717                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12718         }
12719         return ret_conv;
12720 }
12721 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
12722         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
12723         JNIEnv *env;
12724         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12725         if (get_jenv_res == JNI_EDETACHED) {
12726                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12727         } else {
12728                 DO_ASSERT(get_jenv_res == JNI_OK);
12729         }
12730         LDKRoute route_var = *route;
12731         uintptr_t route_ref = 0;
12732         route_var = Route_clone(route);
12733         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12734         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12735         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
12736         route_ref = (uintptr_t)route_var.inner;
12737         if (route_var.is_owned) {
12738                 route_ref |= 1;
12739         }
12740         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
12741         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
12742         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12743         CHECK(obj != NULL);
12744         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
12745         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12746                 (*env)->ExceptionDescribe(env);
12747                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
12748         }
12749         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12750         CHECK_ACCESS(ret_ptr);
12751         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
12752         FREE((void*)ret);
12753         if (get_jenv_res == JNI_EDETACHED) {
12754                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12755         }
12756         return ret_conv;
12757 }
12758 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
12759         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
12760         JNIEnv *env;
12761         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12762         if (get_jenv_res == JNI_EDETACHED) {
12763                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12764         } else {
12765                 DO_ASSERT(get_jenv_res == JNI_OK);
12766         }
12767         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
12768         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
12769         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12770         CHECK(obj != NULL);
12771         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
12772         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12773                 (*env)->ExceptionDescribe(env);
12774                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
12775         }
12776         if (get_jenv_res == JNI_EDETACHED) {
12777                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12778         }
12779 }
12780 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
12781         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
12782         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12783 }
12784 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
12785         jclass c = (*env)->GetObjectClass(env, o);
12786         CHECK(c != NULL);
12787         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
12788         atomic_init(&calls->refcnt, 1);
12789         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12790         calls->o = (*env)->NewWeakGlobalRef(env, o);
12791         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
12792         CHECK(calls->node_id_meth != NULL);
12793         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
12794         CHECK(calls->first_hops_meth != NULL);
12795         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
12796         CHECK(calls->send_payment_meth != NULL);
12797         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
12798         CHECK(calls->send_spontaneous_payment_meth != NULL);
12799         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
12800         CHECK(calls->retry_payment_meth != NULL);
12801         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
12802         CHECK(calls->abandon_payment_meth != NULL);
12803
12804         LDKPayer ret = {
12805                 .this_arg = (void*) calls,
12806                 .node_id = node_id_LDKPayer_jcall,
12807                 .first_hops = first_hops_LDKPayer_jcall,
12808                 .send_payment = send_payment_LDKPayer_jcall,
12809                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
12810                 .retry_payment = retry_payment_LDKPayer_jcall,
12811                 .abandon_payment = abandon_payment_LDKPayer_jcall,
12812                 .free = LDKPayer_JCalls_free,
12813         };
12814         return ret;
12815 }
12816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
12817         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
12818         *res_ptr = LDKPayer_init(env, clz, o);
12819         return (uint64_t)res_ptr;
12820 }
12821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
12822         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12823         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12824         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
12825         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
12826         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
12827         return ret_arr;
12828 }
12829
12830 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
12831         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12832         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12833         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
12834         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
12835         int64_tArray ret_arr = NULL;
12836         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12837         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12838         for (size_t q = 0; q < ret_var.datalen; q++) {
12839                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
12840                 uintptr_t ret_conv_16_ref = 0;
12841                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12842                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12843                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
12844                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
12845                 if (ret_conv_16_var.is_owned) {
12846                         ret_conv_16_ref |= 1;
12847                 }
12848                 ret_arr_ptr[q] = ret_conv_16_ref;
12849         }
12850         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12851         FREE(ret_var.data);
12852         return ret_arr;
12853 }
12854
12855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
12856         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12857         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12858         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
12859         LDKRoute route_conv;
12860         route_conv.inner = (void*)(route & (~1));
12861         route_conv.is_owned = false;
12862         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
12863         LDKThirtyTwoBytes payment_hash_ref;
12864         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
12865         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
12866         LDKThirtyTwoBytes payment_secret_ref;
12867         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
12868         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
12869         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
12870         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
12871         return (uintptr_t)ret_conv;
12872 }
12873
12874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1send_1spontaneous_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_preimage) {
12875         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12876         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12877         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
12878         LDKRoute route_conv;
12879         route_conv.inner = (void*)(route & (~1));
12880         route_conv.is_owned = false;
12881         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
12882         LDKThirtyTwoBytes payment_preimage_ref;
12883         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
12884         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
12885         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
12886         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
12887         return (uintptr_t)ret_conv;
12888 }
12889
12890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_id) {
12891         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12892         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12893         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
12894         LDKRoute route_conv;
12895         route_conv.inner = (void*)(route & (~1));
12896         route_conv.is_owned = false;
12897         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
12898         LDKThirtyTwoBytes payment_id_ref;
12899         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
12900         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
12901         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
12902         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
12903         return (uintptr_t)ret_conv;
12904 }
12905
12906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
12907         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12908         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12909         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
12910         LDKThirtyTwoBytes payment_id_ref;
12911         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
12912         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
12913         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
12914 }
12915
12916 typedef struct LDKRouter_JCalls {
12917         atomic_size_t refcnt;
12918         JavaVM *vm;
12919         jweak o;
12920         jmethodID find_route_meth;
12921 } LDKRouter_JCalls;
12922 static void LDKRouter_JCalls_free(void* this_arg) {
12923         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
12924         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12925                 JNIEnv *env;
12926                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12927                 if (get_jenv_res == JNI_EDETACHED) {
12928                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12929                 } else {
12930                         DO_ASSERT(get_jenv_res == JNI_OK);
12931                 }
12932                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12933                 if (get_jenv_res == JNI_EDETACHED) {
12934                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12935                 }
12936                 FREE(j_calls);
12937         }
12938 }
12939 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * params, const uint8_t (* payment_hash)[32], LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
12940         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
12941         JNIEnv *env;
12942         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12943         if (get_jenv_res == JNI_EDETACHED) {
12944                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12945         } else {
12946                 DO_ASSERT(get_jenv_res == JNI_OK);
12947         }
12948         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
12949         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
12950         LDKRouteParameters params_var = *params;
12951         uintptr_t params_ref = 0;
12952         params_var = RouteParameters_clone(params);
12953         CHECK((((uintptr_t)params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12954         CHECK((((uintptr_t)&params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12955         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_var);
12956         params_ref = (uintptr_t)params_var.inner;
12957         if (params_var.is_owned) {
12958                 params_ref |= 1;
12959         }
12960         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
12961         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
12962         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
12963         int64_tArray first_hops_arr = NULL;
12964         if (first_hops != NULL) {
12965                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
12966                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
12967                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
12968                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
12969                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
12970                         uintptr_t first_hops_conv_16_ref = 0;
12971                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12972                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12973                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
12974                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
12975                         if (first_hops_conv_16_var.is_owned) {
12976                                 first_hops_conv_16_ref |= 1;
12977                         }
12978                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
12979                 }
12980                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
12981         }
12982         // WARNING: This object doesn't live past this scope, needs clone!
12983         uintptr_t ret_scorer = ((uintptr_t)scorer) | 1;
12984         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12985         CHECK(obj != NULL);
12986         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, params_ref, payment_hash_arr, first_hops_arr, ret_scorer);
12987         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12988                 (*env)->ExceptionDescribe(env);
12989                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
12990         }
12991         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12992         CHECK_ACCESS(ret_ptr);
12993         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
12994         FREE((void*)ret);
12995         if (get_jenv_res == JNI_EDETACHED) {
12996                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12997         }
12998         return ret_conv;
12999 }
13000 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
13001         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
13002         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13003 }
13004 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
13005         jclass c = (*env)->GetObjectClass(env, o);
13006         CHECK(c != NULL);
13007         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
13008         atomic_init(&calls->refcnt, 1);
13009         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13010         calls->o = (*env)->NewWeakGlobalRef(env, o);
13011         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
13012         CHECK(calls->find_route_meth != NULL);
13013
13014         LDKRouter ret = {
13015                 .this_arg = (void*) calls,
13016                 .find_route = find_route_LDKRouter_jcall,
13017                 .free = LDKRouter_JCalls_free,
13018         };
13019         return ret;
13020 }
13021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
13022         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
13023         *res_ptr = LDKRouter_init(env, clz, o);
13024         return (uint64_t)res_ptr;
13025 }
13026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Router_1find_1route(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payer, int64_t params, int8_tArray payment_hash, int64_tArray first_hops, int64_t scorer) {
13027         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13028         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13029         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
13030         LDKPublicKey payer_ref;
13031         CHECK((*env)->GetArrayLength(env, payer) == 33);
13032         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
13033         LDKRouteParameters params_conv;
13034         params_conv.inner = (void*)(params & (~1));
13035         params_conv.is_owned = false;
13036         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
13037         unsigned char payment_hash_arr[32];
13038         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13039         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
13040         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
13041         LDKCVec_ChannelDetailsZ first_hops_constr;
13042         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
13043         if (first_hops != NULL) {
13044                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
13045                 if (first_hops_constr.datalen > 0)
13046                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13047                 else
13048                         first_hops_constr.data = NULL;
13049                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
13050                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
13051                         int64_t first_hops_conv_16 = first_hops_vals[q];
13052                         LDKChannelDetails first_hops_conv_16_conv;
13053                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
13054                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
13055                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
13056                         first_hops_constr.data[q] = first_hops_conv_16_conv;
13057                 }
13058                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
13059                 first_hops_ptr = &first_hops_constr;
13060         }
13061         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
13062         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
13063         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
13064         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
13065         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &params_conv, payment_hash_ref, first_hops_ptr, scorer_conv);
13066         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
13067         return (uintptr_t)ret_conv;
13068 }
13069
13070 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
13071         LDKStr ret_str = _ldk_get_compiled_version();
13072         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
13073         Str_free(ret_str);
13074         return ret_conv;
13075 }
13076
13077 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
13078         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
13079         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
13080         Str_free(ret_str);
13081         return ret_conv;
13082 }
13083
13084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
13085         LDKTransaction _res_ref;
13086         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
13087         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
13088         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
13089         _res_ref.data_is_owned = true;
13090         Transaction_free(_res_ref);
13091 }
13092
13093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
13094         LDKCVec_u8Z script_pubkey_ref;
13095         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
13096         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
13097         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
13098         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
13099         *ret_ref = TxOut_new(script_pubkey_ref, value);
13100         return (uintptr_t)ret_ref;
13101 }
13102
13103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
13104         if ((_res & 1) != 0) return;
13105         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13106         CHECK_ACCESS(_res_ptr);
13107         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
13108         FREE((void*)_res);
13109         TxOut_free(_res_conv);
13110 }
13111
13112 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
13113         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
13114         *ret_ref = TxOut_clone(arg);
13115         return (uintptr_t)ret_ref;
13116 }
13117 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13118         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
13119         intptr_t ret_val = TxOut_clone_ptr(arg_conv);
13120         return ret_val;
13121 }
13122
13123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13124         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
13125         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
13126         *ret_ref = TxOut_clone(orig_conv);
13127         return (uintptr_t)ret_ref;
13128 }
13129
13130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
13131         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
13132         Str_free(dummy);
13133 }
13134
13135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13136         LDKSecretKey o_ref;
13137         CHECK((*env)->GetArrayLength(env, o) == 32);
13138         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
13139         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13140         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
13141         return (uintptr_t)ret_conv;
13142 }
13143
13144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13145         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13146         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
13147         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
13148         return (uintptr_t)ret_conv;
13149 }
13150
13151 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13152         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
13153         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
13154         return ret_val;
13155 }
13156
13157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13158         if ((_res & 1) != 0) return;
13159         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13160         CHECK_ACCESS(_res_ptr);
13161         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
13162         FREE((void*)_res);
13163         CResult_SecretKeyErrorZ_free(_res_conv);
13164 }
13165
13166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13167         LDKPublicKey o_ref;
13168         CHECK((*env)->GetArrayLength(env, o) == 33);
13169         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
13170         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13171         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
13172         return (uintptr_t)ret_conv;
13173 }
13174
13175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13176         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13177         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13178         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
13179         return (uintptr_t)ret_conv;
13180 }
13181
13182 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13183         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
13184         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
13185         return ret_val;
13186 }
13187
13188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13189         if ((_res & 1) != 0) return;
13190         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13191         CHECK_ACCESS(_res_ptr);
13192         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
13193         FREE((void*)_res);
13194         CResult_PublicKeyErrorZ_free(_res_conv);
13195 }
13196
13197 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
13198         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13199         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
13200         return (uintptr_t)ret_conv;
13201 }
13202 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13203         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
13204         intptr_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
13205         return ret_val;
13206 }
13207
13208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13209         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
13210         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
13211         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
13212         return (uintptr_t)ret_conv;
13213 }
13214
13215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13216         LDKTxCreationKeys o_conv;
13217         o_conv.inner = (void*)(o & (~1));
13218         o_conv.is_owned = (o & 1) || (o == 0);
13219         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13220         o_conv = TxCreationKeys_clone(&o_conv);
13221         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13222         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
13223         return (uintptr_t)ret_conv;
13224 }
13225
13226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13227         LDKDecodeError e_conv;
13228         e_conv.inner = (void*)(e & (~1));
13229         e_conv.is_owned = (e & 1) || (e == 0);
13230         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13231         e_conv = DecodeError_clone(&e_conv);
13232         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13233         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
13234         return (uintptr_t)ret_conv;
13235 }
13236
13237 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13238         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
13239         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
13240         return ret_val;
13241 }
13242
13243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13244         if ((_res & 1) != 0) return;
13245         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13246         CHECK_ACCESS(_res_ptr);
13247         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
13248         FREE((void*)_res);
13249         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
13250 }
13251
13252 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
13253         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13254         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
13255         return (uintptr_t)ret_conv;
13256 }
13257 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13258         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
13259         intptr_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
13260         return ret_val;
13261 }
13262
13263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13264         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
13265         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
13266         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
13267         return (uintptr_t)ret_conv;
13268 }
13269
13270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13271         LDKChannelPublicKeys o_conv;
13272         o_conv.inner = (void*)(o & (~1));
13273         o_conv.is_owned = (o & 1) || (o == 0);
13274         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13275         o_conv = ChannelPublicKeys_clone(&o_conv);
13276         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
13277         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
13278         return (uintptr_t)ret_conv;
13279 }
13280
13281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13282         LDKDecodeError e_conv;
13283         e_conv.inner = (void*)(e & (~1));
13284         e_conv.is_owned = (e & 1) || (e == 0);
13285         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13286         e_conv = DecodeError_clone(&e_conv);
13287         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
13288         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
13289         return (uintptr_t)ret_conv;
13290 }
13291
13292 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13293         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
13294         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
13295         return ret_val;
13296 }
13297
13298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13299         if ((_res & 1) != 0) return;
13300         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13301         CHECK_ACCESS(_res_ptr);
13302         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
13303         FREE((void*)_res);
13304         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
13305 }
13306
13307 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
13308         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
13309         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
13310         return (uintptr_t)ret_conv;
13311 }
13312 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13313         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
13314         intptr_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
13315         return ret_val;
13316 }
13317
13318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13319         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
13320         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
13321         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
13322         return (uintptr_t)ret_conv;
13323 }
13324
13325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13326         LDKTxCreationKeys o_conv;
13327         o_conv.inner = (void*)(o & (~1));
13328         o_conv.is_owned = (o & 1) || (o == 0);
13329         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13330         o_conv = TxCreationKeys_clone(&o_conv);
13331         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
13332         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
13333         return (uintptr_t)ret_conv;
13334 }
13335
13336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
13337         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
13338         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
13339         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
13340         return (uintptr_t)ret_conv;
13341 }
13342
13343 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13344         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
13345         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
13346         return ret_val;
13347 }
13348
13349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13350         if ((_res & 1) != 0) return;
13351         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13352         CHECK_ACCESS(_res_ptr);
13353         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
13354         FREE((void*)_res);
13355         CResult_TxCreationKeysErrorZ_free(_res_conv);
13356 }
13357
13358 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
13359         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
13360         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
13361         return (uintptr_t)ret_conv;
13362 }
13363 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13364         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
13365         intptr_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
13366         return ret_val;
13367 }
13368
13369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13370         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
13371         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
13372         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
13373         return (uintptr_t)ret_conv;
13374 }
13375
13376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
13377         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
13378         *ret_copy = COption_u32Z_some(o);
13379         uintptr_t ret_ref = (uintptr_t)ret_copy;
13380         return ret_ref;
13381 }
13382
13383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
13384         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
13385         *ret_copy = COption_u32Z_none();
13386         uintptr_t ret_ref = (uintptr_t)ret_copy;
13387         return ret_ref;
13388 }
13389
13390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
13391         if ((_res & 1) != 0) return;
13392         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13393         CHECK_ACCESS(_res_ptr);
13394         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
13395         FREE((void*)_res);
13396         COption_u32Z_free(_res_conv);
13397 }
13398
13399 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
13400         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
13401         *ret_copy = COption_u32Z_clone(arg);
13402 uintptr_t ret_ref = (uintptr_t)ret_copy;
13403         return ret_ref;
13404 }
13405 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13406         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
13407         intptr_t ret_val = COption_u32Z_clone_ptr(arg_conv);
13408         return ret_val;
13409 }
13410
13411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13412         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
13413         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
13414         *ret_copy = COption_u32Z_clone(orig_conv);
13415         uintptr_t ret_ref = (uintptr_t)ret_copy;
13416         return ret_ref;
13417 }
13418
13419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13420         LDKHTLCOutputInCommitment o_conv;
13421         o_conv.inner = (void*)(o & (~1));
13422         o_conv.is_owned = (o & 1) || (o == 0);
13423         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13424         o_conv = HTLCOutputInCommitment_clone(&o_conv);
13425         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
13426         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
13427         return (uintptr_t)ret_conv;
13428 }
13429
13430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13431         LDKDecodeError e_conv;
13432         e_conv.inner = (void*)(e & (~1));
13433         e_conv.is_owned = (e & 1) || (e == 0);
13434         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13435         e_conv = DecodeError_clone(&e_conv);
13436         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
13437         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
13438         return (uintptr_t)ret_conv;
13439 }
13440
13441 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13442         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
13443         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
13444         return ret_val;
13445 }
13446
13447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13448         if ((_res & 1) != 0) return;
13449         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13450         CHECK_ACCESS(_res_ptr);
13451         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
13452         FREE((void*)_res);
13453         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
13454 }
13455
13456 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
13457         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
13458         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
13459         return (uintptr_t)ret_conv;
13460 }
13461 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13462         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
13463         intptr_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
13464         return ret_val;
13465 }
13466
13467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13468         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
13469         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
13470         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
13471         return (uintptr_t)ret_conv;
13472 }
13473
13474 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
13475         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
13476         return ret_conv;
13477 }
13478
13479 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
13480         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
13481         return ret_conv;
13482 }
13483
13484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
13485         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
13486         COption_NoneZ_free(_res_conv);
13487 }
13488
13489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13490         LDKCounterpartyChannelTransactionParameters o_conv;
13491         o_conv.inner = (void*)(o & (~1));
13492         o_conv.is_owned = (o & 1) || (o == 0);
13493         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13494         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
13495         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
13496         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
13497         return (uintptr_t)ret_conv;
13498 }
13499
13500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13501         LDKDecodeError e_conv;
13502         e_conv.inner = (void*)(e & (~1));
13503         e_conv.is_owned = (e & 1) || (e == 0);
13504         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13505         e_conv = DecodeError_clone(&e_conv);
13506         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
13507         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
13508         return (uintptr_t)ret_conv;
13509 }
13510
13511 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13512         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
13513         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
13514         return ret_val;
13515 }
13516
13517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13518         if ((_res & 1) != 0) return;
13519         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13520         CHECK_ACCESS(_res_ptr);
13521         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
13522         FREE((void*)_res);
13523         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
13524 }
13525
13526 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
13527         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
13528         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
13529         return (uintptr_t)ret_conv;
13530 }
13531 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13532         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
13533         intptr_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
13534         return ret_val;
13535 }
13536
13537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13538         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
13539         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
13540         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
13541         return (uintptr_t)ret_conv;
13542 }
13543
13544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13545         LDKChannelTransactionParameters o_conv;
13546         o_conv.inner = (void*)(o & (~1));
13547         o_conv.is_owned = (o & 1) || (o == 0);
13548         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13549         o_conv = ChannelTransactionParameters_clone(&o_conv);
13550         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
13551         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
13552         return (uintptr_t)ret_conv;
13553 }
13554
13555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13556         LDKDecodeError e_conv;
13557         e_conv.inner = (void*)(e & (~1));
13558         e_conv.is_owned = (e & 1) || (e == 0);
13559         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13560         e_conv = DecodeError_clone(&e_conv);
13561         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
13562         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
13563         return (uintptr_t)ret_conv;
13564 }
13565
13566 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13567         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
13568         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
13569         return ret_val;
13570 }
13571
13572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13573         if ((_res & 1) != 0) return;
13574         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13575         CHECK_ACCESS(_res_ptr);
13576         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
13577         FREE((void*)_res);
13578         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
13579 }
13580
13581 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
13582         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
13583         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
13584         return (uintptr_t)ret_conv;
13585 }
13586 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13587         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
13588         intptr_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
13589         return ret_val;
13590 }
13591
13592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13593         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
13594         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
13595         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
13596         return (uintptr_t)ret_conv;
13597 }
13598
13599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
13600         LDKCVec_SignatureZ _res_constr;
13601         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13602         if (_res_constr.datalen > 0)
13603                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13604         else
13605                 _res_constr.data = NULL;
13606         for (size_t i = 0; i < _res_constr.datalen; i++) {
13607                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
13608                 LDKSignature _res_conv_8_ref;
13609                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
13610                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
13611                 _res_constr.data[i] = _res_conv_8_ref;
13612         }
13613         CVec_SignatureZ_free(_res_constr);
13614 }
13615
13616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13617         LDKHolderCommitmentTransaction o_conv;
13618         o_conv.inner = (void*)(o & (~1));
13619         o_conv.is_owned = (o & 1) || (o == 0);
13620         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13621         o_conv = HolderCommitmentTransaction_clone(&o_conv);
13622         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
13623         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
13624         return (uintptr_t)ret_conv;
13625 }
13626
13627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13628         LDKDecodeError e_conv;
13629         e_conv.inner = (void*)(e & (~1));
13630         e_conv.is_owned = (e & 1) || (e == 0);
13631         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13632         e_conv = DecodeError_clone(&e_conv);
13633         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
13634         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
13635         return (uintptr_t)ret_conv;
13636 }
13637
13638 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13639         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
13640         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
13641         return ret_val;
13642 }
13643
13644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13645         if ((_res & 1) != 0) return;
13646         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13647         CHECK_ACCESS(_res_ptr);
13648         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
13649         FREE((void*)_res);
13650         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
13651 }
13652
13653 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
13654         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
13655         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
13656         return (uintptr_t)ret_conv;
13657 }
13658 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13659         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
13660         intptr_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
13661         return ret_val;
13662 }
13663
13664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13665         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
13666         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
13667         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
13668         return (uintptr_t)ret_conv;
13669 }
13670
13671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13672         LDKBuiltCommitmentTransaction o_conv;
13673         o_conv.inner = (void*)(o & (~1));
13674         o_conv.is_owned = (o & 1) || (o == 0);
13675         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13676         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
13677         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
13678         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
13679         return (uintptr_t)ret_conv;
13680 }
13681
13682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13683         LDKDecodeError e_conv;
13684         e_conv.inner = (void*)(e & (~1));
13685         e_conv.is_owned = (e & 1) || (e == 0);
13686         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13687         e_conv = DecodeError_clone(&e_conv);
13688         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
13689         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
13690         return (uintptr_t)ret_conv;
13691 }
13692
13693 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13694         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
13695         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
13696         return ret_val;
13697 }
13698
13699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13700         if ((_res & 1) != 0) return;
13701         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13702         CHECK_ACCESS(_res_ptr);
13703         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
13704         FREE((void*)_res);
13705         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
13706 }
13707
13708 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
13709         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
13710         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
13711         return (uintptr_t)ret_conv;
13712 }
13713 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13714         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
13715         intptr_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
13716         return ret_val;
13717 }
13718
13719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13720         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
13721         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
13722         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
13723         return (uintptr_t)ret_conv;
13724 }
13725
13726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13727         LDKTrustedClosingTransaction o_conv;
13728         o_conv.inner = (void*)(o & (~1));
13729         o_conv.is_owned = (o & 1) || (o == 0);
13730         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13731         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
13732         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
13733         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
13734         return (uintptr_t)ret_conv;
13735 }
13736
13737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
13738         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
13739         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
13740         return (uintptr_t)ret_conv;
13741 }
13742
13743 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13744         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
13745         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
13746         return ret_val;
13747 }
13748
13749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13750         if ((_res & 1) != 0) return;
13751         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13752         CHECK_ACCESS(_res_ptr);
13753         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
13754         FREE((void*)_res);
13755         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
13756 }
13757
13758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13759         LDKCommitmentTransaction o_conv;
13760         o_conv.inner = (void*)(o & (~1));
13761         o_conv.is_owned = (o & 1) || (o == 0);
13762         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13763         o_conv = CommitmentTransaction_clone(&o_conv);
13764         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
13765         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
13766         return (uintptr_t)ret_conv;
13767 }
13768
13769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13770         LDKDecodeError e_conv;
13771         e_conv.inner = (void*)(e & (~1));
13772         e_conv.is_owned = (e & 1) || (e == 0);
13773         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13774         e_conv = DecodeError_clone(&e_conv);
13775         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
13776         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
13777         return (uintptr_t)ret_conv;
13778 }
13779
13780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13781         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
13782         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
13783         return ret_val;
13784 }
13785
13786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13787         if ((_res & 1) != 0) return;
13788         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13789         CHECK_ACCESS(_res_ptr);
13790         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
13791         FREE((void*)_res);
13792         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
13793 }
13794
13795 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
13796         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
13797         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
13798         return (uintptr_t)ret_conv;
13799 }
13800 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13801         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
13802         intptr_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
13803         return ret_val;
13804 }
13805
13806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13807         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
13808         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
13809         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
13810         return (uintptr_t)ret_conv;
13811 }
13812
13813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13814         LDKTrustedCommitmentTransaction o_conv;
13815         o_conv.inner = (void*)(o & (~1));
13816         o_conv.is_owned = (o & 1) || (o == 0);
13817         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13818         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
13819         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
13820         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
13821         return (uintptr_t)ret_conv;
13822 }
13823
13824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
13825         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
13826         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
13827         return (uintptr_t)ret_conv;
13828 }
13829
13830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13831         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
13832         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
13833         return ret_val;
13834 }
13835
13836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13837         if ((_res & 1) != 0) return;
13838         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13839         CHECK_ACCESS(_res_ptr);
13840         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
13841         FREE((void*)_res);
13842         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
13843 }
13844
13845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
13846         LDKCVec_SignatureZ o_constr;
13847         o_constr.datalen = (*env)->GetArrayLength(env, o);
13848         if (o_constr.datalen > 0)
13849                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13850         else
13851                 o_constr.data = NULL;
13852         for (size_t i = 0; i < o_constr.datalen; i++) {
13853                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
13854                 LDKSignature o_conv_8_ref;
13855                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
13856                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
13857                 o_constr.data[i] = o_conv_8_ref;
13858         }
13859         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
13860         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
13861         return (uintptr_t)ret_conv;
13862 }
13863
13864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
13865         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
13866         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
13867         return (uintptr_t)ret_conv;
13868 }
13869
13870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13871         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
13872         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
13873         return ret_val;
13874 }
13875
13876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13877         if ((_res & 1) != 0) return;
13878         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13879         CHECK_ACCESS(_res_ptr);
13880         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
13881         FREE((void*)_res);
13882         CResult_CVec_SignatureZNoneZ_free(_res_conv);
13883 }
13884
13885 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
13886         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
13887         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
13888         return (uintptr_t)ret_conv;
13889 }
13890 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13891         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
13892         intptr_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
13893         return ret_val;
13894 }
13895
13896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13897         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
13898         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
13899         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
13900         return (uintptr_t)ret_conv;
13901 }
13902
13903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13904         LDKShutdownScript o_conv;
13905         o_conv.inner = (void*)(o & (~1));
13906         o_conv.is_owned = (o & 1) || (o == 0);
13907         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13908         o_conv = ShutdownScript_clone(&o_conv);
13909         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
13910         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
13911         return (uintptr_t)ret_conv;
13912 }
13913
13914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13915         LDKDecodeError e_conv;
13916         e_conv.inner = (void*)(e & (~1));
13917         e_conv.is_owned = (e & 1) || (e == 0);
13918         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13919         e_conv = DecodeError_clone(&e_conv);
13920         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
13921         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
13922         return (uintptr_t)ret_conv;
13923 }
13924
13925 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13926         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
13927         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
13928         return ret_val;
13929 }
13930
13931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13932         if ((_res & 1) != 0) return;
13933         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13934         CHECK_ACCESS(_res_ptr);
13935         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
13936         FREE((void*)_res);
13937         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
13938 }
13939
13940 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
13941         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
13942         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
13943         return (uintptr_t)ret_conv;
13944 }
13945 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13946         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
13947         intptr_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
13948         return ret_val;
13949 }
13950
13951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13952         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
13953         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
13954         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
13955         return (uintptr_t)ret_conv;
13956 }
13957
13958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13959         LDKShutdownScript o_conv;
13960         o_conv.inner = (void*)(o & (~1));
13961         o_conv.is_owned = (o & 1) || (o == 0);
13962         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13963         o_conv = ShutdownScript_clone(&o_conv);
13964         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
13965         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
13966         return (uintptr_t)ret_conv;
13967 }
13968
13969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13970         LDKInvalidShutdownScript e_conv;
13971         e_conv.inner = (void*)(e & (~1));
13972         e_conv.is_owned = (e & 1) || (e == 0);
13973         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13974         e_conv = InvalidShutdownScript_clone(&e_conv);
13975         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
13976         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
13977         return (uintptr_t)ret_conv;
13978 }
13979
13980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13981         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
13982         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
13983         return ret_val;
13984 }
13985
13986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13987         if ((_res & 1) != 0) return;
13988         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13989         CHECK_ACCESS(_res_ptr);
13990         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
13991         FREE((void*)_res);
13992         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
13993 }
13994
13995 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
13996         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
13997         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
13998         return (uintptr_t)ret_conv;
13999 }
14000 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14001         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
14002         intptr_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
14003         return ret_val;
14004 }
14005
14006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14007         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
14008         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
14009         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
14010         return (uintptr_t)ret_conv;
14011 }
14012
14013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
14014         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14015         *ret_conv = CResult_NoneErrorZ_ok();
14016         return (uintptr_t)ret_conv;
14017 }
14018
14019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14020         LDKIOError e_conv = LDKIOError_from_java(env, e);
14021         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14022         *ret_conv = CResult_NoneErrorZ_err(e_conv);
14023         return (uintptr_t)ret_conv;
14024 }
14025
14026 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14027         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
14028         jboolean ret_val = CResult_NoneErrorZ_is_ok(o_conv);
14029         return ret_val;
14030 }
14031
14032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14033         if ((_res & 1) != 0) return;
14034         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14035         CHECK_ACCESS(_res_ptr);
14036         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
14037         FREE((void*)_res);
14038         CResult_NoneErrorZ_free(_res_conv);
14039 }
14040
14041 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
14042         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14043         *ret_conv = CResult_NoneErrorZ_clone(arg);
14044         return (uintptr_t)ret_conv;
14045 }
14046 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14047         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
14048         intptr_t ret_val = CResult_NoneErrorZ_clone_ptr(arg_conv);
14049         return ret_val;
14050 }
14051
14052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14053         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
14054         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
14055         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
14056         return (uintptr_t)ret_conv;
14057 }
14058
14059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14060         LDKRouteHop o_conv;
14061         o_conv.inner = (void*)(o & (~1));
14062         o_conv.is_owned = (o & 1) || (o == 0);
14063         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14064         o_conv = RouteHop_clone(&o_conv);
14065         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14066         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
14067         return (uintptr_t)ret_conv;
14068 }
14069
14070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14071         LDKDecodeError e_conv;
14072         e_conv.inner = (void*)(e & (~1));
14073         e_conv.is_owned = (e & 1) || (e == 0);
14074         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14075         e_conv = DecodeError_clone(&e_conv);
14076         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14077         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
14078         return (uintptr_t)ret_conv;
14079 }
14080
14081 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14082         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
14083         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
14084         return ret_val;
14085 }
14086
14087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14088         if ((_res & 1) != 0) return;
14089         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14090         CHECK_ACCESS(_res_ptr);
14091         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
14092         FREE((void*)_res);
14093         CResult_RouteHopDecodeErrorZ_free(_res_conv);
14094 }
14095
14096 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
14097         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14098         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
14099         return (uintptr_t)ret_conv;
14100 }
14101 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14102         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
14103         intptr_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
14104         return ret_val;
14105 }
14106
14107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14108         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
14109         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
14110         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
14111         return (uintptr_t)ret_conv;
14112 }
14113
14114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14115         LDKCVec_RouteHopZ _res_constr;
14116         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14117         if (_res_constr.datalen > 0)
14118                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14119         else
14120                 _res_constr.data = NULL;
14121         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14122         for (size_t k = 0; k < _res_constr.datalen; k++) {
14123                 int64_t _res_conv_10 = _res_vals[k];
14124                 LDKRouteHop _res_conv_10_conv;
14125                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
14126                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
14127                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
14128                 _res_constr.data[k] = _res_conv_10_conv;
14129         }
14130         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14131         CVec_RouteHopZ_free(_res_constr);
14132 }
14133
14134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
14135         LDKCVec_CVec_RouteHopZZ _res_constr;
14136         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14137         if (_res_constr.datalen > 0)
14138                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
14139         else
14140                 _res_constr.data = NULL;
14141         for (size_t m = 0; m < _res_constr.datalen; m++) {
14142                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
14143                 LDKCVec_RouteHopZ _res_conv_12_constr;
14144                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
14145                 if (_res_conv_12_constr.datalen > 0)
14146                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14147                 else
14148                         _res_conv_12_constr.data = NULL;
14149                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
14150                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
14151                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
14152                         LDKRouteHop _res_conv_12_conv_10_conv;
14153                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
14154                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
14155                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
14156                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
14157                 }
14158                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
14159                 _res_constr.data[m] = _res_conv_12_constr;
14160         }
14161         CVec_CVec_RouteHopZZ_free(_res_constr);
14162 }
14163
14164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14165         LDKRoute o_conv;
14166         o_conv.inner = (void*)(o & (~1));
14167         o_conv.is_owned = (o & 1) || (o == 0);
14168         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14169         o_conv = Route_clone(&o_conv);
14170         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14171         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
14172         return (uintptr_t)ret_conv;
14173 }
14174
14175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14176         LDKDecodeError e_conv;
14177         e_conv.inner = (void*)(e & (~1));
14178         e_conv.is_owned = (e & 1) || (e == 0);
14179         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14180         e_conv = DecodeError_clone(&e_conv);
14181         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14182         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
14183         return (uintptr_t)ret_conv;
14184 }
14185
14186 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14187         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
14188         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
14189         return ret_val;
14190 }
14191
14192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14193         if ((_res & 1) != 0) return;
14194         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14195         CHECK_ACCESS(_res_ptr);
14196         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
14197         FREE((void*)_res);
14198         CResult_RouteDecodeErrorZ_free(_res_conv);
14199 }
14200
14201 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
14202         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14203         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
14204         return (uintptr_t)ret_conv;
14205 }
14206 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14207         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
14208         intptr_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
14209         return ret_val;
14210 }
14211
14212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14213         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
14214         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14215         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
14216         return (uintptr_t)ret_conv;
14217 }
14218
14219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14220         LDKRouteParameters o_conv;
14221         o_conv.inner = (void*)(o & (~1));
14222         o_conv.is_owned = (o & 1) || (o == 0);
14223         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14224         o_conv = RouteParameters_clone(&o_conv);
14225         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14226         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
14227         return (uintptr_t)ret_conv;
14228 }
14229
14230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14231         LDKDecodeError e_conv;
14232         e_conv.inner = (void*)(e & (~1));
14233         e_conv.is_owned = (e & 1) || (e == 0);
14234         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14235         e_conv = DecodeError_clone(&e_conv);
14236         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14237         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
14238         return (uintptr_t)ret_conv;
14239 }
14240
14241 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14242         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
14243         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
14244         return ret_val;
14245 }
14246
14247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14248         if ((_res & 1) != 0) return;
14249         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14250         CHECK_ACCESS(_res_ptr);
14251         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
14252         FREE((void*)_res);
14253         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
14254 }
14255
14256 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
14257         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14258         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
14259         return (uintptr_t)ret_conv;
14260 }
14261 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14262         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
14263         intptr_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
14264         return ret_val;
14265 }
14266
14267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14268         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
14269         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
14270         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
14271         return (uintptr_t)ret_conv;
14272 }
14273
14274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14275         LDKCVec_RouteHintZ _res_constr;
14276         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14277         if (_res_constr.datalen > 0)
14278                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
14279         else
14280                 _res_constr.data = NULL;
14281         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14282         for (size_t l = 0; l < _res_constr.datalen; l++) {
14283                 int64_t _res_conv_11 = _res_vals[l];
14284                 LDKRouteHint _res_conv_11_conv;
14285                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
14286                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
14287                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
14288                 _res_constr.data[l] = _res_conv_11_conv;
14289         }
14290         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14291         CVec_RouteHintZ_free(_res_constr);
14292 }
14293
14294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
14295         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14296         *ret_copy = COption_u64Z_some(o);
14297         uintptr_t ret_ref = (uintptr_t)ret_copy;
14298         return ret_ref;
14299 }
14300
14301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
14302         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14303         *ret_copy = COption_u64Z_none();
14304         uintptr_t ret_ref = (uintptr_t)ret_copy;
14305         return ret_ref;
14306 }
14307
14308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14309         if ((_res & 1) != 0) return;
14310         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14311         CHECK_ACCESS(_res_ptr);
14312         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
14313         FREE((void*)_res);
14314         COption_u64Z_free(_res_conv);
14315 }
14316
14317 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
14318         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14319         *ret_copy = COption_u64Z_clone(arg);
14320 uintptr_t ret_ref = (uintptr_t)ret_copy;
14321         return ret_ref;
14322 }
14323 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14324         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
14325         intptr_t ret_val = COption_u64Z_clone_ptr(arg_conv);
14326         return ret_val;
14327 }
14328
14329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14330         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
14331         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
14332         *ret_copy = COption_u64Z_clone(orig_conv);
14333         uintptr_t ret_ref = (uintptr_t)ret_copy;
14334         return ret_ref;
14335 }
14336
14337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14338         LDKPayee o_conv;
14339         o_conv.inner = (void*)(o & (~1));
14340         o_conv.is_owned = (o & 1) || (o == 0);
14341         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14342         o_conv = Payee_clone(&o_conv);
14343         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
14344         *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
14345         return (uintptr_t)ret_conv;
14346 }
14347
14348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14349         LDKDecodeError e_conv;
14350         e_conv.inner = (void*)(e & (~1));
14351         e_conv.is_owned = (e & 1) || (e == 0);
14352         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14353         e_conv = DecodeError_clone(&e_conv);
14354         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
14355         *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
14356         return (uintptr_t)ret_conv;
14357 }
14358
14359 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14360         LDKCResult_PayeeDecodeErrorZ* o_conv = (LDKCResult_PayeeDecodeErrorZ*)(o & ~1);
14361         jboolean ret_val = CResult_PayeeDecodeErrorZ_is_ok(o_conv);
14362         return ret_val;
14363 }
14364
14365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14366         if ((_res & 1) != 0) return;
14367         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14368         CHECK_ACCESS(_res_ptr);
14369         LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
14370         FREE((void*)_res);
14371         CResult_PayeeDecodeErrorZ_free(_res_conv);
14372 }
14373
14374 static inline uintptr_t CResult_PayeeDecodeErrorZ_clone_ptr(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR arg) {
14375         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
14376         *ret_conv = CResult_PayeeDecodeErrorZ_clone(arg);
14377         return (uintptr_t)ret_conv;
14378 }
14379 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14380         LDKCResult_PayeeDecodeErrorZ* arg_conv = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
14381         intptr_t ret_val = CResult_PayeeDecodeErrorZ_clone_ptr(arg_conv);
14382         return ret_val;
14383 }
14384
14385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14386         LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
14387         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
14388         *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
14389         return (uintptr_t)ret_conv;
14390 }
14391
14392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14393         LDKCVec_RouteHintHopZ _res_constr;
14394         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14395         if (_res_constr.datalen > 0)
14396                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
14397         else
14398                 _res_constr.data = NULL;
14399         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14400         for (size_t o = 0; o < _res_constr.datalen; o++) {
14401                 int64_t _res_conv_14 = _res_vals[o];
14402                 LDKRouteHintHop _res_conv_14_conv;
14403                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
14404                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
14405                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
14406                 _res_constr.data[o] = _res_conv_14_conv;
14407         }
14408         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14409         CVec_RouteHintHopZ_free(_res_constr);
14410 }
14411
14412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14413         LDKRouteHint o_conv;
14414         o_conv.inner = (void*)(o & (~1));
14415         o_conv.is_owned = (o & 1) || (o == 0);
14416         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14417         o_conv = RouteHint_clone(&o_conv);
14418         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
14419         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
14420         return (uintptr_t)ret_conv;
14421 }
14422
14423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14424         LDKDecodeError e_conv;
14425         e_conv.inner = (void*)(e & (~1));
14426         e_conv.is_owned = (e & 1) || (e == 0);
14427         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14428         e_conv = DecodeError_clone(&e_conv);
14429         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
14430         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
14431         return (uintptr_t)ret_conv;
14432 }
14433
14434 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14435         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
14436         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
14437         return ret_val;
14438 }
14439
14440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14441         if ((_res & 1) != 0) return;
14442         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14443         CHECK_ACCESS(_res_ptr);
14444         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
14445         FREE((void*)_res);
14446         CResult_RouteHintDecodeErrorZ_free(_res_conv);
14447 }
14448
14449 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
14450         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
14451         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
14452         return (uintptr_t)ret_conv;
14453 }
14454 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14455         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
14456         intptr_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
14457         return ret_val;
14458 }
14459
14460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14461         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
14462         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
14463         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
14464         return (uintptr_t)ret_conv;
14465 }
14466
14467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14468         LDKRouteHintHop o_conv;
14469         o_conv.inner = (void*)(o & (~1));
14470         o_conv.is_owned = (o & 1) || (o == 0);
14471         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14472         o_conv = RouteHintHop_clone(&o_conv);
14473         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
14474         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
14475         return (uintptr_t)ret_conv;
14476 }
14477
14478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14479         LDKDecodeError e_conv;
14480         e_conv.inner = (void*)(e & (~1));
14481         e_conv.is_owned = (e & 1) || (e == 0);
14482         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14483         e_conv = DecodeError_clone(&e_conv);
14484         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
14485         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
14486         return (uintptr_t)ret_conv;
14487 }
14488
14489 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14490         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
14491         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
14492         return ret_val;
14493 }
14494
14495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14496         if ((_res & 1) != 0) return;
14497         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14498         CHECK_ACCESS(_res_ptr);
14499         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
14500         FREE((void*)_res);
14501         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
14502 }
14503
14504 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
14505         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
14506         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
14507         return (uintptr_t)ret_conv;
14508 }
14509 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14510         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
14511         intptr_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
14512         return ret_val;
14513 }
14514
14515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14516         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
14517         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
14518         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
14519         return (uintptr_t)ret_conv;
14520 }
14521
14522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14523         LDKCVec_ChannelDetailsZ _res_constr;
14524         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14525         if (_res_constr.datalen > 0)
14526                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14527         else
14528                 _res_constr.data = NULL;
14529         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14530         for (size_t q = 0; q < _res_constr.datalen; q++) {
14531                 int64_t _res_conv_16 = _res_vals[q];
14532                 LDKChannelDetails _res_conv_16_conv;
14533                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14534                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14535                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
14536                 _res_constr.data[q] = _res_conv_16_conv;
14537         }
14538         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14539         CVec_ChannelDetailsZ_free(_res_constr);
14540 }
14541
14542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14543         LDKRoute o_conv;
14544         o_conv.inner = (void*)(o & (~1));
14545         o_conv.is_owned = (o & 1) || (o == 0);
14546         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14547         o_conv = Route_clone(&o_conv);
14548         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14549         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
14550         return (uintptr_t)ret_conv;
14551 }
14552
14553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14554         LDKLightningError e_conv;
14555         e_conv.inner = (void*)(e & (~1));
14556         e_conv.is_owned = (e & 1) || (e == 0);
14557         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14558         e_conv = LightningError_clone(&e_conv);
14559         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14560         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
14561         return (uintptr_t)ret_conv;
14562 }
14563
14564 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14565         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
14566         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
14567         return ret_val;
14568 }
14569
14570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14571         if ((_res & 1) != 0) return;
14572         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14573         CHECK_ACCESS(_res_ptr);
14574         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
14575         FREE((void*)_res);
14576         CResult_RouteLightningErrorZ_free(_res_conv);
14577 }
14578
14579 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
14580         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14581         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
14582         return (uintptr_t)ret_conv;
14583 }
14584 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14585         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
14586         intptr_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
14587         return ret_val;
14588 }
14589
14590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14591         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
14592         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14593         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
14594         return (uintptr_t)ret_conv;
14595 }
14596
14597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14598         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14599         CHECK_ACCESS(o_ptr);
14600         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
14601         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
14602         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
14603         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
14604         return (uintptr_t)ret_conv;
14605 }
14606
14607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14608         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
14609         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
14610         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
14611         return (uintptr_t)ret_conv;
14612 }
14613
14614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14615         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
14616         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
14617         return ret_val;
14618 }
14619
14620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14621         if ((_res & 1) != 0) return;
14622         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14623         CHECK_ACCESS(_res_ptr);
14624         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
14625         FREE((void*)_res);
14626         CResult_TxOutAccessErrorZ_free(_res_conv);
14627 }
14628
14629 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
14630         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
14631         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
14632         return (uintptr_t)ret_conv;
14633 }
14634 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14635         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
14636         intptr_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
14637         return ret_val;
14638 }
14639
14640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14641         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
14642         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
14643         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
14644         return (uintptr_t)ret_conv;
14645 }
14646
14647 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
14648         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
14649         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
14650         return ((uintptr_t)ret_conv);
14651 }
14652 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14653         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
14654         intptr_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
14655         return ret_val;
14656 }
14657
14658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14659         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
14660         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
14661         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
14662         return ((uintptr_t)ret_conv);
14663 }
14664
14665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, intptr_t a, int8_tArray b) {
14666         LDKTransaction b_ref;
14667         b_ref.datalen = (*env)->GetArrayLength(env, b);
14668         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
14669         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
14670         b_ref.data_is_owned = true;
14671         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
14672         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
14673         return ((uintptr_t)ret_conv);
14674 }
14675
14676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14677         if ((_res & 1) != 0) return;
14678         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14679         CHECK_ACCESS(_res_ptr);
14680         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
14681         FREE((void*)_res);
14682         C2Tuple_usizeTransactionZ_free(_res_conv);
14683 }
14684
14685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14686         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
14687         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14688         if (_res_constr.datalen > 0)
14689                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
14690         else
14691                 _res_constr.data = NULL;
14692         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14693         for (size_t c = 0; c < _res_constr.datalen; c++) {
14694                 int64_t _res_conv_28 = _res_vals[c];
14695                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
14696                 CHECK_ACCESS(_res_conv_28_ptr);
14697                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
14698                 FREE((void*)_res_conv_28);
14699                 _res_constr.data[c] = _res_conv_28_conv;
14700         }
14701         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14702         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
14703 }
14704
14705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
14706         LDKCVec_TxidZ _res_constr;
14707         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14708         if (_res_constr.datalen > 0)
14709                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
14710         else
14711                 _res_constr.data = NULL;
14712         for (size_t i = 0; i < _res_constr.datalen; i++) {
14713                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
14714                 LDKThirtyTwoBytes _res_conv_8_ref;
14715                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
14716                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
14717                 _res_constr.data[i] = _res_conv_8_ref;
14718         }
14719         CVec_TxidZ_free(_res_constr);
14720 }
14721
14722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
14723         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
14724         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
14725         return (uintptr_t)ret_conv;
14726 }
14727
14728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
14729         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
14730         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
14731         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
14732         return (uintptr_t)ret_conv;
14733 }
14734
14735 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14736         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
14737         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
14738         return ret_val;
14739 }
14740
14741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14742         if ((_res & 1) != 0) return;
14743         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14744         CHECK_ACCESS(_res_ptr);
14745         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
14746         FREE((void*)_res);
14747         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
14748 }
14749
14750 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
14751         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
14752         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
14753         return (uintptr_t)ret_conv;
14754 }
14755 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14756         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
14757         intptr_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
14758         return ret_val;
14759 }
14760
14761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14762         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
14763         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
14764         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
14765         return (uintptr_t)ret_conv;
14766 }
14767
14768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14769         LDKCVec_MonitorEventZ _res_constr;
14770         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14771         if (_res_constr.datalen > 0)
14772                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
14773         else
14774                 _res_constr.data = NULL;
14775         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14776         for (size_t o = 0; o < _res_constr.datalen; o++) {
14777                 int64_t _res_conv_14 = _res_vals[o];
14778                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
14779                 CHECK_ACCESS(_res_conv_14_ptr);
14780                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
14781                 FREE((void*)_res_conv_14);
14782                 _res_constr.data[o] = _res_conv_14_conv;
14783         }
14784         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14785         CVec_MonitorEventZ_free(_res_constr);
14786 }
14787
14788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
14789         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14790         CHECK_ACCESS(o_ptr);
14791         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
14792         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
14793         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
14794         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
14795         uintptr_t ret_ref = (uintptr_t)ret_copy;
14796         return ret_ref;
14797 }
14798
14799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
14800         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
14801         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
14802         uintptr_t ret_ref = (uintptr_t)ret_copy;
14803         return ret_ref;
14804 }
14805
14806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14807         if ((_res & 1) != 0) return;
14808         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14809         CHECK_ACCESS(_res_ptr);
14810         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
14811         FREE((void*)_res);
14812         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
14813 }
14814
14815 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
14816         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
14817         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
14818 uintptr_t ret_ref = (uintptr_t)ret_copy;
14819         return ret_ref;
14820 }
14821 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14822         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
14823         intptr_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
14824         return ret_val;
14825 }
14826
14827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14828         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
14829         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
14830         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
14831         uintptr_t ret_ref = (uintptr_t)ret_copy;
14832         return ret_ref;
14833 }
14834
14835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
14836         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14837         CHECK_ACCESS(o_ptr);
14838         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
14839         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
14840         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
14841         *ret_copy = COption_ClosureReasonZ_some(o_conv);
14842         uintptr_t ret_ref = (uintptr_t)ret_copy;
14843         return ret_ref;
14844 }
14845
14846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
14847         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
14848         *ret_copy = COption_ClosureReasonZ_none();
14849         uintptr_t ret_ref = (uintptr_t)ret_copy;
14850         return ret_ref;
14851 }
14852
14853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14854         if ((_res & 1) != 0) return;
14855         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14856         CHECK_ACCESS(_res_ptr);
14857         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
14858         FREE((void*)_res);
14859         COption_ClosureReasonZ_free(_res_conv);
14860 }
14861
14862 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
14863         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
14864         *ret_copy = COption_ClosureReasonZ_clone(arg);
14865 uintptr_t ret_ref = (uintptr_t)ret_copy;
14866         return ret_ref;
14867 }
14868 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14869         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
14870         intptr_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
14871         return ret_val;
14872 }
14873
14874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14875         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
14876         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
14877         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
14878         uintptr_t ret_ref = (uintptr_t)ret_copy;
14879         return ret_ref;
14880 }
14881
14882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14883         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14884         CHECK_ACCESS(o_ptr);
14885         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
14886         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
14887         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
14888         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
14889         return (uintptr_t)ret_conv;
14890 }
14891
14892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14893         LDKDecodeError e_conv;
14894         e_conv.inner = (void*)(e & (~1));
14895         e_conv.is_owned = (e & 1) || (e == 0);
14896         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14897         e_conv = DecodeError_clone(&e_conv);
14898         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
14899         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
14900         return (uintptr_t)ret_conv;
14901 }
14902
14903 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14904         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
14905         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
14906         return ret_val;
14907 }
14908
14909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14910         if ((_res & 1) != 0) return;
14911         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14912         CHECK_ACCESS(_res_ptr);
14913         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
14914         FREE((void*)_res);
14915         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
14916 }
14917
14918 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
14919         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
14920         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
14921         return (uintptr_t)ret_conv;
14922 }
14923 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14924         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
14925         intptr_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
14926         return ret_val;
14927 }
14928
14929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14930         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
14931         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
14932         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
14933         return (uintptr_t)ret_conv;
14934 }
14935
14936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
14937         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14938         CHECK_ACCESS(o_ptr);
14939         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
14940         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
14941         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
14942         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
14943         uintptr_t ret_ref = (uintptr_t)ret_copy;
14944         return ret_ref;
14945 }
14946
14947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
14948         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
14949         *ret_copy = COption_NetworkUpdateZ_none();
14950         uintptr_t ret_ref = (uintptr_t)ret_copy;
14951         return ret_ref;
14952 }
14953
14954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14955         if ((_res & 1) != 0) return;
14956         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14957         CHECK_ACCESS(_res_ptr);
14958         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
14959         FREE((void*)_res);
14960         COption_NetworkUpdateZ_free(_res_conv);
14961 }
14962
14963 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
14964         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
14965         *ret_copy = COption_NetworkUpdateZ_clone(arg);
14966 uintptr_t ret_ref = (uintptr_t)ret_copy;
14967         return ret_ref;
14968 }
14969 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14970         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
14971         intptr_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
14972         return ret_val;
14973 }
14974
14975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14976         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
14977         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
14978         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
14979         uintptr_t ret_ref = (uintptr_t)ret_copy;
14980         return ret_ref;
14981 }
14982
14983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14984         LDKCVec_SpendableOutputDescriptorZ _res_constr;
14985         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14986         if (_res_constr.datalen > 0)
14987                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
14988         else
14989                 _res_constr.data = NULL;
14990         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14991         for (size_t b = 0; b < _res_constr.datalen; b++) {
14992                 int64_t _res_conv_27 = _res_vals[b];
14993                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
14994                 CHECK_ACCESS(_res_conv_27_ptr);
14995                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
14996                 FREE((void*)_res_conv_27);
14997                 _res_constr.data[b] = _res_conv_27_conv;
14998         }
14999         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15000         CVec_SpendableOutputDescriptorZ_free(_res_constr);
15001 }
15002
15003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15004         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15005         CHECK_ACCESS(o_ptr);
15006         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
15007         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
15008         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15009         *ret_copy = COption_EventZ_some(o_conv);
15010         uintptr_t ret_ref = (uintptr_t)ret_copy;
15011         return ret_ref;
15012 }
15013
15014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
15015         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15016         *ret_copy = COption_EventZ_none();
15017         uintptr_t ret_ref = (uintptr_t)ret_copy;
15018         return ret_ref;
15019 }
15020
15021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15022         if ((_res & 1) != 0) return;
15023         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15024         CHECK_ACCESS(_res_ptr);
15025         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
15026         FREE((void*)_res);
15027         COption_EventZ_free(_res_conv);
15028 }
15029
15030 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
15031         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15032         *ret_copy = COption_EventZ_clone(arg);
15033 uintptr_t ret_ref = (uintptr_t)ret_copy;
15034         return ret_ref;
15035 }
15036 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15037         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
15038         intptr_t ret_val = COption_EventZ_clone_ptr(arg_conv);
15039         return ret_val;
15040 }
15041
15042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15043         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
15044         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
15045         *ret_copy = COption_EventZ_clone(orig_conv);
15046         uintptr_t ret_ref = (uintptr_t)ret_copy;
15047         return ret_ref;
15048 }
15049
15050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15051         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15052         CHECK_ACCESS(o_ptr);
15053         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
15054         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
15055         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15056         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
15057         return (uintptr_t)ret_conv;
15058 }
15059
15060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15061         LDKDecodeError e_conv;
15062         e_conv.inner = (void*)(e & (~1));
15063         e_conv.is_owned = (e & 1) || (e == 0);
15064         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15065         e_conv = DecodeError_clone(&e_conv);
15066         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15067         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
15068         return (uintptr_t)ret_conv;
15069 }
15070
15071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15072         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
15073         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
15074         return ret_val;
15075 }
15076
15077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15078         if ((_res & 1) != 0) return;
15079         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15080         CHECK_ACCESS(_res_ptr);
15081         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
15082         FREE((void*)_res);
15083         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
15084 }
15085
15086 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
15087         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15088         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
15089         return (uintptr_t)ret_conv;
15090 }
15091 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15092         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
15093         intptr_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
15094         return ret_val;
15095 }
15096
15097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15098         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
15099         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
15100         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
15101         return (uintptr_t)ret_conv;
15102 }
15103
15104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15105         LDKCVec_MessageSendEventZ _res_constr;
15106         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15107         if (_res_constr.datalen > 0)
15108                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
15109         else
15110                 _res_constr.data = NULL;
15111         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15112         for (size_t s = 0; s < _res_constr.datalen; s++) {
15113                 int64_t _res_conv_18 = _res_vals[s];
15114                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
15115                 CHECK_ACCESS(_res_conv_18_ptr);
15116                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
15117                 FREE((void*)_res_conv_18);
15118                 _res_constr.data[s] = _res_conv_18_conv;
15119         }
15120         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15121         CVec_MessageSendEventZ_free(_res_constr);
15122 }
15123
15124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15125         LDKScoringParameters o_conv;
15126         o_conv.inner = (void*)(o & (~1));
15127         o_conv.is_owned = (o & 1) || (o == 0);
15128         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15129         // Warning: we need a move here but no clone is available for LDKScoringParameters
15130         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
15131         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
15132         return (uintptr_t)ret_conv;
15133 }
15134
15135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15136         LDKDecodeError e_conv;
15137         e_conv.inner = (void*)(e & (~1));
15138         e_conv.is_owned = (e & 1) || (e == 0);
15139         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15140         e_conv = DecodeError_clone(&e_conv);
15141         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
15142         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
15143         return (uintptr_t)ret_conv;
15144 }
15145
15146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15147         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
15148         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
15149         return ret_val;
15150 }
15151
15152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15153         if ((_res & 1) != 0) return;
15154         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15155         CHECK_ACCESS(_res_ptr);
15156         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
15157         FREE((void*)_res);
15158         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
15159 }
15160
15161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15162         LDKScorer o_conv;
15163         o_conv.inner = (void*)(o & (~1));
15164         o_conv.is_owned = (o & 1) || (o == 0);
15165         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15166         // Warning: we need a move here but no clone is available for LDKScorer
15167         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
15168         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
15169         return (uintptr_t)ret_conv;
15170 }
15171
15172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15173         LDKDecodeError e_conv;
15174         e_conv.inner = (void*)(e & (~1));
15175         e_conv.is_owned = (e & 1) || (e == 0);
15176         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15177         e_conv = DecodeError_clone(&e_conv);
15178         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
15179         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
15180         return (uintptr_t)ret_conv;
15181 }
15182
15183 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15184         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
15185         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
15186         return ret_val;
15187 }
15188
15189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15190         if ((_res & 1) != 0) return;
15191         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15192         CHECK_ACCESS(_res_ptr);
15193         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
15194         FREE((void*)_res);
15195         CResult_ScorerDecodeErrorZ_free(_res_conv);
15196 }
15197
15198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15199         LDKInitFeatures o_conv;
15200         o_conv.inner = (void*)(o & (~1));
15201         o_conv.is_owned = (o & 1) || (o == 0);
15202         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15203         o_conv = InitFeatures_clone(&o_conv);
15204         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
15205         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
15206         return (uintptr_t)ret_conv;
15207 }
15208
15209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15210         LDKDecodeError e_conv;
15211         e_conv.inner = (void*)(e & (~1));
15212         e_conv.is_owned = (e & 1) || (e == 0);
15213         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15214         e_conv = DecodeError_clone(&e_conv);
15215         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
15216         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
15217         return (uintptr_t)ret_conv;
15218 }
15219
15220 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15221         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
15222         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
15223         return ret_val;
15224 }
15225
15226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15227         if ((_res & 1) != 0) return;
15228         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15229         CHECK_ACCESS(_res_ptr);
15230         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
15231         FREE((void*)_res);
15232         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
15233 }
15234
15235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15236         LDKChannelFeatures o_conv;
15237         o_conv.inner = (void*)(o & (~1));
15238         o_conv.is_owned = (o & 1) || (o == 0);
15239         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15240         o_conv = ChannelFeatures_clone(&o_conv);
15241         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
15242         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
15243         return (uintptr_t)ret_conv;
15244 }
15245
15246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15247         LDKDecodeError e_conv;
15248         e_conv.inner = (void*)(e & (~1));
15249         e_conv.is_owned = (e & 1) || (e == 0);
15250         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15251         e_conv = DecodeError_clone(&e_conv);
15252         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
15253         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
15254         return (uintptr_t)ret_conv;
15255 }
15256
15257 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15258         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
15259         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
15260         return ret_val;
15261 }
15262
15263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15264         if ((_res & 1) != 0) return;
15265         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15266         CHECK_ACCESS(_res_ptr);
15267         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
15268         FREE((void*)_res);
15269         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
15270 }
15271
15272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15273         LDKNodeFeatures o_conv;
15274         o_conv.inner = (void*)(o & (~1));
15275         o_conv.is_owned = (o & 1) || (o == 0);
15276         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15277         o_conv = NodeFeatures_clone(&o_conv);
15278         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
15279         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
15280         return (uintptr_t)ret_conv;
15281 }
15282
15283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15284         LDKDecodeError e_conv;
15285         e_conv.inner = (void*)(e & (~1));
15286         e_conv.is_owned = (e & 1) || (e == 0);
15287         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15288         e_conv = DecodeError_clone(&e_conv);
15289         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
15290         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
15291         return (uintptr_t)ret_conv;
15292 }
15293
15294 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15295         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
15296         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
15297         return ret_val;
15298 }
15299
15300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15301         if ((_res & 1) != 0) return;
15302         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15303         CHECK_ACCESS(_res_ptr);
15304         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
15305         FREE((void*)_res);
15306         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
15307 }
15308
15309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15310         LDKInvoiceFeatures o_conv;
15311         o_conv.inner = (void*)(o & (~1));
15312         o_conv.is_owned = (o & 1) || (o == 0);
15313         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15314         o_conv = InvoiceFeatures_clone(&o_conv);
15315         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
15316         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
15317         return (uintptr_t)ret_conv;
15318 }
15319
15320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15321         LDKDecodeError e_conv;
15322         e_conv.inner = (void*)(e & (~1));
15323         e_conv.is_owned = (e & 1) || (e == 0);
15324         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15325         e_conv = DecodeError_clone(&e_conv);
15326         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
15327         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
15328         return (uintptr_t)ret_conv;
15329 }
15330
15331 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15332         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
15333         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
15334         return ret_val;
15335 }
15336
15337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15338         if ((_res & 1) != 0) return;
15339         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15340         CHECK_ACCESS(_res_ptr);
15341         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
15342         FREE((void*)_res);
15343         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
15344 }
15345
15346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15347         LDKChannelTypeFeatures o_conv;
15348         o_conv.inner = (void*)(o & (~1));
15349         o_conv.is_owned = (o & 1) || (o == 0);
15350         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15351         o_conv = ChannelTypeFeatures_clone(&o_conv);
15352         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
15353         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
15354         return (uintptr_t)ret_conv;
15355 }
15356
15357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15358         LDKDecodeError e_conv;
15359         e_conv.inner = (void*)(e & (~1));
15360         e_conv.is_owned = (e & 1) || (e == 0);
15361         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15362         e_conv = DecodeError_clone(&e_conv);
15363         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
15364         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
15365         return (uintptr_t)ret_conv;
15366 }
15367
15368 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15369         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
15370         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
15371         return ret_val;
15372 }
15373
15374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15375         if ((_res & 1) != 0) return;
15376         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15377         CHECK_ACCESS(_res_ptr);
15378         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
15379         FREE((void*)_res);
15380         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
15381 }
15382
15383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15384         LDKDelayedPaymentOutputDescriptor o_conv;
15385         o_conv.inner = (void*)(o & (~1));
15386         o_conv.is_owned = (o & 1) || (o == 0);
15387         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15388         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
15389         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15390         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
15391         return (uintptr_t)ret_conv;
15392 }
15393
15394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15395         LDKDecodeError e_conv;
15396         e_conv.inner = (void*)(e & (~1));
15397         e_conv.is_owned = (e & 1) || (e == 0);
15398         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15399         e_conv = DecodeError_clone(&e_conv);
15400         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15401         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
15402         return (uintptr_t)ret_conv;
15403 }
15404
15405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15406         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
15407         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
15408         return ret_val;
15409 }
15410
15411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15412         if ((_res & 1) != 0) return;
15413         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15414         CHECK_ACCESS(_res_ptr);
15415         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
15416         FREE((void*)_res);
15417         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
15418 }
15419
15420 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15421         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15422         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
15423         return (uintptr_t)ret_conv;
15424 }
15425 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15426         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
15427         intptr_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15428         return ret_val;
15429 }
15430
15431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15432         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
15433         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15434         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
15435         return (uintptr_t)ret_conv;
15436 }
15437
15438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15439         LDKStaticPaymentOutputDescriptor o_conv;
15440         o_conv.inner = (void*)(o & (~1));
15441         o_conv.is_owned = (o & 1) || (o == 0);
15442         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15443         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
15444         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15445         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
15446         return (uintptr_t)ret_conv;
15447 }
15448
15449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15450         LDKDecodeError e_conv;
15451         e_conv.inner = (void*)(e & (~1));
15452         e_conv.is_owned = (e & 1) || (e == 0);
15453         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15454         e_conv = DecodeError_clone(&e_conv);
15455         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15456         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
15457         return (uintptr_t)ret_conv;
15458 }
15459
15460 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15461         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
15462         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
15463         return ret_val;
15464 }
15465
15466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15467         if ((_res & 1) != 0) return;
15468         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15469         CHECK_ACCESS(_res_ptr);
15470         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
15471         FREE((void*)_res);
15472         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
15473 }
15474
15475 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15476         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15477         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
15478         return (uintptr_t)ret_conv;
15479 }
15480 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15481         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
15482         intptr_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15483         return ret_val;
15484 }
15485
15486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15487         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
15488         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15489         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
15490         return (uintptr_t)ret_conv;
15491 }
15492
15493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15494         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15495         CHECK_ACCESS(o_ptr);
15496         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
15497         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
15498         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15499         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
15500         return (uintptr_t)ret_conv;
15501 }
15502
15503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15504         LDKDecodeError e_conv;
15505         e_conv.inner = (void*)(e & (~1));
15506         e_conv.is_owned = (e & 1) || (e == 0);
15507         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15508         e_conv = DecodeError_clone(&e_conv);
15509         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15510         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
15511         return (uintptr_t)ret_conv;
15512 }
15513
15514 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15515         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
15516         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
15517         return ret_val;
15518 }
15519
15520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15521         if ((_res & 1) != 0) return;
15522         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15523         CHECK_ACCESS(_res_ptr);
15524         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
15525         FREE((void*)_res);
15526         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
15527 }
15528
15529 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15530         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15531         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
15532         return (uintptr_t)ret_conv;
15533 }
15534 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15535         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
15536         intptr_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15537         return ret_val;
15538 }
15539
15540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15541         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
15542         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15543         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
15544         return (uintptr_t)ret_conv;
15545 }
15546
15547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
15548         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15549         *ret_conv = CResult_NoneNoneZ_ok();
15550         return (uintptr_t)ret_conv;
15551 }
15552
15553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
15554         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15555         *ret_conv = CResult_NoneNoneZ_err();
15556         return (uintptr_t)ret_conv;
15557 }
15558
15559 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15560         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
15561         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
15562         return ret_val;
15563 }
15564
15565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15566         if ((_res & 1) != 0) return;
15567         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15568         CHECK_ACCESS(_res_ptr);
15569         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
15570         FREE((void*)_res);
15571         CResult_NoneNoneZ_free(_res_conv);
15572 }
15573
15574 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
15575         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15576         *ret_conv = CResult_NoneNoneZ_clone(arg);
15577         return (uintptr_t)ret_conv;
15578 }
15579 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15580         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
15581         intptr_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
15582         return ret_val;
15583 }
15584
15585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15586         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
15587         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15588         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
15589         return (uintptr_t)ret_conv;
15590 }
15591
15592 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
15593         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15594         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
15595         return ((uintptr_t)ret_conv);
15596 }
15597 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15598         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
15599         intptr_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
15600         return ret_val;
15601 }
15602
15603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15604         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
15605         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15606         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
15607         return ((uintptr_t)ret_conv);
15608 }
15609
15610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
15611         LDKSignature a_ref;
15612         CHECK((*env)->GetArrayLength(env, a) == 64);
15613         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
15614         LDKCVec_SignatureZ b_constr;
15615         b_constr.datalen = (*env)->GetArrayLength(env, b);
15616         if (b_constr.datalen > 0)
15617                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15618         else
15619                 b_constr.data = NULL;
15620         for (size_t i = 0; i < b_constr.datalen; i++) {
15621                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
15622                 LDKSignature b_conv_8_ref;
15623                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
15624                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
15625                 b_constr.data[i] = b_conv_8_ref;
15626         }
15627         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15628         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
15629         return ((uintptr_t)ret_conv);
15630 }
15631
15632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15633         if ((_res & 1) != 0) return;
15634         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15635         CHECK_ACCESS(_res_ptr);
15636         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
15637         FREE((void*)_res);
15638         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
15639 }
15640
15641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15642         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15643         CHECK_ACCESS(o_ptr);
15644         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
15645         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
15646         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15647         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
15648         return (uintptr_t)ret_conv;
15649 }
15650
15651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
15652         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15653         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
15654         return (uintptr_t)ret_conv;
15655 }
15656
15657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15658         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
15659         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
15660         return ret_val;
15661 }
15662
15663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15664         if ((_res & 1) != 0) return;
15665         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15666         CHECK_ACCESS(_res_ptr);
15667         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
15668         FREE((void*)_res);
15669         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
15670 }
15671
15672 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
15673         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15674         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
15675         return (uintptr_t)ret_conv;
15676 }
15677 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15678         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
15679         intptr_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
15680         return ret_val;
15681 }
15682
15683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15684         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
15685         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15686         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
15687         return (uintptr_t)ret_conv;
15688 }
15689
15690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15691         LDKSignature o_ref;
15692         CHECK((*env)->GetArrayLength(env, o) == 64);
15693         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
15694         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15695         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
15696         return (uintptr_t)ret_conv;
15697 }
15698
15699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
15700         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15701         *ret_conv = CResult_SignatureNoneZ_err();
15702         return (uintptr_t)ret_conv;
15703 }
15704
15705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15706         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
15707         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
15708         return ret_val;
15709 }
15710
15711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15712         if ((_res & 1) != 0) return;
15713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15714         CHECK_ACCESS(_res_ptr);
15715         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
15716         FREE((void*)_res);
15717         CResult_SignatureNoneZ_free(_res_conv);
15718 }
15719
15720 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
15721         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15722         *ret_conv = CResult_SignatureNoneZ_clone(arg);
15723         return (uintptr_t)ret_conv;
15724 }
15725 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15726         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
15727         intptr_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
15728         return ret_val;
15729 }
15730
15731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15732         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
15733         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15734         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
15735         return (uintptr_t)ret_conv;
15736 }
15737
15738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15739         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15740         CHECK_ACCESS(o_ptr);
15741         LDKSign o_conv = *(LDKSign*)(o_ptr);
15742         if (o_conv.free == LDKSign_JCalls_free) {
15743                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15744                 LDKSign_JCalls_cloned(&o_conv);
15745         }
15746         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15747         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
15748         return (uintptr_t)ret_conv;
15749 }
15750
15751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15752         LDKDecodeError e_conv;
15753         e_conv.inner = (void*)(e & (~1));
15754         e_conv.is_owned = (e & 1) || (e == 0);
15755         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15756         e_conv = DecodeError_clone(&e_conv);
15757         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15758         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
15759         return (uintptr_t)ret_conv;
15760 }
15761
15762 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15763         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
15764         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
15765         return ret_val;
15766 }
15767
15768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15769         if ((_res & 1) != 0) return;
15770         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15771         CHECK_ACCESS(_res_ptr);
15772         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
15773         FREE((void*)_res);
15774         CResult_SignDecodeErrorZ_free(_res_conv);
15775 }
15776
15777 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
15778         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15779         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
15780         return (uintptr_t)ret_conv;
15781 }
15782 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15783         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
15784         intptr_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
15785         return ret_val;
15786 }
15787
15788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15789         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
15790         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15791         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
15792         return (uintptr_t)ret_conv;
15793 }
15794
15795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
15796         LDKCVec_u8Z _res_ref;
15797         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
15798         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
15799         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
15800         CVec_u8Z_free(_res_ref);
15801 }
15802
15803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15804         LDKRecoverableSignature o_ref;
15805         CHECK((*env)->GetArrayLength(env, o) == 68);
15806         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
15807         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15808         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
15809         return (uintptr_t)ret_conv;
15810 }
15811
15812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
15813         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15814         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
15815         return (uintptr_t)ret_conv;
15816 }
15817
15818 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15819         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
15820         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
15821         return ret_val;
15822 }
15823
15824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15825         if ((_res & 1) != 0) return;
15826         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15827         CHECK_ACCESS(_res_ptr);
15828         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
15829         FREE((void*)_res);
15830         CResult_RecoverableSignatureNoneZ_free(_res_conv);
15831 }
15832
15833 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
15834         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15835         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
15836         return (uintptr_t)ret_conv;
15837 }
15838 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15839         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
15840         intptr_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
15841         return ret_val;
15842 }
15843
15844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15845         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
15846         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15847         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
15848         return (uintptr_t)ret_conv;
15849 }
15850
15851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15852         LDKCVec_CVec_u8ZZ _res_constr;
15853         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15854         if (_res_constr.datalen > 0)
15855                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15856         else
15857                 _res_constr.data = NULL;
15858         for (size_t i = 0; i < _res_constr.datalen; i++) {
15859                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15860                 LDKCVec_u8Z _res_conv_8_ref;
15861                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
15862                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
15863                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
15864                 _res_constr.data[i] = _res_conv_8_ref;
15865         }
15866         CVec_CVec_u8ZZ_free(_res_constr);
15867 }
15868
15869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
15870         LDKCVec_CVec_u8ZZ o_constr;
15871         o_constr.datalen = (*env)->GetArrayLength(env, o);
15872         if (o_constr.datalen > 0)
15873                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15874         else
15875                 o_constr.data = NULL;
15876         for (size_t i = 0; i < o_constr.datalen; i++) {
15877                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
15878                 LDKCVec_u8Z o_conv_8_ref;
15879                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
15880                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
15881                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
15882                 o_constr.data[i] = o_conv_8_ref;
15883         }
15884         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15885         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
15886         return (uintptr_t)ret_conv;
15887 }
15888
15889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
15890         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15891         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
15892         return (uintptr_t)ret_conv;
15893 }
15894
15895 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15896         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
15897         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
15898         return ret_val;
15899 }
15900
15901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15902         if ((_res & 1) != 0) return;
15903         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15904         CHECK_ACCESS(_res_ptr);
15905         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
15906         FREE((void*)_res);
15907         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
15908 }
15909
15910 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
15911         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15912         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
15913         return (uintptr_t)ret_conv;
15914 }
15915 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15916         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
15917         intptr_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
15918         return ret_val;
15919 }
15920
15921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15922         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
15923         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15924         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
15925         return (uintptr_t)ret_conv;
15926 }
15927
15928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15929         LDKInMemorySigner o_conv;
15930         o_conv.inner = (void*)(o & (~1));
15931         o_conv.is_owned = (o & 1) || (o == 0);
15932         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15933         o_conv = InMemorySigner_clone(&o_conv);
15934         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15935         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
15936         return (uintptr_t)ret_conv;
15937 }
15938
15939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15940         LDKDecodeError e_conv;
15941         e_conv.inner = (void*)(e & (~1));
15942         e_conv.is_owned = (e & 1) || (e == 0);
15943         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15944         e_conv = DecodeError_clone(&e_conv);
15945         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15946         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
15947         return (uintptr_t)ret_conv;
15948 }
15949
15950 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15951         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
15952         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
15953         return ret_val;
15954 }
15955
15956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15957         if ((_res & 1) != 0) return;
15958         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15959         CHECK_ACCESS(_res_ptr);
15960         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
15961         FREE((void*)_res);
15962         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
15963 }
15964
15965 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
15966         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15967         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
15968         return (uintptr_t)ret_conv;
15969 }
15970 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15971         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
15972         intptr_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
15973         return ret_val;
15974 }
15975
15976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15977         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
15978         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15979         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
15980         return (uintptr_t)ret_conv;
15981 }
15982
15983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15984         LDKCVec_TxOutZ _res_constr;
15985         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15986         if (_res_constr.datalen > 0)
15987                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15988         else
15989                 _res_constr.data = NULL;
15990         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15991         for (size_t h = 0; h < _res_constr.datalen; h++) {
15992                 int64_t _res_conv_7 = _res_vals[h];
15993                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
15994                 CHECK_ACCESS(_res_conv_7_ptr);
15995                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
15996                 FREE((void*)_res_conv_7);
15997                 _res_constr.data[h] = _res_conv_7_conv;
15998         }
15999         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16000         CVec_TxOutZ_free(_res_constr);
16001 }
16002
16003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16004         LDKTransaction o_ref;
16005         o_ref.datalen = (*env)->GetArrayLength(env, o);
16006         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
16007         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
16008         o_ref.data_is_owned = true;
16009         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
16010         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
16011         return (uintptr_t)ret_conv;
16012 }
16013
16014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
16015         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
16016         *ret_conv = CResult_TransactionNoneZ_err();
16017         return (uintptr_t)ret_conv;
16018 }
16019
16020 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16021         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
16022         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
16023         return ret_val;
16024 }
16025
16026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16027         if ((_res & 1) != 0) return;
16028         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16029         CHECK_ACCESS(_res_ptr);
16030         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
16031         FREE((void*)_res);
16032         CResult_TransactionNoneZ_free(_res_conv);
16033 }
16034
16035 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
16036         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
16037         *ret_conv = CResult_TransactionNoneZ_clone(arg);
16038         return (uintptr_t)ret_conv;
16039 }
16040 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16041         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
16042         intptr_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
16043         return ret_val;
16044 }
16045
16046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16047         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
16048         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
16049         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
16050         return (uintptr_t)ret_conv;
16051 }
16052
16053 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
16054         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16055         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
16056         return ((uintptr_t)ret_conv);
16057 }
16058 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16059         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
16060         intptr_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
16061         return ret_val;
16062 }
16063
16064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16065         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
16066         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16067         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
16068         return ((uintptr_t)ret_conv);
16069 }
16070
16071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
16072         LDKThirtyTwoBytes a_ref;
16073         CHECK((*env)->GetArrayLength(env, a) == 32);
16074         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
16075         LDKChannelMonitor b_conv;
16076         b_conv.inner = (void*)(b & (~1));
16077         b_conv.is_owned = (b & 1) || (b == 0);
16078         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16079         b_conv = ChannelMonitor_clone(&b_conv);
16080         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16081         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
16082         return ((uintptr_t)ret_conv);
16083 }
16084
16085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16086         if ((_res & 1) != 0) return;
16087         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16088         CHECK_ACCESS(_res_ptr);
16089         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
16090         FREE((void*)_res);
16091         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
16092 }
16093
16094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16095         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
16096         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16097         if (_res_constr.datalen > 0)
16098                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
16099         else
16100                 _res_constr.data = NULL;
16101         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16102         for (size_t j = 0; j < _res_constr.datalen; j++) {
16103                 int64_t _res_conv_35 = _res_vals[j];
16104                 void* _res_conv_35_ptr = (void*)(((uintptr_t)_res_conv_35) & ~1);
16105                 CHECK_ACCESS(_res_conv_35_ptr);
16106                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
16107                 FREE((void*)_res_conv_35);
16108                 _res_constr.data[j] = _res_conv_35_conv;
16109         }
16110         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16111         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
16112 }
16113
16114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
16115         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
16116         o_constr.datalen = (*env)->GetArrayLength(env, o);
16117         if (o_constr.datalen > 0)
16118                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
16119         else
16120                 o_constr.data = NULL;
16121         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
16122         for (size_t j = 0; j < o_constr.datalen; j++) {
16123                 int64_t o_conv_35 = o_vals[j];
16124                 void* o_conv_35_ptr = (void*)(((uintptr_t)o_conv_35) & ~1);
16125                 CHECK_ACCESS(o_conv_35_ptr);
16126                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
16127                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o_conv_35) & ~1));
16128                 o_constr.data[j] = o_conv_35_conv;
16129         }
16130         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
16131         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
16132         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
16133         return (uintptr_t)ret_conv;
16134 }
16135
16136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16137         LDKIOError e_conv = LDKIOError_from_java(env, e);
16138         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
16139         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
16140         return (uintptr_t)ret_conv;
16141 }
16142
16143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16144         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
16145         jboolean ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
16146         return ret_val;
16147 }
16148
16149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16150         if ((_res & 1) != 0) return;
16151         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16152         CHECK_ACCESS(_res_ptr);
16153         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
16154         FREE((void*)_res);
16155         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
16156 }
16157
16158 static inline uintptr_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
16159         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
16160         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
16161         return (uintptr_t)ret_conv;
16162 }
16163 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16164         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
16165         intptr_t ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
16166         return ret_val;
16167 }
16168
16169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16170         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
16171         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
16172         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
16173         return (uintptr_t)ret_conv;
16174 }
16175
16176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
16177         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
16178         *ret_copy = COption_u16Z_some(o);
16179         uintptr_t ret_ref = (uintptr_t)ret_copy;
16180         return ret_ref;
16181 }
16182
16183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
16184         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
16185         *ret_copy = COption_u16Z_none();
16186         uintptr_t ret_ref = (uintptr_t)ret_copy;
16187         return ret_ref;
16188 }
16189
16190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16191         if ((_res & 1) != 0) return;
16192         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16193         CHECK_ACCESS(_res_ptr);
16194         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
16195         FREE((void*)_res);
16196         COption_u16Z_free(_res_conv);
16197 }
16198
16199 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
16200         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
16201         *ret_copy = COption_u16Z_clone(arg);
16202 uintptr_t ret_ref = (uintptr_t)ret_copy;
16203         return ret_ref;
16204 }
16205 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16206         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
16207         intptr_t ret_val = COption_u16Z_clone_ptr(arg_conv);
16208         return ret_val;
16209 }
16210
16211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16212         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
16213         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
16214         *ret_copy = COption_u16Z_clone(orig_conv);
16215         uintptr_t ret_ref = (uintptr_t)ret_copy;
16216         return ret_ref;
16217 }
16218
16219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
16220         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16221         *ret_conv = CResult_NoneAPIErrorZ_ok();
16222         return (uintptr_t)ret_conv;
16223 }
16224
16225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16226         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16227         CHECK_ACCESS(e_ptr);
16228         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16229         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16230         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16231         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
16232         return (uintptr_t)ret_conv;
16233 }
16234
16235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16236         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
16237         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
16238         return ret_val;
16239 }
16240
16241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16242         if ((_res & 1) != 0) return;
16243         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16244         CHECK_ACCESS(_res_ptr);
16245         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
16246         FREE((void*)_res);
16247         CResult_NoneAPIErrorZ_free(_res_conv);
16248 }
16249
16250 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
16251         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16252         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
16253         return (uintptr_t)ret_conv;
16254 }
16255 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16256         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
16257         intptr_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
16258         return ret_val;
16259 }
16260
16261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16262         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
16263         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
16264         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
16265         return (uintptr_t)ret_conv;
16266 }
16267
16268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16269         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
16270         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16271         if (_res_constr.datalen > 0)
16272                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
16273         else
16274                 _res_constr.data = NULL;
16275         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16276         for (size_t w = 0; w < _res_constr.datalen; w++) {
16277                 int64_t _res_conv_22 = _res_vals[w];
16278                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
16279                 CHECK_ACCESS(_res_conv_22_ptr);
16280                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
16281                 FREE((void*)_res_conv_22);
16282                 _res_constr.data[w] = _res_conv_22_conv;
16283         }
16284         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16285         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
16286 }
16287
16288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16289         LDKCVec_APIErrorZ _res_constr;
16290         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16291         if (_res_constr.datalen > 0)
16292                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
16293         else
16294                 _res_constr.data = NULL;
16295         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16296         for (size_t k = 0; k < _res_constr.datalen; k++) {
16297                 int64_t _res_conv_10 = _res_vals[k];
16298                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
16299                 CHECK_ACCESS(_res_conv_10_ptr);
16300                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
16301                 FREE((void*)_res_conv_10);
16302                 _res_constr.data[k] = _res_conv_10_conv;
16303         }
16304         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16305         CVec_APIErrorZ_free(_res_constr);
16306 }
16307
16308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16309         LDKThirtyTwoBytes o_ref;
16310         CHECK((*env)->GetArrayLength(env, o) == 32);
16311         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
16312         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
16313         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
16314         return (uintptr_t)ret_conv;
16315 }
16316
16317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16318         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16319         CHECK_ACCESS(e_ptr);
16320         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16321         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16322         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
16323         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
16324         return (uintptr_t)ret_conv;
16325 }
16326
16327 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16328         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
16329         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
16330         return ret_val;
16331 }
16332
16333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16334         if ((_res & 1) != 0) return;
16335         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16336         CHECK_ACCESS(_res_ptr);
16337         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
16338         FREE((void*)_res);
16339         CResult__u832APIErrorZ_free(_res_conv);
16340 }
16341
16342 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
16343         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
16344         *ret_conv = CResult__u832APIErrorZ_clone(arg);
16345         return (uintptr_t)ret_conv;
16346 }
16347 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16348         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
16349         intptr_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
16350         return ret_val;
16351 }
16352
16353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16354         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
16355         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
16356         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
16357         return (uintptr_t)ret_conv;
16358 }
16359
16360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16361         LDKThirtyTwoBytes o_ref;
16362         CHECK((*env)->GetArrayLength(env, o) == 32);
16363         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
16364         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
16365         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
16366         return (uintptr_t)ret_conv;
16367 }
16368
16369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16370         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16371         CHECK_ACCESS(e_ptr);
16372         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
16373         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
16374         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
16375         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
16376         return (uintptr_t)ret_conv;
16377 }
16378
16379 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16380         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
16381         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
16382         return ret_val;
16383 }
16384
16385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16386         if ((_res & 1) != 0) return;
16387         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16388         CHECK_ACCESS(_res_ptr);
16389         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
16390         FREE((void*)_res);
16391         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
16392 }
16393
16394 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
16395         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
16396         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
16397         return (uintptr_t)ret_conv;
16398 }
16399 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16400         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
16401         intptr_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
16402         return ret_val;
16403 }
16404
16405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16406         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
16407         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
16408         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
16409         return (uintptr_t)ret_conv;
16410 }
16411
16412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
16413         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16414         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
16415         return (uintptr_t)ret_conv;
16416 }
16417
16418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16419         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16420         CHECK_ACCESS(e_ptr);
16421         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
16422         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
16423         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16424         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
16425         return (uintptr_t)ret_conv;
16426 }
16427
16428 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16429         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
16430         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
16431         return ret_val;
16432 }
16433
16434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16435         if ((_res & 1) != 0) return;
16436         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16437         CHECK_ACCESS(_res_ptr);
16438         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
16439         FREE((void*)_res);
16440         CResult_NonePaymentSendFailureZ_free(_res_conv);
16441 }
16442
16443 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
16444         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16445         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
16446         return (uintptr_t)ret_conv;
16447 }
16448 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16449         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
16450         intptr_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
16451         return ret_val;
16452 }
16453
16454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16455         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
16456         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16457         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
16458         return (uintptr_t)ret_conv;
16459 }
16460
16461 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
16462         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
16463         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
16464         return ((uintptr_t)ret_conv);
16465 }
16466 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16467         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
16468         intptr_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
16469         return ret_val;
16470 }
16471
16472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16473         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
16474         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
16475         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
16476         return ((uintptr_t)ret_conv);
16477 }
16478
16479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
16480         LDKThirtyTwoBytes a_ref;
16481         CHECK((*env)->GetArrayLength(env, a) == 32);
16482         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
16483         LDKThirtyTwoBytes b_ref;
16484         CHECK((*env)->GetArrayLength(env, b) == 32);
16485         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
16486         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
16487         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
16488         return ((uintptr_t)ret_conv);
16489 }
16490
16491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16492         if ((_res & 1) != 0) return;
16493         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16494         CHECK_ACCESS(_res_ptr);
16495         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
16496         FREE((void*)_res);
16497         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
16498 }
16499
16500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16501         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16502         CHECK_ACCESS(o_ptr);
16503         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
16504         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
16505         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16506         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
16507         return (uintptr_t)ret_conv;
16508 }
16509
16510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16511         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16512         CHECK_ACCESS(e_ptr);
16513         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
16514         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
16515         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16516         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
16517         return (uintptr_t)ret_conv;
16518 }
16519
16520 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16521         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
16522         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
16523         return ret_val;
16524 }
16525
16526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16527         if ((_res & 1) != 0) return;
16528         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16529         CHECK_ACCESS(_res_ptr);
16530         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
16531         FREE((void*)_res);
16532         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
16533 }
16534
16535 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
16536         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16537         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
16538         return (uintptr_t)ret_conv;
16539 }
16540 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16541         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
16542         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
16543         return ret_val;
16544 }
16545
16546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16547         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
16548         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16549         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
16550         return (uintptr_t)ret_conv;
16551 }
16552
16553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16554         LDKCVec_NetAddressZ _res_constr;
16555         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16556         if (_res_constr.datalen > 0)
16557                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
16558         else
16559                 _res_constr.data = NULL;
16560         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16561         for (size_t m = 0; m < _res_constr.datalen; m++) {
16562                 int64_t _res_conv_12 = _res_vals[m];
16563                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
16564                 CHECK_ACCESS(_res_conv_12_ptr);
16565                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
16566                 FREE((void*)_res_conv_12);
16567                 _res_constr.data[m] = _res_conv_12_conv;
16568         }
16569         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16570         CVec_NetAddressZ_free(_res_constr);
16571 }
16572
16573 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
16574         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16575         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
16576         return ((uintptr_t)ret_conv);
16577 }
16578 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16579         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
16580         intptr_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
16581         return ret_val;
16582 }
16583
16584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16585         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
16586         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16587         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
16588         return ((uintptr_t)ret_conv);
16589 }
16590
16591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
16592         LDKThirtyTwoBytes a_ref;
16593         CHECK((*env)->GetArrayLength(env, a) == 32);
16594         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
16595         LDKThirtyTwoBytes b_ref;
16596         CHECK((*env)->GetArrayLength(env, b) == 32);
16597         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
16598         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16599         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
16600         return ((uintptr_t)ret_conv);
16601 }
16602
16603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16604         if ((_res & 1) != 0) return;
16605         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16606         CHECK_ACCESS(_res_ptr);
16607         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
16608         FREE((void*)_res);
16609         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
16610 }
16611
16612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16613         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16614         CHECK_ACCESS(o_ptr);
16615         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16616         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
16617         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16618         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
16619         return (uintptr_t)ret_conv;
16620 }
16621
16622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
16623         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16624         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
16625         return (uintptr_t)ret_conv;
16626 }
16627
16628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16629         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
16630         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
16631         return ret_val;
16632 }
16633
16634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16635         if ((_res & 1) != 0) return;
16636         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16637         CHECK_ACCESS(_res_ptr);
16638         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
16639         FREE((void*)_res);
16640         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
16641 }
16642
16643 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
16644         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16645         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
16646         return (uintptr_t)ret_conv;
16647 }
16648 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16649         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
16650         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
16651         return ret_val;
16652 }
16653
16654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16655         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
16656         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16657         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
16658         return (uintptr_t)ret_conv;
16659 }
16660
16661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16662         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16663         CHECK_ACCESS(o_ptr);
16664         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16665         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
16666         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16667         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
16668         return (uintptr_t)ret_conv;
16669 }
16670
16671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16672         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16673         CHECK_ACCESS(e_ptr);
16674         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16675         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16676         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16677         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
16678         return (uintptr_t)ret_conv;
16679 }
16680
16681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16682         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
16683         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
16684         return ret_val;
16685 }
16686
16687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16688         if ((_res & 1) != 0) return;
16689         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16690         CHECK_ACCESS(_res_ptr);
16691         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
16692         FREE((void*)_res);
16693         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
16694 }
16695
16696 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
16697         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16698         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
16699         return (uintptr_t)ret_conv;
16700 }
16701 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16702         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
16703         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
16704         return ret_val;
16705 }
16706
16707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16708         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
16709         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16710         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
16711         return (uintptr_t)ret_conv;
16712 }
16713
16714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16715         LDKThirtyTwoBytes o_ref;
16716         CHECK((*env)->GetArrayLength(env, o) == 32);
16717         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
16718         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16719         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
16720         return (uintptr_t)ret_conv;
16721 }
16722
16723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
16724         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16725         *ret_conv = CResult_PaymentSecretNoneZ_err();
16726         return (uintptr_t)ret_conv;
16727 }
16728
16729 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16730         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
16731         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
16732         return ret_val;
16733 }
16734
16735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16736         if ((_res & 1) != 0) return;
16737         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16738         CHECK_ACCESS(_res_ptr);
16739         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
16740         FREE((void*)_res);
16741         CResult_PaymentSecretNoneZ_free(_res_conv);
16742 }
16743
16744 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
16745         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16746         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
16747         return (uintptr_t)ret_conv;
16748 }
16749 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16750         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
16751         intptr_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
16752         return ret_val;
16753 }
16754
16755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16756         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
16757         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16758         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
16759         return (uintptr_t)ret_conv;
16760 }
16761
16762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16763         LDKThirtyTwoBytes o_ref;
16764         CHECK((*env)->GetArrayLength(env, o) == 32);
16765         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
16766         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16767         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
16768         return (uintptr_t)ret_conv;
16769 }
16770
16771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16772         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16773         CHECK_ACCESS(e_ptr);
16774         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16775         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16776         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16777         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
16778         return (uintptr_t)ret_conv;
16779 }
16780
16781 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16782         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
16783         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
16784         return ret_val;
16785 }
16786
16787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16788         if ((_res & 1) != 0) return;
16789         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16790         CHECK_ACCESS(_res_ptr);
16791         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
16792         FREE((void*)_res);
16793         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
16794 }
16795
16796 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
16797         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16798         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
16799         return (uintptr_t)ret_conv;
16800 }
16801 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16802         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
16803         intptr_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
16804         return ret_val;
16805 }
16806
16807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16808         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
16809         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16810         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
16811         return (uintptr_t)ret_conv;
16812 }
16813
16814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16815         LDKThirtyTwoBytes o_ref;
16816         CHECK((*env)->GetArrayLength(env, o) == 32);
16817         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
16818         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16819         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
16820         return (uintptr_t)ret_conv;
16821 }
16822
16823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16824         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16825         CHECK_ACCESS(e_ptr);
16826         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16827         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16828         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16829         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
16830         return (uintptr_t)ret_conv;
16831 }
16832
16833 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16834         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
16835         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
16836         return ret_val;
16837 }
16838
16839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16840         if ((_res & 1) != 0) return;
16841         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16842         CHECK_ACCESS(_res_ptr);
16843         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
16844         FREE((void*)_res);
16845         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
16846 }
16847
16848 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
16849         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16850         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
16851         return (uintptr_t)ret_conv;
16852 }
16853 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16854         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
16855         intptr_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
16856         return ret_val;
16857 }
16858
16859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16860         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
16861         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16862         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
16863         return (uintptr_t)ret_conv;
16864 }
16865
16866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16867         LDKCVec_ChannelMonitorZ _res_constr;
16868         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16869         if (_res_constr.datalen > 0)
16870                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16871         else
16872                 _res_constr.data = NULL;
16873         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16874         for (size_t q = 0; q < _res_constr.datalen; q++) {
16875                 int64_t _res_conv_16 = _res_vals[q];
16876                 LDKChannelMonitor _res_conv_16_conv;
16877                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16878                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16879                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16880                 _res_constr.data[q] = _res_conv_16_conv;
16881         }
16882         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16883         CVec_ChannelMonitorZ_free(_res_constr);
16884 }
16885
16886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
16887         LDKThirtyTwoBytes a_ref;
16888         CHECK((*env)->GetArrayLength(env, a) == 32);
16889         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
16890         LDKChannelManager b_conv;
16891         b_conv.inner = (void*)(b & (~1));
16892         b_conv.is_owned = (b & 1) || (b == 0);
16893         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16894         // Warning: we need a move here but no clone is available for LDKChannelManager
16895         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
16896         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
16897         return ((uintptr_t)ret_conv);
16898 }
16899
16900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16901         if ((_res & 1) != 0) return;
16902         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16903         CHECK_ACCESS(_res_ptr);
16904         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
16905         FREE((void*)_res);
16906         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
16907 }
16908
16909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16910         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16911         CHECK_ACCESS(o_ptr);
16912         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
16913         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
16914         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16915         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
16916         return (uintptr_t)ret_conv;
16917 }
16918
16919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16920         LDKDecodeError e_conv;
16921         e_conv.inner = (void*)(e & (~1));
16922         e_conv.is_owned = (e & 1) || (e == 0);
16923         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16924         e_conv = DecodeError_clone(&e_conv);
16925         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16926         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
16927         return (uintptr_t)ret_conv;
16928 }
16929
16930 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16931         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
16932         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
16933         return ret_val;
16934 }
16935
16936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16937         if ((_res & 1) != 0) return;
16938         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16939         CHECK_ACCESS(_res_ptr);
16940         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
16941         FREE((void*)_res);
16942         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
16943 }
16944
16945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16946         LDKChannelConfig o_conv;
16947         o_conv.inner = (void*)(o & (~1));
16948         o_conv.is_owned = (o & 1) || (o == 0);
16949         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16950         o_conv = ChannelConfig_clone(&o_conv);
16951         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16952         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
16953         return (uintptr_t)ret_conv;
16954 }
16955
16956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16957         LDKDecodeError e_conv;
16958         e_conv.inner = (void*)(e & (~1));
16959         e_conv.is_owned = (e & 1) || (e == 0);
16960         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16961         e_conv = DecodeError_clone(&e_conv);
16962         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16963         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
16964         return (uintptr_t)ret_conv;
16965 }
16966
16967 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16968         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
16969         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
16970         return ret_val;
16971 }
16972
16973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16974         if ((_res & 1) != 0) return;
16975         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16976         CHECK_ACCESS(_res_ptr);
16977         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
16978         FREE((void*)_res);
16979         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
16980 }
16981
16982 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
16983         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16984         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
16985         return (uintptr_t)ret_conv;
16986 }
16987 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16988         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
16989         intptr_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
16990         return ret_val;
16991 }
16992
16993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16994         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
16995         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16996         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
16997         return (uintptr_t)ret_conv;
16998 }
16999
17000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17001         LDKOutPoint o_conv;
17002         o_conv.inner = (void*)(o & (~1));
17003         o_conv.is_owned = (o & 1) || (o == 0);
17004         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17005         o_conv = OutPoint_clone(&o_conv);
17006         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
17007         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
17008         return (uintptr_t)ret_conv;
17009 }
17010
17011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17012         LDKDecodeError e_conv;
17013         e_conv.inner = (void*)(e & (~1));
17014         e_conv.is_owned = (e & 1) || (e == 0);
17015         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17016         e_conv = DecodeError_clone(&e_conv);
17017         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
17018         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
17019         return (uintptr_t)ret_conv;
17020 }
17021
17022 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17023         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
17024         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
17025         return ret_val;
17026 }
17027
17028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17029         if ((_res & 1) != 0) return;
17030         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17031         CHECK_ACCESS(_res_ptr);
17032         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
17033         FREE((void*)_res);
17034         CResult_OutPointDecodeErrorZ_free(_res_conv);
17035 }
17036
17037 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
17038         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
17039         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
17040         return (uintptr_t)ret_conv;
17041 }
17042 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17043         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
17044         intptr_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
17045         return ret_val;
17046 }
17047
17048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17049         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
17050         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
17051         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
17052         return (uintptr_t)ret_conv;
17053 }
17054
17055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17056         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17057         CHECK_ACCESS(o_ptr);
17058         LDKType o_conv = *(LDKType*)(o_ptr);
17059         if (o_conv.free == LDKType_JCalls_free) {
17060                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17061                 LDKType_JCalls_cloned(&o_conv);
17062         }
17063         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
17064         *ret_copy = COption_TypeZ_some(o_conv);
17065         uintptr_t ret_ref = (uintptr_t)ret_copy;
17066         return ret_ref;
17067 }
17068
17069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
17070         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
17071         *ret_copy = COption_TypeZ_none();
17072         uintptr_t ret_ref = (uintptr_t)ret_copy;
17073         return ret_ref;
17074 }
17075
17076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17077         if ((_res & 1) != 0) return;
17078         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17079         CHECK_ACCESS(_res_ptr);
17080         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
17081         FREE((void*)_res);
17082         COption_TypeZ_free(_res_conv);
17083 }
17084
17085 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
17086         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
17087         *ret_copy = COption_TypeZ_clone(arg);
17088 uintptr_t ret_ref = (uintptr_t)ret_copy;
17089         return ret_ref;
17090 }
17091 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17092         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
17093         intptr_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
17094         return ret_val;
17095 }
17096
17097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17098         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
17099         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
17100         *ret_copy = COption_TypeZ_clone(orig_conv);
17101         uintptr_t ret_ref = (uintptr_t)ret_copy;
17102         return ret_ref;
17103 }
17104
17105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17106         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17107         CHECK_ACCESS(o_ptr);
17108         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
17109         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
17110         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
17111         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
17112         return (uintptr_t)ret_conv;
17113 }
17114
17115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17116         LDKDecodeError e_conv;
17117         e_conv.inner = (void*)(e & (~1));
17118         e_conv.is_owned = (e & 1) || (e == 0);
17119         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17120         e_conv = DecodeError_clone(&e_conv);
17121         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
17122         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
17123         return (uintptr_t)ret_conv;
17124 }
17125
17126 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17127         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
17128         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
17129         return ret_val;
17130 }
17131
17132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17133         if ((_res & 1) != 0) return;
17134         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17135         CHECK_ACCESS(_res_ptr);
17136         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
17137         FREE((void*)_res);
17138         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
17139 }
17140
17141 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
17142         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
17143         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
17144         return (uintptr_t)ret_conv;
17145 }
17146 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17147         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
17148         intptr_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
17149         return ret_val;
17150 }
17151
17152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17153         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
17154         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
17155         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
17156         return (uintptr_t)ret_conv;
17157 }
17158
17159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17160         LDKThirtyTwoBytes o_ref;
17161         CHECK((*env)->GetArrayLength(env, o) == 32);
17162         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17163         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
17164         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
17165         return (uintptr_t)ret_conv;
17166 }
17167
17168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17169         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17170         CHECK_ACCESS(e_ptr);
17171         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
17172         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
17173         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
17174         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
17175         return (uintptr_t)ret_conv;
17176 }
17177
17178 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17179         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
17180         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
17181         return ret_val;
17182 }
17183
17184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17185         if ((_res & 1) != 0) return;
17186         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17187         CHECK_ACCESS(_res_ptr);
17188         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
17189         FREE((void*)_res);
17190         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
17191 }
17192
17193 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
17194         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
17195         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
17196         return (uintptr_t)ret_conv;
17197 }
17198 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17199         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
17200         intptr_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
17201         return ret_val;
17202 }
17203
17204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17205         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
17206         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
17207         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
17208         return (uintptr_t)ret_conv;
17209 }
17210
17211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
17212         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
17213         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
17214         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
17215         return (uintptr_t)ret_conv;
17216 }
17217
17218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
17219         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
17220         *ret_conv = CResult_SiPrefixNoneZ_err();
17221         return (uintptr_t)ret_conv;
17222 }
17223
17224 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17225         LDKCResult_SiPrefixNoneZ* o_conv = (LDKCResult_SiPrefixNoneZ*)(o & ~1);
17226         jboolean ret_val = CResult_SiPrefixNoneZ_is_ok(o_conv);
17227         return ret_val;
17228 }
17229
17230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17231         if ((_res & 1) != 0) return;
17232         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17233         CHECK_ACCESS(_res_ptr);
17234         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
17235         FREE((void*)_res);
17236         CResult_SiPrefixNoneZ_free(_res_conv);
17237 }
17238
17239 static inline uintptr_t CResult_SiPrefixNoneZ_clone_ptr(LDKCResult_SiPrefixNoneZ *NONNULL_PTR arg) {
17240         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
17241         *ret_conv = CResult_SiPrefixNoneZ_clone(arg);
17242         return (uintptr_t)ret_conv;
17243 }
17244 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17245         LDKCResult_SiPrefixNoneZ* arg_conv = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
17246         intptr_t ret_val = CResult_SiPrefixNoneZ_clone_ptr(arg_conv);
17247         return ret_val;
17248 }
17249
17250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17251         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
17252         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
17253         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
17254         return (uintptr_t)ret_conv;
17255 }
17256
17257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17258         LDKInvoice o_conv;
17259         o_conv.inner = (void*)(o & (~1));
17260         o_conv.is_owned = (o & 1) || (o == 0);
17261         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17262         o_conv = Invoice_clone(&o_conv);
17263         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
17264         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
17265         return (uintptr_t)ret_conv;
17266 }
17267
17268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
17269         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
17270         *ret_conv = CResult_InvoiceNoneZ_err();
17271         return (uintptr_t)ret_conv;
17272 }
17273
17274 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17275         LDKCResult_InvoiceNoneZ* o_conv = (LDKCResult_InvoiceNoneZ*)(o & ~1);
17276         jboolean ret_val = CResult_InvoiceNoneZ_is_ok(o_conv);
17277         return ret_val;
17278 }
17279
17280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17281         if ((_res & 1) != 0) return;
17282         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17283         CHECK_ACCESS(_res_ptr);
17284         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
17285         FREE((void*)_res);
17286         CResult_InvoiceNoneZ_free(_res_conv);
17287 }
17288
17289 static inline uintptr_t CResult_InvoiceNoneZ_clone_ptr(LDKCResult_InvoiceNoneZ *NONNULL_PTR arg) {
17290         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
17291         *ret_conv = CResult_InvoiceNoneZ_clone(arg);
17292         return (uintptr_t)ret_conv;
17293 }
17294 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17295         LDKCResult_InvoiceNoneZ* arg_conv = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
17296         intptr_t ret_val = CResult_InvoiceNoneZ_clone_ptr(arg_conv);
17297         return ret_val;
17298 }
17299
17300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17301         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
17302         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
17303         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
17304         return (uintptr_t)ret_conv;
17305 }
17306
17307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17308         LDKSignedRawInvoice o_conv;
17309         o_conv.inner = (void*)(o & (~1));
17310         o_conv.is_owned = (o & 1) || (o == 0);
17311         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17312         o_conv = SignedRawInvoice_clone(&o_conv);
17313         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
17314         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
17315         return (uintptr_t)ret_conv;
17316 }
17317
17318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
17319         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
17320         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
17321         return (uintptr_t)ret_conv;
17322 }
17323
17324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17325         LDKCResult_SignedRawInvoiceNoneZ* o_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(o & ~1);
17326         jboolean ret_val = CResult_SignedRawInvoiceNoneZ_is_ok(o_conv);
17327         return ret_val;
17328 }
17329
17330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17331         if ((_res & 1) != 0) return;
17332         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17333         CHECK_ACCESS(_res_ptr);
17334         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
17335         FREE((void*)_res);
17336         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
17337 }
17338
17339 static inline uintptr_t CResult_SignedRawInvoiceNoneZ_clone_ptr(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR arg) {
17340         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
17341         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(arg);
17342         return (uintptr_t)ret_conv;
17343 }
17344 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17345         LDKCResult_SignedRawInvoiceNoneZ* arg_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
17346         intptr_t ret_val = CResult_SignedRawInvoiceNoneZ_clone_ptr(arg_conv);
17347         return ret_val;
17348 }
17349
17350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17351         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
17352         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
17353         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
17354         return (uintptr_t)ret_conv;
17355 }
17356
17357 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
17358         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17359         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
17360         return ((uintptr_t)ret_conv);
17361 }
17362 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17363         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
17364         intptr_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
17365         return ret_val;
17366 }
17367
17368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17369         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
17370         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17371         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
17372         return ((uintptr_t)ret_conv);
17373 }
17374
17375 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) {
17376         LDKRawInvoice a_conv;
17377         a_conv.inner = (void*)(a & (~1));
17378         a_conv.is_owned = (a & 1) || (a == 0);
17379         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17380         a_conv = RawInvoice_clone(&a_conv);
17381         LDKThirtyTwoBytes b_ref;
17382         CHECK((*env)->GetArrayLength(env, b) == 32);
17383         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
17384         LDKInvoiceSignature c_conv;
17385         c_conv.inner = (void*)(c & (~1));
17386         c_conv.is_owned = (c & 1) || (c == 0);
17387         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
17388         c_conv = InvoiceSignature_clone(&c_conv);
17389         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17390         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
17391         return ((uintptr_t)ret_conv);
17392 }
17393
17394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17395         if ((_res & 1) != 0) return;
17396         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17397         CHECK_ACCESS(_res_ptr);
17398         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
17399         FREE((void*)_res);
17400         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
17401 }
17402
17403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17404         LDKPayeePubKey o_conv;
17405         o_conv.inner = (void*)(o & (~1));
17406         o_conv.is_owned = (o & 1) || (o == 0);
17407         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17408         o_conv = PayeePubKey_clone(&o_conv);
17409         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17410         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
17411         return (uintptr_t)ret_conv;
17412 }
17413
17414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17415         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
17416         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17417         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
17418         return (uintptr_t)ret_conv;
17419 }
17420
17421 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17422         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
17423         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
17424         return ret_val;
17425 }
17426
17427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17428         if ((_res & 1) != 0) return;
17429         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17430         CHECK_ACCESS(_res_ptr);
17431         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
17432         FREE((void*)_res);
17433         CResult_PayeePubKeyErrorZ_free(_res_conv);
17434 }
17435
17436 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
17437         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17438         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
17439         return (uintptr_t)ret_conv;
17440 }
17441 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17442         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
17443         intptr_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
17444         return ret_val;
17445 }
17446
17447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17448         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
17449         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17450         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
17451         return (uintptr_t)ret_conv;
17452 }
17453
17454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17455         LDKCVec_PrivateRouteZ _res_constr;
17456         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17457         if (_res_constr.datalen > 0)
17458                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
17459         else
17460                 _res_constr.data = NULL;
17461         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17462         for (size_t o = 0; o < _res_constr.datalen; o++) {
17463                 int64_t _res_conv_14 = _res_vals[o];
17464                 LDKPrivateRoute _res_conv_14_conv;
17465                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
17466                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
17467                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
17468                 _res_constr.data[o] = _res_conv_14_conv;
17469         }
17470         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17471         CVec_PrivateRouteZ_free(_res_constr);
17472 }
17473
17474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17475         LDKPositiveTimestamp o_conv;
17476         o_conv.inner = (void*)(o & (~1));
17477         o_conv.is_owned = (o & 1) || (o == 0);
17478         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17479         o_conv = PositiveTimestamp_clone(&o_conv);
17480         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17481         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
17482         return (uintptr_t)ret_conv;
17483 }
17484
17485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17486         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
17487         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17488         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
17489         return (uintptr_t)ret_conv;
17490 }
17491
17492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17493         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
17494         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
17495         return ret_val;
17496 }
17497
17498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17499         if ((_res & 1) != 0) return;
17500         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17501         CHECK_ACCESS(_res_ptr);
17502         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
17503         FREE((void*)_res);
17504         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
17505 }
17506
17507 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
17508         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17509         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
17510         return (uintptr_t)ret_conv;
17511 }
17512 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17513         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
17514         intptr_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
17515         return ret_val;
17516 }
17517
17518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17519         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
17520         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17521         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
17522         return (uintptr_t)ret_conv;
17523 }
17524
17525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
17526         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17527         *ret_conv = CResult_NoneSemanticErrorZ_ok();
17528         return (uintptr_t)ret_conv;
17529 }
17530
17531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17532         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
17533         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17534         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
17535         return (uintptr_t)ret_conv;
17536 }
17537
17538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17539         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
17540         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
17541         return ret_val;
17542 }
17543
17544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17545         if ((_res & 1) != 0) return;
17546         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17547         CHECK_ACCESS(_res_ptr);
17548         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
17549         FREE((void*)_res);
17550         CResult_NoneSemanticErrorZ_free(_res_conv);
17551 }
17552
17553 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
17554         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17555         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
17556         return (uintptr_t)ret_conv;
17557 }
17558 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17559         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
17560         intptr_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
17561         return ret_val;
17562 }
17563
17564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17565         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
17566         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17567         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
17568         return (uintptr_t)ret_conv;
17569 }
17570
17571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17572         LDKInvoice o_conv;
17573         o_conv.inner = (void*)(o & (~1));
17574         o_conv.is_owned = (o & 1) || (o == 0);
17575         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17576         o_conv = Invoice_clone(&o_conv);
17577         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17578         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
17579         return (uintptr_t)ret_conv;
17580 }
17581
17582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17583         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
17584         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17585         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
17586         return (uintptr_t)ret_conv;
17587 }
17588
17589 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17590         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
17591         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
17592         return ret_val;
17593 }
17594
17595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17596         if ((_res & 1) != 0) return;
17597         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17598         CHECK_ACCESS(_res_ptr);
17599         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
17600         FREE((void*)_res);
17601         CResult_InvoiceSemanticErrorZ_free(_res_conv);
17602 }
17603
17604 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
17605         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17606         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
17607         return (uintptr_t)ret_conv;
17608 }
17609 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17610         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
17611         intptr_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
17612         return ret_val;
17613 }
17614
17615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17616         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
17617         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17618         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
17619         return (uintptr_t)ret_conv;
17620 }
17621
17622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17623         LDKDescription o_conv;
17624         o_conv.inner = (void*)(o & (~1));
17625         o_conv.is_owned = (o & 1) || (o == 0);
17626         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17627         o_conv = Description_clone(&o_conv);
17628         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17629         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
17630         return (uintptr_t)ret_conv;
17631 }
17632
17633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17634         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
17635         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17636         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
17637         return (uintptr_t)ret_conv;
17638 }
17639
17640 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17641         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
17642         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
17643         return ret_val;
17644 }
17645
17646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17647         if ((_res & 1) != 0) return;
17648         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17649         CHECK_ACCESS(_res_ptr);
17650         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
17651         FREE((void*)_res);
17652         CResult_DescriptionCreationErrorZ_free(_res_conv);
17653 }
17654
17655 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
17656         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17657         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
17658         return (uintptr_t)ret_conv;
17659 }
17660 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17661         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
17662         intptr_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
17663         return ret_val;
17664 }
17665
17666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17667         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
17668         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17669         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
17670         return (uintptr_t)ret_conv;
17671 }
17672
17673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17674         LDKExpiryTime o_conv;
17675         o_conv.inner = (void*)(o & (~1));
17676         o_conv.is_owned = (o & 1) || (o == 0);
17677         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17678         o_conv = ExpiryTime_clone(&o_conv);
17679         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
17680         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
17681         return (uintptr_t)ret_conv;
17682 }
17683
17684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17685         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
17686         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
17687         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
17688         return (uintptr_t)ret_conv;
17689 }
17690
17691 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17692         LDKCResult_ExpiryTimeCreationErrorZ* o_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(o & ~1);
17693         jboolean ret_val = CResult_ExpiryTimeCreationErrorZ_is_ok(o_conv);
17694         return ret_val;
17695 }
17696
17697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17698         if ((_res & 1) != 0) return;
17699         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17700         CHECK_ACCESS(_res_ptr);
17701         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(_res_ptr);
17702         FREE((void*)_res);
17703         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
17704 }
17705
17706 static inline uintptr_t CResult_ExpiryTimeCreationErrorZ_clone_ptr(LDKCResult_ExpiryTimeCreationErrorZ *NONNULL_PTR arg) {
17707         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
17708         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(arg);
17709         return (uintptr_t)ret_conv;
17710 }
17711 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17712         LDKCResult_ExpiryTimeCreationErrorZ* arg_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
17713         intptr_t ret_val = CResult_ExpiryTimeCreationErrorZ_clone_ptr(arg_conv);
17714         return ret_val;
17715 }
17716
17717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17718         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
17719         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
17720         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
17721         return (uintptr_t)ret_conv;
17722 }
17723
17724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17725         LDKPrivateRoute o_conv;
17726         o_conv.inner = (void*)(o & (~1));
17727         o_conv.is_owned = (o & 1) || (o == 0);
17728         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17729         o_conv = PrivateRoute_clone(&o_conv);
17730         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17731         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
17732         return (uintptr_t)ret_conv;
17733 }
17734
17735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17736         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
17737         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17738         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
17739         return (uintptr_t)ret_conv;
17740 }
17741
17742 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17743         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
17744         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
17745         return ret_val;
17746 }
17747
17748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17749         if ((_res & 1) != 0) return;
17750         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17751         CHECK_ACCESS(_res_ptr);
17752         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
17753         FREE((void*)_res);
17754         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
17755 }
17756
17757 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
17758         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17759         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
17760         return (uintptr_t)ret_conv;
17761 }
17762 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17763         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
17764         intptr_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
17765         return ret_val;
17766 }
17767
17768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17769         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
17770         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17771         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
17772         return (uintptr_t)ret_conv;
17773 }
17774
17775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
17776         LDKStr o_conv = java_to_owned_str(env, o);
17777         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17778         *ret_conv = CResult_StringErrorZ_ok(o_conv);
17779         return (uintptr_t)ret_conv;
17780 }
17781
17782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17783         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
17784         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17785         *ret_conv = CResult_StringErrorZ_err(e_conv);
17786         return (uintptr_t)ret_conv;
17787 }
17788
17789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17790         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
17791         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
17792         return ret_val;
17793 }
17794
17795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17796         if ((_res & 1) != 0) return;
17797         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17798         CHECK_ACCESS(_res_ptr);
17799         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
17800         FREE((void*)_res);
17801         CResult_StringErrorZ_free(_res_conv);
17802 }
17803
17804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17805         LDKChannelMonitorUpdate o_conv;
17806         o_conv.inner = (void*)(o & (~1));
17807         o_conv.is_owned = (o & 1) || (o == 0);
17808         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17809         o_conv = ChannelMonitorUpdate_clone(&o_conv);
17810         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17811         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
17812         return (uintptr_t)ret_conv;
17813 }
17814
17815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17816         LDKDecodeError e_conv;
17817         e_conv.inner = (void*)(e & (~1));
17818         e_conv.is_owned = (e & 1) || (e == 0);
17819         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17820         e_conv = DecodeError_clone(&e_conv);
17821         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17822         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
17823         return (uintptr_t)ret_conv;
17824 }
17825
17826 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17827         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
17828         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
17829         return ret_val;
17830 }
17831
17832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17833         if ((_res & 1) != 0) return;
17834         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17835         CHECK_ACCESS(_res_ptr);
17836         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
17837         FREE((void*)_res);
17838         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
17839 }
17840
17841 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
17842         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17843         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
17844         return (uintptr_t)ret_conv;
17845 }
17846 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17847         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
17848         intptr_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
17849         return ret_val;
17850 }
17851
17852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17853         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
17854         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17855         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
17856         return (uintptr_t)ret_conv;
17857 }
17858
17859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17860         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17861         CHECK_ACCESS(o_ptr);
17862         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
17863         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
17864         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17865         *ret_copy = COption_MonitorEventZ_some(o_conv);
17866         uintptr_t ret_ref = (uintptr_t)ret_copy;
17867         return ret_ref;
17868 }
17869
17870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
17871         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17872         *ret_copy = COption_MonitorEventZ_none();
17873         uintptr_t ret_ref = (uintptr_t)ret_copy;
17874         return ret_ref;
17875 }
17876
17877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17878         if ((_res & 1) != 0) return;
17879         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17880         CHECK_ACCESS(_res_ptr);
17881         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
17882         FREE((void*)_res);
17883         COption_MonitorEventZ_free(_res_conv);
17884 }
17885
17886 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
17887         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17888         *ret_copy = COption_MonitorEventZ_clone(arg);
17889 uintptr_t ret_ref = (uintptr_t)ret_copy;
17890         return ret_ref;
17891 }
17892 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17893         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
17894         intptr_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
17895         return ret_val;
17896 }
17897
17898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17899         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
17900         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17901         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
17902         uintptr_t ret_ref = (uintptr_t)ret_copy;
17903         return ret_ref;
17904 }
17905
17906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17907         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17908         CHECK_ACCESS(o_ptr);
17909         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
17910         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
17911         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17912         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
17913         return (uintptr_t)ret_conv;
17914 }
17915
17916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17917         LDKDecodeError e_conv;
17918         e_conv.inner = (void*)(e & (~1));
17919         e_conv.is_owned = (e & 1) || (e == 0);
17920         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17921         e_conv = DecodeError_clone(&e_conv);
17922         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17923         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
17924         return (uintptr_t)ret_conv;
17925 }
17926
17927 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17928         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
17929         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
17930         return ret_val;
17931 }
17932
17933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17934         if ((_res & 1) != 0) return;
17935         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17936         CHECK_ACCESS(_res_ptr);
17937         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
17938         FREE((void*)_res);
17939         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
17940 }
17941
17942 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
17943         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17944         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
17945         return (uintptr_t)ret_conv;
17946 }
17947 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17948         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
17949         intptr_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
17950         return ret_val;
17951 }
17952
17953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17954         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
17955         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17956         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
17957         return (uintptr_t)ret_conv;
17958 }
17959
17960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17961         LDKHTLCUpdate o_conv;
17962         o_conv.inner = (void*)(o & (~1));
17963         o_conv.is_owned = (o & 1) || (o == 0);
17964         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17965         o_conv = HTLCUpdate_clone(&o_conv);
17966         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17967         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
17968         return (uintptr_t)ret_conv;
17969 }
17970
17971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17972         LDKDecodeError e_conv;
17973         e_conv.inner = (void*)(e & (~1));
17974         e_conv.is_owned = (e & 1) || (e == 0);
17975         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17976         e_conv = DecodeError_clone(&e_conv);
17977         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17978         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
17979         return (uintptr_t)ret_conv;
17980 }
17981
17982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17983         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
17984         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
17985         return ret_val;
17986 }
17987
17988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17989         if ((_res & 1) != 0) return;
17990         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17991         CHECK_ACCESS(_res_ptr);
17992         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
17993         FREE((void*)_res);
17994         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
17995 }
17996
17997 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
17998         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17999         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
18000         return (uintptr_t)ret_conv;
18001 }
18002 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18003         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
18004         intptr_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
18005         return ret_val;
18006 }
18007
18008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18009         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
18010         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
18011         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
18012         return (uintptr_t)ret_conv;
18013 }
18014
18015 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
18016         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
18017         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
18018         return ((uintptr_t)ret_conv);
18019 }
18020 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18021         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
18022         intptr_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
18023         return ret_val;
18024 }
18025
18026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18027         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
18028         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
18029         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
18030         return ((uintptr_t)ret_conv);
18031 }
18032
18033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
18034         LDKOutPoint a_conv;
18035         a_conv.inner = (void*)(a & (~1));
18036         a_conv.is_owned = (a & 1) || (a == 0);
18037         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18038         a_conv = OutPoint_clone(&a_conv);
18039         LDKCVec_u8Z b_ref;
18040         b_ref.datalen = (*env)->GetArrayLength(env, b);
18041         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
18042         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
18043         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
18044         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
18045         return ((uintptr_t)ret_conv);
18046 }
18047
18048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18049         if ((_res & 1) != 0) return;
18050         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18051         CHECK_ACCESS(_res_ptr);
18052         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
18053         FREE((void*)_res);
18054         C2Tuple_OutPointScriptZ_free(_res_conv);
18055 }
18056
18057 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
18058         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
18059         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
18060         return ((uintptr_t)ret_conv);
18061 }
18062 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18063         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
18064         intptr_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
18065         return ret_val;
18066 }
18067
18068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18069         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
18070         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
18071         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
18072         return ((uintptr_t)ret_conv);
18073 }
18074
18075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
18076         LDKCVec_u8Z b_ref;
18077         b_ref.datalen = (*env)->GetArrayLength(env, b);
18078         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
18079         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
18080         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
18081         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
18082         return ((uintptr_t)ret_conv);
18083 }
18084
18085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18086         if ((_res & 1) != 0) return;
18087         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18088         CHECK_ACCESS(_res_ptr);
18089         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
18090         FREE((void*)_res);
18091         C2Tuple_u32ScriptZ_free(_res_conv);
18092 }
18093
18094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18095         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
18096         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18097         if (_res_constr.datalen > 0)
18098                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
18099         else
18100                 _res_constr.data = NULL;
18101         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18102         for (size_t v = 0; v < _res_constr.datalen; v++) {
18103                 int64_t _res_conv_21 = _res_vals[v];
18104                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
18105                 CHECK_ACCESS(_res_conv_21_ptr);
18106                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
18107                 FREE((void*)_res_conv_21);
18108                 _res_constr.data[v] = _res_conv_21_conv;
18109         }
18110         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18111         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
18112 }
18113
18114 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
18115         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
18116         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
18117         return ((uintptr_t)ret_conv);
18118 }
18119 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18120         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
18121         intptr_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
18122         return ret_val;
18123 }
18124
18125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18126         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
18127         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
18128         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
18129         return ((uintptr_t)ret_conv);
18130 }
18131
18132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
18133         LDKThirtyTwoBytes a_ref;
18134         CHECK((*env)->GetArrayLength(env, a) == 32);
18135         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18136         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
18137         b_constr.datalen = (*env)->GetArrayLength(env, b);
18138         if (b_constr.datalen > 0)
18139                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
18140         else
18141                 b_constr.data = NULL;
18142         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
18143         for (size_t v = 0; v < b_constr.datalen; v++) {
18144                 int64_t b_conv_21 = b_vals[v];
18145                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
18146                 CHECK_ACCESS(b_conv_21_ptr);
18147                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
18148                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
18149                 b_constr.data[v] = b_conv_21_conv;
18150         }
18151         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
18152         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
18153         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
18154         return ((uintptr_t)ret_conv);
18155 }
18156
18157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18158         if ((_res & 1) != 0) return;
18159         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18160         CHECK_ACCESS(_res_ptr);
18161         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
18162         FREE((void*)_res);
18163         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
18164 }
18165
18166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18167         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
18168         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18169         if (_res_constr.datalen > 0)
18170                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
18171         else
18172                 _res_constr.data = NULL;
18173         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18174         for (size_t o = 0; o < _res_constr.datalen; o++) {
18175                 int64_t _res_conv_40 = _res_vals[o];
18176                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
18177                 CHECK_ACCESS(_res_conv_40_ptr);
18178                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
18179                 FREE((void*)_res_conv_40);
18180                 _res_constr.data[o] = _res_conv_40_conv;
18181         }
18182         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18183         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
18184 }
18185
18186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18187         LDKCVec_EventZ _res_constr;
18188         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18189         if (_res_constr.datalen > 0)
18190                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
18191         else
18192                 _res_constr.data = NULL;
18193         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18194         for (size_t h = 0; h < _res_constr.datalen; h++) {
18195                 int64_t _res_conv_7 = _res_vals[h];
18196                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
18197                 CHECK_ACCESS(_res_conv_7_ptr);
18198                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
18199                 FREE((void*)_res_conv_7);
18200                 _res_constr.data[h] = _res_conv_7_conv;
18201         }
18202         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18203         CVec_EventZ_free(_res_constr);
18204 }
18205
18206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18207         LDKCVec_TransactionZ _res_constr;
18208         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18209         if (_res_constr.datalen > 0)
18210                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
18211         else
18212                 _res_constr.data = NULL;
18213         for (size_t i = 0; i < _res_constr.datalen; i++) {
18214                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
18215                 LDKTransaction _res_conv_8_ref;
18216                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
18217                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
18218                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
18219                 _res_conv_8_ref.data_is_owned = true;
18220                 _res_constr.data[i] = _res_conv_8_ref;
18221         }
18222         CVec_TransactionZ_free(_res_constr);
18223 }
18224
18225 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
18226         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
18227         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
18228         return ((uintptr_t)ret_conv);
18229 }
18230 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18231         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
18232         intptr_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
18233         return ret_val;
18234 }
18235
18236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18237         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
18238         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
18239         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
18240         return ((uintptr_t)ret_conv);
18241 }
18242
18243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
18244         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
18245         CHECK_ACCESS(b_ptr);
18246         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
18247         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
18248         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
18249         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
18250         return ((uintptr_t)ret_conv);
18251 }
18252
18253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18254         if ((_res & 1) != 0) return;
18255         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18256         CHECK_ACCESS(_res_ptr);
18257         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
18258         FREE((void*)_res);
18259         C2Tuple_u32TxOutZ_free(_res_conv);
18260 }
18261
18262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18263         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
18264         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18265         if (_res_constr.datalen > 0)
18266                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
18267         else
18268                 _res_constr.data = NULL;
18269         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18270         for (size_t u = 0; u < _res_constr.datalen; u++) {
18271                 int64_t _res_conv_20 = _res_vals[u];
18272                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
18273                 CHECK_ACCESS(_res_conv_20_ptr);
18274                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
18275                 FREE((void*)_res_conv_20);
18276                 _res_constr.data[u] = _res_conv_20_conv;
18277         }
18278         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18279         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
18280 }
18281
18282 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
18283         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18284         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
18285         return ((uintptr_t)ret_conv);
18286 }
18287 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18288         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
18289         intptr_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
18290         return ret_val;
18291 }
18292
18293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18294         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
18295         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18296         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
18297         return ((uintptr_t)ret_conv);
18298 }
18299
18300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
18301         LDKThirtyTwoBytes a_ref;
18302         CHECK((*env)->GetArrayLength(env, a) == 32);
18303         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18304         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
18305         b_constr.datalen = (*env)->GetArrayLength(env, b);
18306         if (b_constr.datalen > 0)
18307                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
18308         else
18309                 b_constr.data = NULL;
18310         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
18311         for (size_t u = 0; u < b_constr.datalen; u++) {
18312                 int64_t b_conv_20 = b_vals[u];
18313                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
18314                 CHECK_ACCESS(b_conv_20_ptr);
18315                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
18316                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
18317                 b_constr.data[u] = b_conv_20_conv;
18318         }
18319         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
18320         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18321         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
18322         return ((uintptr_t)ret_conv);
18323 }
18324
18325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18326         if ((_res & 1) != 0) return;
18327         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18328         CHECK_ACCESS(_res_ptr);
18329         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
18330         FREE((void*)_res);
18331         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
18332 }
18333
18334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18335         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
18336         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18337         if (_res_constr.datalen > 0)
18338                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
18339         else
18340                 _res_constr.data = NULL;
18341         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18342         for (size_t n = 0; n < _res_constr.datalen; n++) {
18343                 int64_t _res_conv_39 = _res_vals[n];
18344                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
18345                 CHECK_ACCESS(_res_conv_39_ptr);
18346                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
18347                 FREE((void*)_res_conv_39);
18348                 _res_constr.data[n] = _res_conv_39_conv;
18349         }
18350         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18351         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
18352 }
18353
18354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18355         LDKCVec_BalanceZ _res_constr;
18356         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18357         if (_res_constr.datalen > 0)
18358                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
18359         else
18360                 _res_constr.data = NULL;
18361         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18362         for (size_t j = 0; j < _res_constr.datalen; j++) {
18363                 int64_t _res_conv_9 = _res_vals[j];
18364                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
18365                 CHECK_ACCESS(_res_conv_9_ptr);
18366                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
18367                 FREE((void*)_res_conv_9);
18368                 _res_constr.data[j] = _res_conv_9_conv;
18369         }
18370         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18371         CVec_BalanceZ_free(_res_constr);
18372 }
18373
18374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18375         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18376         CHECK_ACCESS(o_ptr);
18377         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
18378         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
18379         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18380         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
18381         return (uintptr_t)ret_conv;
18382 }
18383
18384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18385         LDKDecodeError e_conv;
18386         e_conv.inner = (void*)(e & (~1));
18387         e_conv.is_owned = (e & 1) || (e == 0);
18388         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18389         e_conv = DecodeError_clone(&e_conv);
18390         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18391         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
18392         return (uintptr_t)ret_conv;
18393 }
18394
18395 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18396         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
18397         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
18398         return ret_val;
18399 }
18400
18401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18402         if ((_res & 1) != 0) return;
18403         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18404         CHECK_ACCESS(_res_ptr);
18405         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
18406         FREE((void*)_res);
18407         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
18408 }
18409
18410 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
18411         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18412         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
18413         return (uintptr_t)ret_conv;
18414 }
18415 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18416         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
18417         intptr_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
18418         return ret_val;
18419 }
18420
18421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18422         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
18423         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18424         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
18425         return (uintptr_t)ret_conv;
18426 }
18427
18428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
18429         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18430         *ret_conv = CResult_NoneLightningErrorZ_ok();
18431         return (uintptr_t)ret_conv;
18432 }
18433
18434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18435         LDKLightningError e_conv;
18436         e_conv.inner = (void*)(e & (~1));
18437         e_conv.is_owned = (e & 1) || (e == 0);
18438         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18439         e_conv = LightningError_clone(&e_conv);
18440         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18441         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
18442         return (uintptr_t)ret_conv;
18443 }
18444
18445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18446         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
18447         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
18448         return ret_val;
18449 }
18450
18451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18452         if ((_res & 1) != 0) return;
18453         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18454         CHECK_ACCESS(_res_ptr);
18455         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
18456         FREE((void*)_res);
18457         CResult_NoneLightningErrorZ_free(_res_conv);
18458 }
18459
18460 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
18461         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18462         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
18463         return (uintptr_t)ret_conv;
18464 }
18465 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18466         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
18467         intptr_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
18468         return ret_val;
18469 }
18470
18471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18472         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
18473         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18474         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
18475         return (uintptr_t)ret_conv;
18476 }
18477
18478 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
18479         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18480         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
18481         return ((uintptr_t)ret_conv);
18482 }
18483 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18484         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
18485         intptr_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
18486         return ret_val;
18487 }
18488
18489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18490         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
18491         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18492         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
18493         return ((uintptr_t)ret_conv);
18494 }
18495
18496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
18497         LDKPublicKey a_ref;
18498         CHECK((*env)->GetArrayLength(env, a) == 33);
18499         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
18500         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
18501         CHECK_ACCESS(b_ptr);
18502         LDKType b_conv = *(LDKType*)(b_ptr);
18503         if (b_conv.free == LDKType_JCalls_free) {
18504                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18505                 LDKType_JCalls_cloned(&b_conv);
18506         }
18507         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18508         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
18509         return ((uintptr_t)ret_conv);
18510 }
18511
18512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18513         if ((_res & 1) != 0) return;
18514         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18515         CHECK_ACCESS(_res_ptr);
18516         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
18517         FREE((void*)_res);
18518         C2Tuple_PublicKeyTypeZ_free(_res_conv);
18519 }
18520
18521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18522         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
18523         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18524         if (_res_constr.datalen > 0)
18525                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
18526         else
18527                 _res_constr.data = NULL;
18528         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18529         for (size_t z = 0; z < _res_constr.datalen; z++) {
18530                 int64_t _res_conv_25 = _res_vals[z];
18531                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
18532                 CHECK_ACCESS(_res_conv_25_ptr);
18533                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
18534                 FREE((void*)_res_conv_25);
18535                 _res_constr.data[z] = _res_conv_25_conv;
18536         }
18537         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18538         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
18539 }
18540
18541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
18542         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18543         *ret_conv = CResult_boolLightningErrorZ_ok(o);
18544         return (uintptr_t)ret_conv;
18545 }
18546
18547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18548         LDKLightningError e_conv;
18549         e_conv.inner = (void*)(e & (~1));
18550         e_conv.is_owned = (e & 1) || (e == 0);
18551         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18552         e_conv = LightningError_clone(&e_conv);
18553         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18554         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
18555         return (uintptr_t)ret_conv;
18556 }
18557
18558 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18559         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
18560         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
18561         return ret_val;
18562 }
18563
18564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18565         if ((_res & 1) != 0) return;
18566         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18567         CHECK_ACCESS(_res_ptr);
18568         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
18569         FREE((void*)_res);
18570         CResult_boolLightningErrorZ_free(_res_conv);
18571 }
18572
18573 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
18574         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18575         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
18576         return (uintptr_t)ret_conv;
18577 }
18578 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18579         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
18580         intptr_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
18581         return ret_val;
18582 }
18583
18584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18585         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
18586         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18587         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
18588         return (uintptr_t)ret_conv;
18589 }
18590
18591 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
18592         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
18593         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
18594         return ((uintptr_t)ret_conv);
18595 }
18596 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18597         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
18598         intptr_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
18599         return ret_val;
18600 }
18601
18602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18603         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
18604         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
18605         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
18606         return ((uintptr_t)ret_conv);
18607 }
18608
18609 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) {
18610         LDKChannelAnnouncement a_conv;
18611         a_conv.inner = (void*)(a & (~1));
18612         a_conv.is_owned = (a & 1) || (a == 0);
18613         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18614         a_conv = ChannelAnnouncement_clone(&a_conv);
18615         LDKChannelUpdate b_conv;
18616         b_conv.inner = (void*)(b & (~1));
18617         b_conv.is_owned = (b & 1) || (b == 0);
18618         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18619         b_conv = ChannelUpdate_clone(&b_conv);
18620         LDKChannelUpdate c_conv;
18621         c_conv.inner = (void*)(c & (~1));
18622         c_conv.is_owned = (c & 1) || (c == 0);
18623         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
18624         c_conv = ChannelUpdate_clone(&c_conv);
18625         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
18626         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
18627         return ((uintptr_t)ret_conv);
18628 }
18629
18630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18631         if ((_res & 1) != 0) return;
18632         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18633         CHECK_ACCESS(_res_ptr);
18634         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
18635         FREE((void*)_res);
18636         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
18637 }
18638
18639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18640         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
18641         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18642         if (_res_constr.datalen > 0)
18643                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
18644         else
18645                 _res_constr.data = NULL;
18646         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18647         for (size_t h = 0; h < _res_constr.datalen; h++) {
18648                 int64_t _res_conv_59 = _res_vals[h];
18649                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
18650                 CHECK_ACCESS(_res_conv_59_ptr);
18651                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
18652                 FREE((void*)_res_conv_59);
18653                 _res_constr.data[h] = _res_conv_59_conv;
18654         }
18655         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18656         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
18657 }
18658
18659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18660         LDKCVec_NodeAnnouncementZ _res_constr;
18661         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18662         if (_res_constr.datalen > 0)
18663                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
18664         else
18665                 _res_constr.data = NULL;
18666         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18667         for (size_t s = 0; s < _res_constr.datalen; s++) {
18668                 int64_t _res_conv_18 = _res_vals[s];
18669                 LDKNodeAnnouncement _res_conv_18_conv;
18670                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
18671                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
18672                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
18673                 _res_constr.data[s] = _res_conv_18_conv;
18674         }
18675         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18676         CVec_NodeAnnouncementZ_free(_res_constr);
18677 }
18678
18679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18680         LDKCVec_PublicKeyZ _res_constr;
18681         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18682         if (_res_constr.datalen > 0)
18683                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
18684         else
18685                 _res_constr.data = NULL;
18686         for (size_t i = 0; i < _res_constr.datalen; i++) {
18687                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
18688                 LDKPublicKey _res_conv_8_ref;
18689                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
18690                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
18691                 _res_constr.data[i] = _res_conv_8_ref;
18692         }
18693         CVec_PublicKeyZ_free(_res_constr);
18694 }
18695
18696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18697         LDKCVec_u8Z o_ref;
18698         o_ref.datalen = (*env)->GetArrayLength(env, o);
18699         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
18700         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
18701         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18702         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
18703         return (uintptr_t)ret_conv;
18704 }
18705
18706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18707         LDKPeerHandleError e_conv;
18708         e_conv.inner = (void*)(e & (~1));
18709         e_conv.is_owned = (e & 1) || (e == 0);
18710         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18711         e_conv = PeerHandleError_clone(&e_conv);
18712         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18713         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
18714         return (uintptr_t)ret_conv;
18715 }
18716
18717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18718         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
18719         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
18720         return ret_val;
18721 }
18722
18723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18724         if ((_res & 1) != 0) return;
18725         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18726         CHECK_ACCESS(_res_ptr);
18727         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
18728         FREE((void*)_res);
18729         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
18730 }
18731
18732 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
18733         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18734         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
18735         return (uintptr_t)ret_conv;
18736 }
18737 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18738         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
18739         intptr_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
18740         return ret_val;
18741 }
18742
18743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18744         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
18745         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18746         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
18747         return (uintptr_t)ret_conv;
18748 }
18749
18750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
18751         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18752         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
18753         return (uintptr_t)ret_conv;
18754 }
18755
18756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18757         LDKPeerHandleError e_conv;
18758         e_conv.inner = (void*)(e & (~1));
18759         e_conv.is_owned = (e & 1) || (e == 0);
18760         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18761         e_conv = PeerHandleError_clone(&e_conv);
18762         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18763         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
18764         return (uintptr_t)ret_conv;
18765 }
18766
18767 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18768         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
18769         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
18770         return ret_val;
18771 }
18772
18773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18774         if ((_res & 1) != 0) return;
18775         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18776         CHECK_ACCESS(_res_ptr);
18777         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
18778         FREE((void*)_res);
18779         CResult_NonePeerHandleErrorZ_free(_res_conv);
18780 }
18781
18782 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
18783         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18784         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
18785         return (uintptr_t)ret_conv;
18786 }
18787 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18788         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
18789         intptr_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
18790         return ret_val;
18791 }
18792
18793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18794         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
18795         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18796         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
18797         return (uintptr_t)ret_conv;
18798 }
18799
18800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
18801         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18802         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
18803         return (uintptr_t)ret_conv;
18804 }
18805
18806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18807         LDKPeerHandleError e_conv;
18808         e_conv.inner = (void*)(e & (~1));
18809         e_conv.is_owned = (e & 1) || (e == 0);
18810         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18811         e_conv = PeerHandleError_clone(&e_conv);
18812         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18813         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
18814         return (uintptr_t)ret_conv;
18815 }
18816
18817 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18818         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
18819         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
18820         return ret_val;
18821 }
18822
18823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18824         if ((_res & 1) != 0) return;
18825         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18826         CHECK_ACCESS(_res_ptr);
18827         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
18828         FREE((void*)_res);
18829         CResult_boolPeerHandleErrorZ_free(_res_conv);
18830 }
18831
18832 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
18833         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18834         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
18835         return (uintptr_t)ret_conv;
18836 }
18837 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18838         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
18839         intptr_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
18840         return ret_val;
18841 }
18842
18843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18844         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
18845         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18846         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
18847         return (uintptr_t)ret_conv;
18848 }
18849
18850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18851         LDKNodeId o_conv;
18852         o_conv.inner = (void*)(o & (~1));
18853         o_conv.is_owned = (o & 1) || (o == 0);
18854         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18855         o_conv = NodeId_clone(&o_conv);
18856         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18857         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
18858         return (uintptr_t)ret_conv;
18859 }
18860
18861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18862         LDKDecodeError e_conv;
18863         e_conv.inner = (void*)(e & (~1));
18864         e_conv.is_owned = (e & 1) || (e == 0);
18865         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18866         e_conv = DecodeError_clone(&e_conv);
18867         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18868         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
18869         return (uintptr_t)ret_conv;
18870 }
18871
18872 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18873         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
18874         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
18875         return ret_val;
18876 }
18877
18878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18879         if ((_res & 1) != 0) return;
18880         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18881         CHECK_ACCESS(_res_ptr);
18882         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
18883         FREE((void*)_res);
18884         CResult_NodeIdDecodeErrorZ_free(_res_conv);
18885 }
18886
18887 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
18888         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18889         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
18890         return (uintptr_t)ret_conv;
18891 }
18892 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18893         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
18894         intptr_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
18895         return ret_val;
18896 }
18897
18898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18899         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
18900         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18901         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
18902         return (uintptr_t)ret_conv;
18903 }
18904
18905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18906         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18907         CHECK_ACCESS(o_ptr);
18908         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
18909         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
18910         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18911         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
18912         return (uintptr_t)ret_conv;
18913 }
18914
18915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18916         LDKDecodeError e_conv;
18917         e_conv.inner = (void*)(e & (~1));
18918         e_conv.is_owned = (e & 1) || (e == 0);
18919         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18920         e_conv = DecodeError_clone(&e_conv);
18921         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18922         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
18923         return (uintptr_t)ret_conv;
18924 }
18925
18926 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18927         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
18928         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
18929         return ret_val;
18930 }
18931
18932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18933         if ((_res & 1) != 0) return;
18934         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18935         CHECK_ACCESS(_res_ptr);
18936         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
18937         FREE((void*)_res);
18938         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
18939 }
18940
18941 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
18942         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18943         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
18944         return (uintptr_t)ret_conv;
18945 }
18946 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18947         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
18948         intptr_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
18949         return ret_val;
18950 }
18951
18952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18953         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
18954         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18955         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
18956         return (uintptr_t)ret_conv;
18957 }
18958
18959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18960         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18961         CHECK_ACCESS(o_ptr);
18962         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
18963         if (o_conv.free == LDKAccess_JCalls_free) {
18964                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18965                 LDKAccess_JCalls_cloned(&o_conv);
18966         }
18967         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
18968         *ret_copy = COption_AccessZ_some(o_conv);
18969         uintptr_t ret_ref = (uintptr_t)ret_copy;
18970         return ret_ref;
18971 }
18972
18973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
18974         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
18975         *ret_copy = COption_AccessZ_none();
18976         uintptr_t ret_ref = (uintptr_t)ret_copy;
18977         return ret_ref;
18978 }
18979
18980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18981         if ((_res & 1) != 0) return;
18982         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18983         CHECK_ACCESS(_res_ptr);
18984         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
18985         FREE((void*)_res);
18986         COption_AccessZ_free(_res_conv);
18987 }
18988
18989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18990         LDKDirectionalChannelInfo o_conv;
18991         o_conv.inner = (void*)(o & (~1));
18992         o_conv.is_owned = (o & 1) || (o == 0);
18993         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18994         o_conv = DirectionalChannelInfo_clone(&o_conv);
18995         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
18996         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
18997         return (uintptr_t)ret_conv;
18998 }
18999
19000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19001         LDKDecodeError e_conv;
19002         e_conv.inner = (void*)(e & (~1));
19003         e_conv.is_owned = (e & 1) || (e == 0);
19004         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19005         e_conv = DecodeError_clone(&e_conv);
19006         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
19007         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
19008         return (uintptr_t)ret_conv;
19009 }
19010
19011 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19012         LDKCResult_DirectionalChannelInfoDecodeErrorZ* o_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(o & ~1);
19013         jboolean ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(o_conv);
19014         return ret_val;
19015 }
19016
19017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19018         if ((_res & 1) != 0) return;
19019         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19020         CHECK_ACCESS(_res_ptr);
19021         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
19022         FREE((void*)_res);
19023         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
19024 }
19025
19026 static inline uintptr_t CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
19027         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
19028         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(arg);
19029         return (uintptr_t)ret_conv;
19030 }
19031 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19032         LDKCResult_DirectionalChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
19033         intptr_t ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
19034         return ret_val;
19035 }
19036
19037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19038         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
19039         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
19040         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
19041         return (uintptr_t)ret_conv;
19042 }
19043
19044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19045         LDKChannelInfo o_conv;
19046         o_conv.inner = (void*)(o & (~1));
19047         o_conv.is_owned = (o & 1) || (o == 0);
19048         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19049         o_conv = ChannelInfo_clone(&o_conv);
19050         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19051         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
19052         return (uintptr_t)ret_conv;
19053 }
19054
19055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19056         LDKDecodeError e_conv;
19057         e_conv.inner = (void*)(e & (~1));
19058         e_conv.is_owned = (e & 1) || (e == 0);
19059         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19060         e_conv = DecodeError_clone(&e_conv);
19061         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19062         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
19063         return (uintptr_t)ret_conv;
19064 }
19065
19066 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19067         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
19068         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
19069         return ret_val;
19070 }
19071
19072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19073         if ((_res & 1) != 0) return;
19074         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19075         CHECK_ACCESS(_res_ptr);
19076         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
19077         FREE((void*)_res);
19078         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
19079 }
19080
19081 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
19082         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19083         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
19084         return (uintptr_t)ret_conv;
19085 }
19086 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19087         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
19088         intptr_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
19089         return ret_val;
19090 }
19091
19092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19093         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
19094         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19095         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
19096         return (uintptr_t)ret_conv;
19097 }
19098
19099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19100         LDKRoutingFees o_conv;
19101         o_conv.inner = (void*)(o & (~1));
19102         o_conv.is_owned = (o & 1) || (o == 0);
19103         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19104         o_conv = RoutingFees_clone(&o_conv);
19105         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19106         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
19107         return (uintptr_t)ret_conv;
19108 }
19109
19110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19111         LDKDecodeError e_conv;
19112         e_conv.inner = (void*)(e & (~1));
19113         e_conv.is_owned = (e & 1) || (e == 0);
19114         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19115         e_conv = DecodeError_clone(&e_conv);
19116         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19117         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
19118         return (uintptr_t)ret_conv;
19119 }
19120
19121 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19122         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
19123         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
19124         return ret_val;
19125 }
19126
19127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19128         if ((_res & 1) != 0) return;
19129         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19130         CHECK_ACCESS(_res_ptr);
19131         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
19132         FREE((void*)_res);
19133         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
19134 }
19135
19136 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
19137         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19138         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
19139         return (uintptr_t)ret_conv;
19140 }
19141 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19142         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
19143         intptr_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
19144         return ret_val;
19145 }
19146
19147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19148         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
19149         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19150         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
19151         return (uintptr_t)ret_conv;
19152 }
19153
19154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19155         LDKNodeAnnouncementInfo o_conv;
19156         o_conv.inner = (void*)(o & (~1));
19157         o_conv.is_owned = (o & 1) || (o == 0);
19158         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19159         o_conv = NodeAnnouncementInfo_clone(&o_conv);
19160         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19161         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
19162         return (uintptr_t)ret_conv;
19163 }
19164
19165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19166         LDKDecodeError e_conv;
19167         e_conv.inner = (void*)(e & (~1));
19168         e_conv.is_owned = (e & 1) || (e == 0);
19169         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19170         e_conv = DecodeError_clone(&e_conv);
19171         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19172         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
19173         return (uintptr_t)ret_conv;
19174 }
19175
19176 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19177         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
19178         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
19179         return ret_val;
19180 }
19181
19182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19183         if ((_res & 1) != 0) return;
19184         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19185         CHECK_ACCESS(_res_ptr);
19186         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
19187         FREE((void*)_res);
19188         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
19189 }
19190
19191 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
19192         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19193         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
19194         return (uintptr_t)ret_conv;
19195 }
19196 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19197         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
19198         intptr_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
19199         return ret_val;
19200 }
19201
19202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19203         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
19204         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19205         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
19206         return (uintptr_t)ret_conv;
19207 }
19208
19209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19210         LDKCVec_u64Z _res_constr;
19211         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19212         if (_res_constr.datalen > 0)
19213                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
19214         else
19215                 _res_constr.data = NULL;
19216         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19217         for (size_t g = 0; g < _res_constr.datalen; g++) {
19218                 int64_t _res_conv_6 = _res_vals[g];
19219                 _res_constr.data[g] = _res_conv_6;
19220         }
19221         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19222         CVec_u64Z_free(_res_constr);
19223 }
19224
19225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19226         LDKNodeInfo o_conv;
19227         o_conv.inner = (void*)(o & (~1));
19228         o_conv.is_owned = (o & 1) || (o == 0);
19229         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19230         o_conv = NodeInfo_clone(&o_conv);
19231         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19232         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
19233         return (uintptr_t)ret_conv;
19234 }
19235
19236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19237         LDKDecodeError e_conv;
19238         e_conv.inner = (void*)(e & (~1));
19239         e_conv.is_owned = (e & 1) || (e == 0);
19240         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19241         e_conv = DecodeError_clone(&e_conv);
19242         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19243         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
19244         return (uintptr_t)ret_conv;
19245 }
19246
19247 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19248         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
19249         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
19250         return ret_val;
19251 }
19252
19253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19254         if ((_res & 1) != 0) return;
19255         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19256         CHECK_ACCESS(_res_ptr);
19257         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
19258         FREE((void*)_res);
19259         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
19260 }
19261
19262 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
19263         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19264         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
19265         return (uintptr_t)ret_conv;
19266 }
19267 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19268         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
19269         intptr_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
19270         return ret_val;
19271 }
19272
19273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19274         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
19275         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19276         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
19277         return (uintptr_t)ret_conv;
19278 }
19279
19280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19281         LDKNetworkGraph o_conv;
19282         o_conv.inner = (void*)(o & (~1));
19283         o_conv.is_owned = (o & 1) || (o == 0);
19284         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19285         o_conv = NetworkGraph_clone(&o_conv);
19286         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
19287         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
19288         return (uintptr_t)ret_conv;
19289 }
19290
19291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19292         LDKDecodeError e_conv;
19293         e_conv.inner = (void*)(e & (~1));
19294         e_conv.is_owned = (e & 1) || (e == 0);
19295         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19296         e_conv = DecodeError_clone(&e_conv);
19297         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
19298         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
19299         return (uintptr_t)ret_conv;
19300 }
19301
19302 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19303         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
19304         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
19305         return ret_val;
19306 }
19307
19308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19309         if ((_res & 1) != 0) return;
19310         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19311         CHECK_ACCESS(_res_ptr);
19312         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
19313         FREE((void*)_res);
19314         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
19315 }
19316
19317 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
19318         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
19319         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
19320         return (uintptr_t)ret_conv;
19321 }
19322 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19323         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
19324         intptr_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
19325         return ret_val;
19326 }
19327
19328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19329         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
19330         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
19331         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
19332         return (uintptr_t)ret_conv;
19333 }
19334
19335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
19336         LDKCVec_NetAddressZ o_constr;
19337         o_constr.datalen = (*env)->GetArrayLength(env, o);
19338         if (o_constr.datalen > 0)
19339                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19340         else
19341                 o_constr.data = NULL;
19342         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
19343         for (size_t m = 0; m < o_constr.datalen; m++) {
19344                 int64_t o_conv_12 = o_vals[m];
19345                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
19346                 CHECK_ACCESS(o_conv_12_ptr);
19347                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
19348                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
19349                 o_constr.data[m] = o_conv_12_conv;
19350         }
19351         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
19352         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19353         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
19354         uintptr_t ret_ref = (uintptr_t)ret_copy;
19355         return ret_ref;
19356 }
19357
19358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
19359         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19360         *ret_copy = COption_CVec_NetAddressZZ_none();
19361         uintptr_t ret_ref = (uintptr_t)ret_copy;
19362         return ret_ref;
19363 }
19364
19365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19366         if ((_res & 1) != 0) return;
19367         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19368         CHECK_ACCESS(_res_ptr);
19369         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
19370         FREE((void*)_res);
19371         COption_CVec_NetAddressZZ_free(_res_conv);
19372 }
19373
19374 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
19375         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19376         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
19377 uintptr_t ret_ref = (uintptr_t)ret_copy;
19378         return ret_ref;
19379 }
19380 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19381         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
19382         intptr_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
19383         return ret_val;
19384 }
19385
19386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19387         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
19388         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19389         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
19390         uintptr_t ret_ref = (uintptr_t)ret_copy;
19391         return ret_ref;
19392 }
19393
19394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19395         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19396         CHECK_ACCESS(o_ptr);
19397         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
19398         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
19399         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
19400         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
19401         return (uintptr_t)ret_conv;
19402 }
19403
19404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19405         LDKDecodeError e_conv;
19406         e_conv.inner = (void*)(e & (~1));
19407         e_conv.is_owned = (e & 1) || (e == 0);
19408         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19409         e_conv = DecodeError_clone(&e_conv);
19410         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
19411         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
19412         return (uintptr_t)ret_conv;
19413 }
19414
19415 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19416         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
19417         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
19418         return ret_val;
19419 }
19420
19421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19422         if ((_res & 1) != 0) return;
19423         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19424         CHECK_ACCESS(_res_ptr);
19425         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
19426         FREE((void*)_res);
19427         CResult_NetAddressDecodeErrorZ_free(_res_conv);
19428 }
19429
19430 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
19431         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
19432         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
19433         return (uintptr_t)ret_conv;
19434 }
19435 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19436         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
19437         intptr_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
19438         return ret_val;
19439 }
19440
19441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19442         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
19443         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
19444         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
19445         return (uintptr_t)ret_conv;
19446 }
19447
19448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19449         LDKCVec_UpdateAddHTLCZ _res_constr;
19450         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19451         if (_res_constr.datalen > 0)
19452                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
19453         else
19454                 _res_constr.data = NULL;
19455         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19456         for (size_t p = 0; p < _res_constr.datalen; p++) {
19457                 int64_t _res_conv_15 = _res_vals[p];
19458                 LDKUpdateAddHTLC _res_conv_15_conv;
19459                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
19460                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
19461                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
19462                 _res_constr.data[p] = _res_conv_15_conv;
19463         }
19464         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19465         CVec_UpdateAddHTLCZ_free(_res_constr);
19466 }
19467
19468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19469         LDKCVec_UpdateFulfillHTLCZ _res_constr;
19470         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19471         if (_res_constr.datalen > 0)
19472                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
19473         else
19474                 _res_constr.data = NULL;
19475         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19476         for (size_t t = 0; t < _res_constr.datalen; t++) {
19477                 int64_t _res_conv_19 = _res_vals[t];
19478                 LDKUpdateFulfillHTLC _res_conv_19_conv;
19479                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
19480                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
19481                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
19482                 _res_constr.data[t] = _res_conv_19_conv;
19483         }
19484         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19485         CVec_UpdateFulfillHTLCZ_free(_res_constr);
19486 }
19487
19488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19489         LDKCVec_UpdateFailHTLCZ _res_constr;
19490         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19491         if (_res_constr.datalen > 0)
19492                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
19493         else
19494                 _res_constr.data = NULL;
19495         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19496         for (size_t q = 0; q < _res_constr.datalen; q++) {
19497                 int64_t _res_conv_16 = _res_vals[q];
19498                 LDKUpdateFailHTLC _res_conv_16_conv;
19499                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
19500                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
19501                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
19502                 _res_constr.data[q] = _res_conv_16_conv;
19503         }
19504         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19505         CVec_UpdateFailHTLCZ_free(_res_constr);
19506 }
19507
19508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19509         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
19510         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19511         if (_res_constr.datalen > 0)
19512                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
19513         else
19514                 _res_constr.data = NULL;
19515         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19516         for (size_t z = 0; z < _res_constr.datalen; z++) {
19517                 int64_t _res_conv_25 = _res_vals[z];
19518                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
19519                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
19520                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
19521                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
19522                 _res_constr.data[z] = _res_conv_25_conv;
19523         }
19524         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19525         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
19526 }
19527
19528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19529         LDKAcceptChannel o_conv;
19530         o_conv.inner = (void*)(o & (~1));
19531         o_conv.is_owned = (o & 1) || (o == 0);
19532         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19533         o_conv = AcceptChannel_clone(&o_conv);
19534         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
19535         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
19536         return (uintptr_t)ret_conv;
19537 }
19538
19539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19540         LDKDecodeError e_conv;
19541         e_conv.inner = (void*)(e & (~1));
19542         e_conv.is_owned = (e & 1) || (e == 0);
19543         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19544         e_conv = DecodeError_clone(&e_conv);
19545         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
19546         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
19547         return (uintptr_t)ret_conv;
19548 }
19549
19550 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19551         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
19552         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
19553         return ret_val;
19554 }
19555
19556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19557         if ((_res & 1) != 0) return;
19558         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19559         CHECK_ACCESS(_res_ptr);
19560         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
19561         FREE((void*)_res);
19562         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
19563 }
19564
19565 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
19566         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
19567         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
19568         return (uintptr_t)ret_conv;
19569 }
19570 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19571         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
19572         intptr_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
19573         return ret_val;
19574 }
19575
19576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19577         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
19578         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
19579         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
19580         return (uintptr_t)ret_conv;
19581 }
19582
19583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19584         LDKAnnouncementSignatures o_conv;
19585         o_conv.inner = (void*)(o & (~1));
19586         o_conv.is_owned = (o & 1) || (o == 0);
19587         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19588         o_conv = AnnouncementSignatures_clone(&o_conv);
19589         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
19590         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
19591         return (uintptr_t)ret_conv;
19592 }
19593
19594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19595         LDKDecodeError e_conv;
19596         e_conv.inner = (void*)(e & (~1));
19597         e_conv.is_owned = (e & 1) || (e == 0);
19598         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19599         e_conv = DecodeError_clone(&e_conv);
19600         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
19601         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
19602         return (uintptr_t)ret_conv;
19603 }
19604
19605 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19606         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
19607         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
19608         return ret_val;
19609 }
19610
19611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19612         if ((_res & 1) != 0) return;
19613         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19614         CHECK_ACCESS(_res_ptr);
19615         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
19616         FREE((void*)_res);
19617         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
19618 }
19619
19620 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
19621         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
19622         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
19623         return (uintptr_t)ret_conv;
19624 }
19625 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19626         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
19627         intptr_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
19628         return ret_val;
19629 }
19630
19631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19632         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
19633         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
19634         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
19635         return (uintptr_t)ret_conv;
19636 }
19637
19638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19639         LDKChannelReestablish o_conv;
19640         o_conv.inner = (void*)(o & (~1));
19641         o_conv.is_owned = (o & 1) || (o == 0);
19642         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19643         o_conv = ChannelReestablish_clone(&o_conv);
19644         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
19645         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
19646         return (uintptr_t)ret_conv;
19647 }
19648
19649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19650         LDKDecodeError e_conv;
19651         e_conv.inner = (void*)(e & (~1));
19652         e_conv.is_owned = (e & 1) || (e == 0);
19653         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19654         e_conv = DecodeError_clone(&e_conv);
19655         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
19656         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
19657         return (uintptr_t)ret_conv;
19658 }
19659
19660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19661         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
19662         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
19663         return ret_val;
19664 }
19665
19666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19667         if ((_res & 1) != 0) return;
19668         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19669         CHECK_ACCESS(_res_ptr);
19670         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
19671         FREE((void*)_res);
19672         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
19673 }
19674
19675 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
19676         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
19677         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
19678         return (uintptr_t)ret_conv;
19679 }
19680 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19681         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
19682         intptr_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
19683         return ret_val;
19684 }
19685
19686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19687         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
19688         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
19689         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
19690         return (uintptr_t)ret_conv;
19691 }
19692
19693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19694         LDKClosingSigned o_conv;
19695         o_conv.inner = (void*)(o & (~1));
19696         o_conv.is_owned = (o & 1) || (o == 0);
19697         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19698         o_conv = ClosingSigned_clone(&o_conv);
19699         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
19700         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
19701         return (uintptr_t)ret_conv;
19702 }
19703
19704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19705         LDKDecodeError e_conv;
19706         e_conv.inner = (void*)(e & (~1));
19707         e_conv.is_owned = (e & 1) || (e == 0);
19708         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19709         e_conv = DecodeError_clone(&e_conv);
19710         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
19711         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
19712         return (uintptr_t)ret_conv;
19713 }
19714
19715 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19716         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
19717         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
19718         return ret_val;
19719 }
19720
19721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19722         if ((_res & 1) != 0) return;
19723         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19724         CHECK_ACCESS(_res_ptr);
19725         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
19726         FREE((void*)_res);
19727         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
19728 }
19729
19730 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
19731         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
19732         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
19733         return (uintptr_t)ret_conv;
19734 }
19735 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19736         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
19737         intptr_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
19738         return ret_val;
19739 }
19740
19741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19742         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
19743         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
19744         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
19745         return (uintptr_t)ret_conv;
19746 }
19747
19748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19749         LDKClosingSignedFeeRange o_conv;
19750         o_conv.inner = (void*)(o & (~1));
19751         o_conv.is_owned = (o & 1) || (o == 0);
19752         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19753         o_conv = ClosingSignedFeeRange_clone(&o_conv);
19754         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
19755         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
19756         return (uintptr_t)ret_conv;
19757 }
19758
19759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19760         LDKDecodeError e_conv;
19761         e_conv.inner = (void*)(e & (~1));
19762         e_conv.is_owned = (e & 1) || (e == 0);
19763         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19764         e_conv = DecodeError_clone(&e_conv);
19765         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
19766         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
19767         return (uintptr_t)ret_conv;
19768 }
19769
19770 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19771         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
19772         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
19773         return ret_val;
19774 }
19775
19776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19777         if ((_res & 1) != 0) return;
19778         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19779         CHECK_ACCESS(_res_ptr);
19780         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
19781         FREE((void*)_res);
19782         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
19783 }
19784
19785 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
19786         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
19787         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
19788         return (uintptr_t)ret_conv;
19789 }
19790 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19791         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
19792         intptr_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
19793         return ret_val;
19794 }
19795
19796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19797         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
19798         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
19799         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
19800         return (uintptr_t)ret_conv;
19801 }
19802
19803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19804         LDKCommitmentSigned o_conv;
19805         o_conv.inner = (void*)(o & (~1));
19806         o_conv.is_owned = (o & 1) || (o == 0);
19807         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19808         o_conv = CommitmentSigned_clone(&o_conv);
19809         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
19810         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
19811         return (uintptr_t)ret_conv;
19812 }
19813
19814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19815         LDKDecodeError e_conv;
19816         e_conv.inner = (void*)(e & (~1));
19817         e_conv.is_owned = (e & 1) || (e == 0);
19818         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19819         e_conv = DecodeError_clone(&e_conv);
19820         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
19821         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
19822         return (uintptr_t)ret_conv;
19823 }
19824
19825 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19826         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
19827         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
19828         return ret_val;
19829 }
19830
19831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19832         if ((_res & 1) != 0) return;
19833         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19834         CHECK_ACCESS(_res_ptr);
19835         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
19836         FREE((void*)_res);
19837         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
19838 }
19839
19840 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
19841         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
19842         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
19843         return (uintptr_t)ret_conv;
19844 }
19845 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19846         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
19847         intptr_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
19848         return ret_val;
19849 }
19850
19851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19852         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
19853         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
19854         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
19855         return (uintptr_t)ret_conv;
19856 }
19857
19858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19859         LDKFundingCreated o_conv;
19860         o_conv.inner = (void*)(o & (~1));
19861         o_conv.is_owned = (o & 1) || (o == 0);
19862         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19863         o_conv = FundingCreated_clone(&o_conv);
19864         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19865         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
19866         return (uintptr_t)ret_conv;
19867 }
19868
19869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19870         LDKDecodeError e_conv;
19871         e_conv.inner = (void*)(e & (~1));
19872         e_conv.is_owned = (e & 1) || (e == 0);
19873         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19874         e_conv = DecodeError_clone(&e_conv);
19875         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19876         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
19877         return (uintptr_t)ret_conv;
19878 }
19879
19880 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19881         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
19882         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
19883         return ret_val;
19884 }
19885
19886 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19887         if ((_res & 1) != 0) return;
19888         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19889         CHECK_ACCESS(_res_ptr);
19890         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
19891         FREE((void*)_res);
19892         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
19893 }
19894
19895 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
19896         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19897         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
19898         return (uintptr_t)ret_conv;
19899 }
19900 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19901         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
19902         intptr_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
19903         return ret_val;
19904 }
19905
19906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19907         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
19908         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19909         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
19910         return (uintptr_t)ret_conv;
19911 }
19912
19913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19914         LDKFundingSigned o_conv;
19915         o_conv.inner = (void*)(o & (~1));
19916         o_conv.is_owned = (o & 1) || (o == 0);
19917         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19918         o_conv = FundingSigned_clone(&o_conv);
19919         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19920         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
19921         return (uintptr_t)ret_conv;
19922 }
19923
19924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19925         LDKDecodeError e_conv;
19926         e_conv.inner = (void*)(e & (~1));
19927         e_conv.is_owned = (e & 1) || (e == 0);
19928         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19929         e_conv = DecodeError_clone(&e_conv);
19930         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19931         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
19932         return (uintptr_t)ret_conv;
19933 }
19934
19935 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19936         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
19937         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
19938         return ret_val;
19939 }
19940
19941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19942         if ((_res & 1) != 0) return;
19943         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19944         CHECK_ACCESS(_res_ptr);
19945         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
19946         FREE((void*)_res);
19947         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
19948 }
19949
19950 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
19951         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19952         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
19953         return (uintptr_t)ret_conv;
19954 }
19955 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19956         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
19957         intptr_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
19958         return ret_val;
19959 }
19960
19961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19962         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
19963         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19964         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
19965         return (uintptr_t)ret_conv;
19966 }
19967
19968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19969         LDKFundingLocked o_conv;
19970         o_conv.inner = (void*)(o & (~1));
19971         o_conv.is_owned = (o & 1) || (o == 0);
19972         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19973         o_conv = FundingLocked_clone(&o_conv);
19974         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
19975         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
19976         return (uintptr_t)ret_conv;
19977 }
19978
19979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19980         LDKDecodeError e_conv;
19981         e_conv.inner = (void*)(e & (~1));
19982         e_conv.is_owned = (e & 1) || (e == 0);
19983         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19984         e_conv = DecodeError_clone(&e_conv);
19985         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
19986         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
19987         return (uintptr_t)ret_conv;
19988 }
19989
19990 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19991         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
19992         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
19993         return ret_val;
19994 }
19995
19996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19997         if ((_res & 1) != 0) return;
19998         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19999         CHECK_ACCESS(_res_ptr);
20000         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
20001         FREE((void*)_res);
20002         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
20003 }
20004
20005 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
20006         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
20007         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
20008         return (uintptr_t)ret_conv;
20009 }
20010 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20011         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
20012         intptr_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
20013         return ret_val;
20014 }
20015
20016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20017         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
20018         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
20019         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
20020         return (uintptr_t)ret_conv;
20021 }
20022
20023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20024         LDKInit o_conv;
20025         o_conv.inner = (void*)(o & (~1));
20026         o_conv.is_owned = (o & 1) || (o == 0);
20027         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20028         o_conv = Init_clone(&o_conv);
20029         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
20030         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
20031         return (uintptr_t)ret_conv;
20032 }
20033
20034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20035         LDKDecodeError e_conv;
20036         e_conv.inner = (void*)(e & (~1));
20037         e_conv.is_owned = (e & 1) || (e == 0);
20038         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20039         e_conv = DecodeError_clone(&e_conv);
20040         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
20041         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
20042         return (uintptr_t)ret_conv;
20043 }
20044
20045 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20046         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
20047         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
20048         return ret_val;
20049 }
20050
20051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20052         if ((_res & 1) != 0) return;
20053         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20054         CHECK_ACCESS(_res_ptr);
20055         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
20056         FREE((void*)_res);
20057         CResult_InitDecodeErrorZ_free(_res_conv);
20058 }
20059
20060 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
20061         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
20062         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
20063         return (uintptr_t)ret_conv;
20064 }
20065 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20066         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
20067         intptr_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
20068         return ret_val;
20069 }
20070
20071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20072         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
20073         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
20074         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
20075         return (uintptr_t)ret_conv;
20076 }
20077
20078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20079         LDKOpenChannel o_conv;
20080         o_conv.inner = (void*)(o & (~1));
20081         o_conv.is_owned = (o & 1) || (o == 0);
20082         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20083         o_conv = OpenChannel_clone(&o_conv);
20084         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
20085         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
20086         return (uintptr_t)ret_conv;
20087 }
20088
20089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20090         LDKDecodeError e_conv;
20091         e_conv.inner = (void*)(e & (~1));
20092         e_conv.is_owned = (e & 1) || (e == 0);
20093         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20094         e_conv = DecodeError_clone(&e_conv);
20095         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
20096         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
20097         return (uintptr_t)ret_conv;
20098 }
20099
20100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20101         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
20102         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
20103         return ret_val;
20104 }
20105
20106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20107         if ((_res & 1) != 0) return;
20108         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20109         CHECK_ACCESS(_res_ptr);
20110         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
20111         FREE((void*)_res);
20112         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
20113 }
20114
20115 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
20116         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
20117         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
20118         return (uintptr_t)ret_conv;
20119 }
20120 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20121         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
20122         intptr_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
20123         return ret_val;
20124 }
20125
20126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20127         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
20128         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
20129         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
20130         return (uintptr_t)ret_conv;
20131 }
20132
20133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20134         LDKRevokeAndACK o_conv;
20135         o_conv.inner = (void*)(o & (~1));
20136         o_conv.is_owned = (o & 1) || (o == 0);
20137         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20138         o_conv = RevokeAndACK_clone(&o_conv);
20139         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
20140         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
20141         return (uintptr_t)ret_conv;
20142 }
20143
20144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20145         LDKDecodeError e_conv;
20146         e_conv.inner = (void*)(e & (~1));
20147         e_conv.is_owned = (e & 1) || (e == 0);
20148         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20149         e_conv = DecodeError_clone(&e_conv);
20150         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
20151         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
20152         return (uintptr_t)ret_conv;
20153 }
20154
20155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20156         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
20157         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
20158         return ret_val;
20159 }
20160
20161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20162         if ((_res & 1) != 0) return;
20163         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20164         CHECK_ACCESS(_res_ptr);
20165         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
20166         FREE((void*)_res);
20167         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
20168 }
20169
20170 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
20171         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
20172         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
20173         return (uintptr_t)ret_conv;
20174 }
20175 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20176         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
20177         intptr_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
20178         return ret_val;
20179 }
20180
20181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20182         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
20183         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
20184         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
20185         return (uintptr_t)ret_conv;
20186 }
20187
20188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20189         LDKShutdown o_conv;
20190         o_conv.inner = (void*)(o & (~1));
20191         o_conv.is_owned = (o & 1) || (o == 0);
20192         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20193         o_conv = Shutdown_clone(&o_conv);
20194         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
20195         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
20196         return (uintptr_t)ret_conv;
20197 }
20198
20199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20200         LDKDecodeError e_conv;
20201         e_conv.inner = (void*)(e & (~1));
20202         e_conv.is_owned = (e & 1) || (e == 0);
20203         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20204         e_conv = DecodeError_clone(&e_conv);
20205         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
20206         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
20207         return (uintptr_t)ret_conv;
20208 }
20209
20210 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20211         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
20212         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
20213         return ret_val;
20214 }
20215
20216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20217         if ((_res & 1) != 0) return;
20218         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20219         CHECK_ACCESS(_res_ptr);
20220         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
20221         FREE((void*)_res);
20222         CResult_ShutdownDecodeErrorZ_free(_res_conv);
20223 }
20224
20225 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
20226         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
20227         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
20228         return (uintptr_t)ret_conv;
20229 }
20230 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20231         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
20232         intptr_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
20233         return ret_val;
20234 }
20235
20236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20237         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
20238         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
20239         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
20240         return (uintptr_t)ret_conv;
20241 }
20242
20243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20244         LDKUpdateFailHTLC o_conv;
20245         o_conv.inner = (void*)(o & (~1));
20246         o_conv.is_owned = (o & 1) || (o == 0);
20247         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20248         o_conv = UpdateFailHTLC_clone(&o_conv);
20249         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
20250         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
20251         return (uintptr_t)ret_conv;
20252 }
20253
20254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20255         LDKDecodeError e_conv;
20256         e_conv.inner = (void*)(e & (~1));
20257         e_conv.is_owned = (e & 1) || (e == 0);
20258         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20259         e_conv = DecodeError_clone(&e_conv);
20260         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
20261         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
20262         return (uintptr_t)ret_conv;
20263 }
20264
20265 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20266         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
20267         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
20268         return ret_val;
20269 }
20270
20271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20272         if ((_res & 1) != 0) return;
20273         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20274         CHECK_ACCESS(_res_ptr);
20275         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
20276         FREE((void*)_res);
20277         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
20278 }
20279
20280 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
20281         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
20282         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
20283         return (uintptr_t)ret_conv;
20284 }
20285 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20286         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
20287         intptr_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
20288         return ret_val;
20289 }
20290
20291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20292         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
20293         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
20294         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
20295         return (uintptr_t)ret_conv;
20296 }
20297
20298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20299         LDKUpdateFailMalformedHTLC o_conv;
20300         o_conv.inner = (void*)(o & (~1));
20301         o_conv.is_owned = (o & 1) || (o == 0);
20302         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20303         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
20304         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
20305         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
20306         return (uintptr_t)ret_conv;
20307 }
20308
20309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20310         LDKDecodeError e_conv;
20311         e_conv.inner = (void*)(e & (~1));
20312         e_conv.is_owned = (e & 1) || (e == 0);
20313         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20314         e_conv = DecodeError_clone(&e_conv);
20315         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
20316         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
20317         return (uintptr_t)ret_conv;
20318 }
20319
20320 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20321         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
20322         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
20323         return ret_val;
20324 }
20325
20326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20327         if ((_res & 1) != 0) return;
20328         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20329         CHECK_ACCESS(_res_ptr);
20330         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
20331         FREE((void*)_res);
20332         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
20333 }
20334
20335 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
20336         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
20337         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
20338         return (uintptr_t)ret_conv;
20339 }
20340 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20341         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
20342         intptr_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
20343         return ret_val;
20344 }
20345
20346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20347         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
20348         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
20349         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
20350         return (uintptr_t)ret_conv;
20351 }
20352
20353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20354         LDKUpdateFee o_conv;
20355         o_conv.inner = (void*)(o & (~1));
20356         o_conv.is_owned = (o & 1) || (o == 0);
20357         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20358         o_conv = UpdateFee_clone(&o_conv);
20359         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
20360         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
20361         return (uintptr_t)ret_conv;
20362 }
20363
20364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20365         LDKDecodeError e_conv;
20366         e_conv.inner = (void*)(e & (~1));
20367         e_conv.is_owned = (e & 1) || (e == 0);
20368         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20369         e_conv = DecodeError_clone(&e_conv);
20370         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
20371         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
20372         return (uintptr_t)ret_conv;
20373 }
20374
20375 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20376         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
20377         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
20378         return ret_val;
20379 }
20380
20381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20382         if ((_res & 1) != 0) return;
20383         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20384         CHECK_ACCESS(_res_ptr);
20385         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
20386         FREE((void*)_res);
20387         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
20388 }
20389
20390 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
20391         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
20392         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
20393         return (uintptr_t)ret_conv;
20394 }
20395 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20396         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
20397         intptr_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
20398         return ret_val;
20399 }
20400
20401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20402         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
20403         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
20404         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
20405         return (uintptr_t)ret_conv;
20406 }
20407
20408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20409         LDKUpdateFulfillHTLC o_conv;
20410         o_conv.inner = (void*)(o & (~1));
20411         o_conv.is_owned = (o & 1) || (o == 0);
20412         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20413         o_conv = UpdateFulfillHTLC_clone(&o_conv);
20414         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
20415         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
20416         return (uintptr_t)ret_conv;
20417 }
20418
20419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20420         LDKDecodeError e_conv;
20421         e_conv.inner = (void*)(e & (~1));
20422         e_conv.is_owned = (e & 1) || (e == 0);
20423         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20424         e_conv = DecodeError_clone(&e_conv);
20425         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
20426         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
20427         return (uintptr_t)ret_conv;
20428 }
20429
20430 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20431         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
20432         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
20433         return ret_val;
20434 }
20435
20436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20437         if ((_res & 1) != 0) return;
20438         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20439         CHECK_ACCESS(_res_ptr);
20440         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
20441         FREE((void*)_res);
20442         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
20443 }
20444
20445 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
20446         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
20447         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
20448         return (uintptr_t)ret_conv;
20449 }
20450 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20451         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
20452         intptr_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
20453         return ret_val;
20454 }
20455
20456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20457         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
20458         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
20459         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
20460         return (uintptr_t)ret_conv;
20461 }
20462
20463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20464         LDKUpdateAddHTLC o_conv;
20465         o_conv.inner = (void*)(o & (~1));
20466         o_conv.is_owned = (o & 1) || (o == 0);
20467         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20468         o_conv = UpdateAddHTLC_clone(&o_conv);
20469         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
20470         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
20471         return (uintptr_t)ret_conv;
20472 }
20473
20474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20475         LDKDecodeError e_conv;
20476         e_conv.inner = (void*)(e & (~1));
20477         e_conv.is_owned = (e & 1) || (e == 0);
20478         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20479         e_conv = DecodeError_clone(&e_conv);
20480         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
20481         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
20482         return (uintptr_t)ret_conv;
20483 }
20484
20485 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20486         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
20487         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
20488         return ret_val;
20489 }
20490
20491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20492         if ((_res & 1) != 0) return;
20493         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20494         CHECK_ACCESS(_res_ptr);
20495         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
20496         FREE((void*)_res);
20497         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
20498 }
20499
20500 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
20501         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
20502         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
20503         return (uintptr_t)ret_conv;
20504 }
20505 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20506         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
20507         intptr_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
20508         return ret_val;
20509 }
20510
20511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20512         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
20513         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
20514         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
20515         return (uintptr_t)ret_conv;
20516 }
20517
20518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20519         LDKPing o_conv;
20520         o_conv.inner = (void*)(o & (~1));
20521         o_conv.is_owned = (o & 1) || (o == 0);
20522         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20523         o_conv = Ping_clone(&o_conv);
20524         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
20525         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
20526         return (uintptr_t)ret_conv;
20527 }
20528
20529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20530         LDKDecodeError e_conv;
20531         e_conv.inner = (void*)(e & (~1));
20532         e_conv.is_owned = (e & 1) || (e == 0);
20533         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20534         e_conv = DecodeError_clone(&e_conv);
20535         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
20536         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
20537         return (uintptr_t)ret_conv;
20538 }
20539
20540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20541         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
20542         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
20543         return ret_val;
20544 }
20545
20546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20547         if ((_res & 1) != 0) return;
20548         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20549         CHECK_ACCESS(_res_ptr);
20550         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
20551         FREE((void*)_res);
20552         CResult_PingDecodeErrorZ_free(_res_conv);
20553 }
20554
20555 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
20556         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
20557         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
20558         return (uintptr_t)ret_conv;
20559 }
20560 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20561         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
20562         intptr_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
20563         return ret_val;
20564 }
20565
20566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20567         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
20568         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
20569         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
20570         return (uintptr_t)ret_conv;
20571 }
20572
20573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20574         LDKPong o_conv;
20575         o_conv.inner = (void*)(o & (~1));
20576         o_conv.is_owned = (o & 1) || (o == 0);
20577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20578         o_conv = Pong_clone(&o_conv);
20579         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
20580         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
20581         return (uintptr_t)ret_conv;
20582 }
20583
20584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20585         LDKDecodeError e_conv;
20586         e_conv.inner = (void*)(e & (~1));
20587         e_conv.is_owned = (e & 1) || (e == 0);
20588         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20589         e_conv = DecodeError_clone(&e_conv);
20590         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
20591         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
20592         return (uintptr_t)ret_conv;
20593 }
20594
20595 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20596         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
20597         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
20598         return ret_val;
20599 }
20600
20601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20602         if ((_res & 1) != 0) return;
20603         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20604         CHECK_ACCESS(_res_ptr);
20605         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
20606         FREE((void*)_res);
20607         CResult_PongDecodeErrorZ_free(_res_conv);
20608 }
20609
20610 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
20611         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
20612         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
20613         return (uintptr_t)ret_conv;
20614 }
20615 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20616         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
20617         intptr_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
20618         return ret_val;
20619 }
20620
20621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20622         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
20623         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
20624         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
20625         return (uintptr_t)ret_conv;
20626 }
20627
20628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20629         LDKUnsignedChannelAnnouncement o_conv;
20630         o_conv.inner = (void*)(o & (~1));
20631         o_conv.is_owned = (o & 1) || (o == 0);
20632         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20633         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
20634         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
20635         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
20636         return (uintptr_t)ret_conv;
20637 }
20638
20639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20640         LDKDecodeError e_conv;
20641         e_conv.inner = (void*)(e & (~1));
20642         e_conv.is_owned = (e & 1) || (e == 0);
20643         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20644         e_conv = DecodeError_clone(&e_conv);
20645         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
20646         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
20647         return (uintptr_t)ret_conv;
20648 }
20649
20650 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20651         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
20652         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
20653         return ret_val;
20654 }
20655
20656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20657         if ((_res & 1) != 0) return;
20658         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20659         CHECK_ACCESS(_res_ptr);
20660         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
20661         FREE((void*)_res);
20662         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
20663 }
20664
20665 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
20666         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
20667         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
20668         return (uintptr_t)ret_conv;
20669 }
20670 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20671         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
20672         intptr_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
20673         return ret_val;
20674 }
20675
20676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20677         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
20678         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
20679         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
20680         return (uintptr_t)ret_conv;
20681 }
20682
20683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20684         LDKChannelAnnouncement o_conv;
20685         o_conv.inner = (void*)(o & (~1));
20686         o_conv.is_owned = (o & 1) || (o == 0);
20687         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20688         o_conv = ChannelAnnouncement_clone(&o_conv);
20689         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
20690         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
20691         return (uintptr_t)ret_conv;
20692 }
20693
20694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20695         LDKDecodeError e_conv;
20696         e_conv.inner = (void*)(e & (~1));
20697         e_conv.is_owned = (e & 1) || (e == 0);
20698         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20699         e_conv = DecodeError_clone(&e_conv);
20700         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
20701         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
20702         return (uintptr_t)ret_conv;
20703 }
20704
20705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20706         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
20707         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
20708         return ret_val;
20709 }
20710
20711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20712         if ((_res & 1) != 0) return;
20713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20714         CHECK_ACCESS(_res_ptr);
20715         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
20716         FREE((void*)_res);
20717         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
20718 }
20719
20720 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
20721         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
20722         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
20723         return (uintptr_t)ret_conv;
20724 }
20725 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20726         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
20727         intptr_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
20728         return ret_val;
20729 }
20730
20731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20732         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
20733         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
20734         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
20735         return (uintptr_t)ret_conv;
20736 }
20737
20738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20739         LDKUnsignedChannelUpdate o_conv;
20740         o_conv.inner = (void*)(o & (~1));
20741         o_conv.is_owned = (o & 1) || (o == 0);
20742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20743         o_conv = UnsignedChannelUpdate_clone(&o_conv);
20744         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
20745         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
20746         return (uintptr_t)ret_conv;
20747 }
20748
20749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20750         LDKDecodeError e_conv;
20751         e_conv.inner = (void*)(e & (~1));
20752         e_conv.is_owned = (e & 1) || (e == 0);
20753         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20754         e_conv = DecodeError_clone(&e_conv);
20755         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
20756         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
20757         return (uintptr_t)ret_conv;
20758 }
20759
20760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20761         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
20762         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
20763         return ret_val;
20764 }
20765
20766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20767         if ((_res & 1) != 0) return;
20768         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20769         CHECK_ACCESS(_res_ptr);
20770         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
20771         FREE((void*)_res);
20772         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
20773 }
20774
20775 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
20776         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
20777         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
20778         return (uintptr_t)ret_conv;
20779 }
20780 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20781         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
20782         intptr_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
20783         return ret_val;
20784 }
20785
20786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20787         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
20788         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
20789         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
20790         return (uintptr_t)ret_conv;
20791 }
20792
20793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20794         LDKChannelUpdate o_conv;
20795         o_conv.inner = (void*)(o & (~1));
20796         o_conv.is_owned = (o & 1) || (o == 0);
20797         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20798         o_conv = ChannelUpdate_clone(&o_conv);
20799         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20800         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
20801         return (uintptr_t)ret_conv;
20802 }
20803
20804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20805         LDKDecodeError e_conv;
20806         e_conv.inner = (void*)(e & (~1));
20807         e_conv.is_owned = (e & 1) || (e == 0);
20808         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20809         e_conv = DecodeError_clone(&e_conv);
20810         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20811         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
20812         return (uintptr_t)ret_conv;
20813 }
20814
20815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20816         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
20817         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
20818         return ret_val;
20819 }
20820
20821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20822         if ((_res & 1) != 0) return;
20823         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20824         CHECK_ACCESS(_res_ptr);
20825         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
20826         FREE((void*)_res);
20827         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
20828 }
20829
20830 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
20831         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20832         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
20833         return (uintptr_t)ret_conv;
20834 }
20835 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20836         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
20837         intptr_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
20838         return ret_val;
20839 }
20840
20841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20842         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
20843         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20844         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
20845         return (uintptr_t)ret_conv;
20846 }
20847
20848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20849         LDKErrorMessage o_conv;
20850         o_conv.inner = (void*)(o & (~1));
20851         o_conv.is_owned = (o & 1) || (o == 0);
20852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20853         o_conv = ErrorMessage_clone(&o_conv);
20854         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20855         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
20856         return (uintptr_t)ret_conv;
20857 }
20858
20859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20860         LDKDecodeError e_conv;
20861         e_conv.inner = (void*)(e & (~1));
20862         e_conv.is_owned = (e & 1) || (e == 0);
20863         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20864         e_conv = DecodeError_clone(&e_conv);
20865         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20866         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
20867         return (uintptr_t)ret_conv;
20868 }
20869
20870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20871         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
20872         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
20873         return ret_val;
20874 }
20875
20876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20877         if ((_res & 1) != 0) return;
20878         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20879         CHECK_ACCESS(_res_ptr);
20880         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
20881         FREE((void*)_res);
20882         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
20883 }
20884
20885 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
20886         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20887         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
20888         return (uintptr_t)ret_conv;
20889 }
20890 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20891         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
20892         intptr_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
20893         return ret_val;
20894 }
20895
20896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20897         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
20898         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20899         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
20900         return (uintptr_t)ret_conv;
20901 }
20902
20903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20904         LDKUnsignedNodeAnnouncement o_conv;
20905         o_conv.inner = (void*)(o & (~1));
20906         o_conv.is_owned = (o & 1) || (o == 0);
20907         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20908         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
20909         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20910         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
20911         return (uintptr_t)ret_conv;
20912 }
20913
20914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20915         LDKDecodeError e_conv;
20916         e_conv.inner = (void*)(e & (~1));
20917         e_conv.is_owned = (e & 1) || (e == 0);
20918         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20919         e_conv = DecodeError_clone(&e_conv);
20920         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20921         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
20922         return (uintptr_t)ret_conv;
20923 }
20924
20925 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20926         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
20927         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
20928         return ret_val;
20929 }
20930
20931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20932         if ((_res & 1) != 0) return;
20933         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20934         CHECK_ACCESS(_res_ptr);
20935         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
20936         FREE((void*)_res);
20937         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
20938 }
20939
20940 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
20941         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20942         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
20943         return (uintptr_t)ret_conv;
20944 }
20945 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20946         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
20947         intptr_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
20948         return ret_val;
20949 }
20950
20951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20952         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
20953         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20954         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
20955         return (uintptr_t)ret_conv;
20956 }
20957
20958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20959         LDKNodeAnnouncement o_conv;
20960         o_conv.inner = (void*)(o & (~1));
20961         o_conv.is_owned = (o & 1) || (o == 0);
20962         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20963         o_conv = NodeAnnouncement_clone(&o_conv);
20964         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20965         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
20966         return (uintptr_t)ret_conv;
20967 }
20968
20969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20970         LDKDecodeError e_conv;
20971         e_conv.inner = (void*)(e & (~1));
20972         e_conv.is_owned = (e & 1) || (e == 0);
20973         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20974         e_conv = DecodeError_clone(&e_conv);
20975         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20976         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
20977         return (uintptr_t)ret_conv;
20978 }
20979
20980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20981         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
20982         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
20983         return ret_val;
20984 }
20985
20986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20987         if ((_res & 1) != 0) return;
20988         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20989         CHECK_ACCESS(_res_ptr);
20990         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
20991         FREE((void*)_res);
20992         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
20993 }
20994
20995 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
20996         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20997         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
20998         return (uintptr_t)ret_conv;
20999 }
21000 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21001         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
21002         intptr_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
21003         return ret_val;
21004 }
21005
21006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21007         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
21008         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
21009         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
21010         return (uintptr_t)ret_conv;
21011 }
21012
21013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21014         LDKQueryShortChannelIds o_conv;
21015         o_conv.inner = (void*)(o & (~1));
21016         o_conv.is_owned = (o & 1) || (o == 0);
21017         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21018         o_conv = QueryShortChannelIds_clone(&o_conv);
21019         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
21020         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
21021         return (uintptr_t)ret_conv;
21022 }
21023
21024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21025         LDKDecodeError e_conv;
21026         e_conv.inner = (void*)(e & (~1));
21027         e_conv.is_owned = (e & 1) || (e == 0);
21028         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21029         e_conv = DecodeError_clone(&e_conv);
21030         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
21031         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
21032         return (uintptr_t)ret_conv;
21033 }
21034
21035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21036         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
21037         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
21038         return ret_val;
21039 }
21040
21041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21042         if ((_res & 1) != 0) return;
21043         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21044         CHECK_ACCESS(_res_ptr);
21045         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
21046         FREE((void*)_res);
21047         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
21048 }
21049
21050 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
21051         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
21052         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
21053         return (uintptr_t)ret_conv;
21054 }
21055 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21056         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
21057         intptr_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
21058         return ret_val;
21059 }
21060
21061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21062         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
21063         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
21064         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
21065         return (uintptr_t)ret_conv;
21066 }
21067
21068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21069         LDKReplyShortChannelIdsEnd o_conv;
21070         o_conv.inner = (void*)(o & (~1));
21071         o_conv.is_owned = (o & 1) || (o == 0);
21072         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21073         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
21074         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
21075         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
21076         return (uintptr_t)ret_conv;
21077 }
21078
21079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21080         LDKDecodeError e_conv;
21081         e_conv.inner = (void*)(e & (~1));
21082         e_conv.is_owned = (e & 1) || (e == 0);
21083         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21084         e_conv = DecodeError_clone(&e_conv);
21085         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
21086         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
21087         return (uintptr_t)ret_conv;
21088 }
21089
21090 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21091         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
21092         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
21093         return ret_val;
21094 }
21095
21096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21097         if ((_res & 1) != 0) return;
21098         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21099         CHECK_ACCESS(_res_ptr);
21100         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
21101         FREE((void*)_res);
21102         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
21103 }
21104
21105 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
21106         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
21107         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
21108         return (uintptr_t)ret_conv;
21109 }
21110 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21111         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
21112         intptr_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
21113         return ret_val;
21114 }
21115
21116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21117         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
21118         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
21119         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
21120         return (uintptr_t)ret_conv;
21121 }
21122
21123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21124         LDKQueryChannelRange o_conv;
21125         o_conv.inner = (void*)(o & (~1));
21126         o_conv.is_owned = (o & 1) || (o == 0);
21127         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21128         o_conv = QueryChannelRange_clone(&o_conv);
21129         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
21130         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
21131         return (uintptr_t)ret_conv;
21132 }
21133
21134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21135         LDKDecodeError e_conv;
21136         e_conv.inner = (void*)(e & (~1));
21137         e_conv.is_owned = (e & 1) || (e == 0);
21138         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21139         e_conv = DecodeError_clone(&e_conv);
21140         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
21141         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
21142         return (uintptr_t)ret_conv;
21143 }
21144
21145 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21146         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
21147         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
21148         return ret_val;
21149 }
21150
21151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21152         if ((_res & 1) != 0) return;
21153         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21154         CHECK_ACCESS(_res_ptr);
21155         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
21156         FREE((void*)_res);
21157         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
21158 }
21159
21160 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
21161         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
21162         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
21163         return (uintptr_t)ret_conv;
21164 }
21165 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21166         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
21167         intptr_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
21168         return ret_val;
21169 }
21170
21171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21172         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
21173         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
21174         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
21175         return (uintptr_t)ret_conv;
21176 }
21177
21178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21179         LDKReplyChannelRange o_conv;
21180         o_conv.inner = (void*)(o & (~1));
21181         o_conv.is_owned = (o & 1) || (o == 0);
21182         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21183         o_conv = ReplyChannelRange_clone(&o_conv);
21184         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
21185         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
21186         return (uintptr_t)ret_conv;
21187 }
21188
21189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21190         LDKDecodeError e_conv;
21191         e_conv.inner = (void*)(e & (~1));
21192         e_conv.is_owned = (e & 1) || (e == 0);
21193         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21194         e_conv = DecodeError_clone(&e_conv);
21195         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
21196         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
21197         return (uintptr_t)ret_conv;
21198 }
21199
21200 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21201         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
21202         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
21203         return ret_val;
21204 }
21205
21206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21207         if ((_res & 1) != 0) return;
21208         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21209         CHECK_ACCESS(_res_ptr);
21210         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
21211         FREE((void*)_res);
21212         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
21213 }
21214
21215 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
21216         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
21217         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
21218         return (uintptr_t)ret_conv;
21219 }
21220 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21221         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
21222         intptr_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
21223         return ret_val;
21224 }
21225
21226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21227         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
21228         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
21229         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
21230         return (uintptr_t)ret_conv;
21231 }
21232
21233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21234         LDKGossipTimestampFilter o_conv;
21235         o_conv.inner = (void*)(o & (~1));
21236         o_conv.is_owned = (o & 1) || (o == 0);
21237         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21238         o_conv = GossipTimestampFilter_clone(&o_conv);
21239         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
21240         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
21241         return (uintptr_t)ret_conv;
21242 }
21243
21244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21245         LDKDecodeError e_conv;
21246         e_conv.inner = (void*)(e & (~1));
21247         e_conv.is_owned = (e & 1) || (e == 0);
21248         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21249         e_conv = DecodeError_clone(&e_conv);
21250         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
21251         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
21252         return (uintptr_t)ret_conv;
21253 }
21254
21255 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21256         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
21257         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
21258         return ret_val;
21259 }
21260
21261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21262         if ((_res & 1) != 0) return;
21263         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21264         CHECK_ACCESS(_res_ptr);
21265         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
21266         FREE((void*)_res);
21267         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
21268 }
21269
21270 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
21271         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
21272         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
21273         return (uintptr_t)ret_conv;
21274 }
21275 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21276         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
21277         intptr_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
21278         return ret_val;
21279 }
21280
21281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21282         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
21283         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
21284         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
21285         return (uintptr_t)ret_conv;
21286 }
21287
21288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21289         LDKInvoice o_conv;
21290         o_conv.inner = (void*)(o & (~1));
21291         o_conv.is_owned = (o & 1) || (o == 0);
21292         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21293         o_conv = Invoice_clone(&o_conv);
21294         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
21295         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
21296         return (uintptr_t)ret_conv;
21297 }
21298
21299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21300         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
21301         CHECK_ACCESS(e_ptr);
21302         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
21303         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
21304         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
21305         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
21306         return (uintptr_t)ret_conv;
21307 }
21308
21309 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21310         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
21311         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
21312         return ret_val;
21313 }
21314
21315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21316         if ((_res & 1) != 0) return;
21317         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21318         CHECK_ACCESS(_res_ptr);
21319         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
21320         FREE((void*)_res);
21321         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
21322 }
21323
21324 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
21325         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
21326         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
21327         return (uintptr_t)ret_conv;
21328 }
21329 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21330         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
21331         intptr_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
21332         return ret_val;
21333 }
21334
21335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21336         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
21337         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
21338         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
21339         return (uintptr_t)ret_conv;
21340 }
21341
21342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21343         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21344         CHECK_ACCESS(o_ptr);
21345         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
21346         if (o_conv.free == LDKFilter_JCalls_free) {
21347                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21348                 LDKFilter_JCalls_cloned(&o_conv);
21349         }
21350         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
21351         *ret_copy = COption_FilterZ_some(o_conv);
21352         uintptr_t ret_ref = (uintptr_t)ret_copy;
21353         return ret_ref;
21354 }
21355
21356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
21357         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
21358         *ret_copy = COption_FilterZ_none();
21359         uintptr_t ret_ref = (uintptr_t)ret_copy;
21360         return ret_ref;
21361 }
21362
21363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21364         if ((_res & 1) != 0) return;
21365         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21366         CHECK_ACCESS(_res_ptr);
21367         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
21368         FREE((void*)_res);
21369         COption_FilterZ_free(_res_conv);
21370 }
21371
21372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21373         LDKLockedChannelMonitor o_conv;
21374         o_conv.inner = (void*)(o & (~1));
21375         o_conv.is_owned = (o & 1) || (o == 0);
21376         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21377         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
21378         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
21379         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
21380         return (uintptr_t)ret_conv;
21381 }
21382
21383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
21384         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
21385         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
21386         return (uintptr_t)ret_conv;
21387 }
21388
21389 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21390         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
21391         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
21392         return ret_val;
21393 }
21394
21395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21396         if ((_res & 1) != 0) return;
21397         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21398         CHECK_ACCESS(_res_ptr);
21399         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
21400         FREE((void*)_res);
21401         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
21402 }
21403
21404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21405         LDKCVec_OutPointZ _res_constr;
21406         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21407         if (_res_constr.datalen > 0)
21408                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
21409         else
21410                 _res_constr.data = NULL;
21411         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21412         for (size_t k = 0; k < _res_constr.datalen; k++) {
21413                 int64_t _res_conv_10 = _res_vals[k];
21414                 LDKOutPoint _res_conv_10_conv;
21415                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
21416                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
21417                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
21418                 _res_constr.data[k] = _res_conv_10_conv;
21419         }
21420         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21421         CVec_OutPointZ_free(_res_constr);
21422 }
21423
21424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21425         if ((this_ptr & 1) != 0) return;
21426         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21427         CHECK_ACCESS(this_ptr_ptr);
21428         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
21429         FREE((void*)this_ptr);
21430         PaymentPurpose_free(this_ptr_conv);
21431 }
21432
21433 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
21434         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
21435         *ret_copy = PaymentPurpose_clone(arg);
21436 uintptr_t ret_ref = (uintptr_t)ret_copy;
21437         return ret_ref;
21438 }
21439 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21440         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
21441         intptr_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
21442         return ret_val;
21443 }
21444
21445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21446         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
21447         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
21448         *ret_copy = PaymentPurpose_clone(orig_conv);
21449         uintptr_t ret_ref = (uintptr_t)ret_copy;
21450         return ret_ref;
21451 }
21452
21453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
21454         LDKThirtyTwoBytes payment_preimage_ref;
21455         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
21456         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
21457         LDKThirtyTwoBytes payment_secret_ref;
21458         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
21459         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
21460         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
21461         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
21462         uintptr_t ret_ref = (uintptr_t)ret_copy;
21463         return ret_ref;
21464 }
21465
21466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
21467         LDKThirtyTwoBytes a_ref;
21468         CHECK((*env)->GetArrayLength(env, a) == 32);
21469         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21470         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
21471         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
21472         uintptr_t ret_ref = (uintptr_t)ret_copy;
21473         return ret_ref;
21474 }
21475
21476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21477         if ((this_ptr & 1) != 0) return;
21478         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21479         CHECK_ACCESS(this_ptr_ptr);
21480         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
21481         FREE((void*)this_ptr);
21482         ClosureReason_free(this_ptr_conv);
21483 }
21484
21485 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
21486         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
21487         *ret_copy = ClosureReason_clone(arg);
21488 uintptr_t ret_ref = (uintptr_t)ret_copy;
21489         return ret_ref;
21490 }
21491 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21492         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
21493         intptr_t ret_val = ClosureReason_clone_ptr(arg_conv);
21494         return ret_val;
21495 }
21496
21497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21498         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
21499         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
21500         *ret_copy = ClosureReason_clone(orig_conv);
21501         uintptr_t ret_ref = (uintptr_t)ret_copy;
21502         return ret_ref;
21503 }
21504
21505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
21506         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
21507         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
21508         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
21509         uintptr_t ret_ref = (uintptr_t)ret_copy;
21510         return ret_ref;
21511 }
21512
21513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
21514         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
21515         *ret_copy = ClosureReason_holder_force_closed();
21516         uintptr_t ret_ref = (uintptr_t)ret_copy;
21517         return ret_ref;
21518 }
21519
21520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
21521         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
21522         *ret_copy = ClosureReason_cooperative_closure();
21523         uintptr_t ret_ref = (uintptr_t)ret_copy;
21524         return ret_ref;
21525 }
21526
21527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
21528         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
21529         *ret_copy = ClosureReason_commitment_tx_confirmed();
21530         uintptr_t ret_ref = (uintptr_t)ret_copy;
21531         return ret_ref;
21532 }
21533
21534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
21535         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
21536         *ret_copy = ClosureReason_funding_timed_out();
21537         uintptr_t ret_ref = (uintptr_t)ret_copy;
21538         return ret_ref;
21539 }
21540
21541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
21542         LDKStr err_conv = java_to_owned_str(env, err);
21543         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
21544         *ret_copy = ClosureReason_processing_error(err_conv);
21545         uintptr_t ret_ref = (uintptr_t)ret_copy;
21546         return ret_ref;
21547 }
21548
21549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
21550         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
21551         *ret_copy = ClosureReason_disconnected_peer();
21552         uintptr_t ret_ref = (uintptr_t)ret_copy;
21553         return ret_ref;
21554 }
21555
21556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
21557         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
21558         *ret_copy = ClosureReason_outdated_channel_manager();
21559         uintptr_t ret_ref = (uintptr_t)ret_copy;
21560         return ret_ref;
21561 }
21562
21563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
21564         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
21565         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
21566         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21567         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21568         CVec_u8Z_free(ret_var);
21569         return ret_arr;
21570 }
21571
21572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21573         LDKu8slice ser_ref;
21574         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21575         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21576         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
21577         *ret_conv = ClosureReason_read(ser_ref);
21578         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21579         return (uintptr_t)ret_conv;
21580 }
21581
21582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21583         if ((this_ptr & 1) != 0) return;
21584         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21585         CHECK_ACCESS(this_ptr_ptr);
21586         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
21587         FREE((void*)this_ptr);
21588         Event_free(this_ptr_conv);
21589 }
21590
21591 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
21592         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21593         *ret_copy = Event_clone(arg);
21594 uintptr_t ret_ref = (uintptr_t)ret_copy;
21595         return ret_ref;
21596 }
21597 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21598         LDKEvent* arg_conv = (LDKEvent*)arg;
21599         intptr_t ret_val = Event_clone_ptr(arg_conv);
21600         return ret_val;
21601 }
21602
21603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21604         LDKEvent* orig_conv = (LDKEvent*)orig;
21605         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21606         *ret_copy = Event_clone(orig_conv);
21607         uintptr_t ret_ref = (uintptr_t)ret_copy;
21608         return ret_ref;
21609 }
21610
21611 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) {
21612         LDKThirtyTwoBytes temporary_channel_id_ref;
21613         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
21614         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
21615         LDKCVec_u8Z output_script_ref;
21616         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
21617         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
21618         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
21619         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21620         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
21621         uintptr_t ret_ref = (uintptr_t)ret_copy;
21622         return ret_ref;
21623 }
21624
21625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amt, int64_t purpose) {
21626         LDKThirtyTwoBytes payment_hash_ref;
21627         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
21628         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
21629         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
21630         CHECK_ACCESS(purpose_ptr);
21631         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
21632         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
21633         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21634         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
21635         uintptr_t ret_ref = (uintptr_t)ret_copy;
21636         return ret_ref;
21637 }
21638
21639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1sent(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, int64_t fee_paid_msat) {
21640         LDKThirtyTwoBytes payment_id_ref;
21641         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
21642         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
21643         LDKThirtyTwoBytes payment_preimage_ref;
21644         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
21645         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
21646         LDKThirtyTwoBytes payment_hash_ref;
21647         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
21648         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
21649         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
21650         CHECK_ACCESS(fee_paid_msat_ptr);
21651         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
21652         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
21653         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21654         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
21655         uintptr_t ret_ref = (uintptr_t)ret_copy;
21656         return ret_ref;
21657 }
21658
21659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, jboolean rejected_by_dest, int64_t network_update, jboolean all_paths_failed, int64_tArray path, int64_t short_channel_id, int64_t retry) {
21660         LDKThirtyTwoBytes payment_id_ref;
21661         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
21662         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
21663         LDKThirtyTwoBytes payment_hash_ref;
21664         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
21665         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
21666         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
21667         CHECK_ACCESS(network_update_ptr);
21668         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
21669         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
21670         LDKCVec_RouteHopZ path_constr;
21671         path_constr.datalen = (*env)->GetArrayLength(env, path);
21672         if (path_constr.datalen > 0)
21673                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21674         else
21675                 path_constr.data = NULL;
21676         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
21677         for (size_t k = 0; k < path_constr.datalen; k++) {
21678                 int64_t path_conv_10 = path_vals[k];
21679                 LDKRouteHop path_conv_10_conv;
21680                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21681                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21682                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21683                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21684                 path_constr.data[k] = path_conv_10_conv;
21685         }
21686         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
21687         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
21688         CHECK_ACCESS(short_channel_id_ptr);
21689         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
21690         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
21691         LDKRouteParameters retry_conv;
21692         retry_conv.inner = (void*)(retry & (~1));
21693         retry_conv.is_owned = (retry & 1) || (retry == 0);
21694         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
21695         retry_conv = RouteParameters_clone(&retry_conv);
21696         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21697         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
21698         uintptr_t ret_ref = (uintptr_t)ret_copy;
21699         return ret_ref;
21700 }
21701
21702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
21703         LDKThirtyTwoBytes payment_id_ref;
21704         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
21705         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
21706         LDKThirtyTwoBytes payment_hash_ref;
21707         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
21708         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
21709         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21710         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
21711         uintptr_t ret_ref = (uintptr_t)ret_copy;
21712         return ret_ref;
21713 }
21714
21715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
21716         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21717         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
21718         uintptr_t ret_ref = (uintptr_t)ret_copy;
21719         return ret_ref;
21720 }
21721
21722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
21723         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
21724         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
21725         if (outputs_constr.datalen > 0)
21726                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
21727         else
21728                 outputs_constr.data = NULL;
21729         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
21730         for (size_t b = 0; b < outputs_constr.datalen; b++) {
21731                 int64_t outputs_conv_27 = outputs_vals[b];
21732                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
21733                 CHECK_ACCESS(outputs_conv_27_ptr);
21734                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
21735                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
21736                 outputs_constr.data[b] = outputs_conv_27_conv;
21737         }
21738         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
21739         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21740         *ret_copy = Event_spendable_outputs(outputs_constr);
21741         uintptr_t ret_ref = (uintptr_t)ret_copy;
21742         return ret_ref;
21743 }
21744
21745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
21746         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
21747         CHECK_ACCESS(fee_earned_msat_ptr);
21748         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
21749         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
21750         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21751         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
21752         uintptr_t ret_ref = (uintptr_t)ret_copy;
21753         return ret_ref;
21754 }
21755
21756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1closed(JNIEnv *env, jclass clz, int8_tArray channel_id, int64_t user_channel_id, int64_t reason) {
21757         LDKThirtyTwoBytes channel_id_ref;
21758         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
21759         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
21760         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
21761         CHECK_ACCESS(reason_ptr);
21762         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
21763         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
21764         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21765         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
21766         uintptr_t ret_ref = (uintptr_t)ret_copy;
21767         return ret_ref;
21768 }
21769
21770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
21771         LDKThirtyTwoBytes channel_id_ref;
21772         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
21773         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
21774         LDKTransaction transaction_ref;
21775         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
21776         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
21777         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
21778         transaction_ref.data_is_owned = true;
21779         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21780         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
21781         uintptr_t ret_ref = (uintptr_t)ret_copy;
21782         return ret_ref;
21783 }
21784
21785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1path_1successful(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path) {
21786         LDKThirtyTwoBytes payment_id_ref;
21787         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
21788         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
21789         LDKThirtyTwoBytes payment_hash_ref;
21790         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
21791         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
21792         LDKCVec_RouteHopZ path_constr;
21793         path_constr.datalen = (*env)->GetArrayLength(env, path);
21794         if (path_constr.datalen > 0)
21795                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21796         else
21797                 path_constr.data = NULL;
21798         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
21799         for (size_t k = 0; k < path_constr.datalen; k++) {
21800                 int64_t path_conv_10 = path_vals[k];
21801                 LDKRouteHop path_conv_10_conv;
21802                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21803                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21804                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21805                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21806                 path_constr.data[k] = path_conv_10_conv;
21807         }
21808         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
21809         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21810         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
21811         uintptr_t ret_ref = (uintptr_t)ret_copy;
21812         return ret_ref;
21813 }
21814
21815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
21816         LDKEvent* obj_conv = (LDKEvent*)obj;
21817         LDKCVec_u8Z ret_var = Event_write(obj_conv);
21818         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21819         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21820         CVec_u8Z_free(ret_var);
21821         return ret_arr;
21822 }
21823
21824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21825         LDKu8slice ser_ref;
21826         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21827         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21828         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
21829         *ret_conv = Event_read(ser_ref);
21830         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21831         return (uintptr_t)ret_conv;
21832 }
21833
21834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21835         if ((this_ptr & 1) != 0) return;
21836         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21837         CHECK_ACCESS(this_ptr_ptr);
21838         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
21839         FREE((void*)this_ptr);
21840         MessageSendEvent_free(this_ptr_conv);
21841 }
21842
21843 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
21844         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21845         *ret_copy = MessageSendEvent_clone(arg);
21846 uintptr_t ret_ref = (uintptr_t)ret_copy;
21847         return ret_ref;
21848 }
21849 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21850         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
21851         intptr_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
21852         return ret_val;
21853 }
21854
21855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21856         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
21857         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21858         *ret_copy = MessageSendEvent_clone(orig_conv);
21859         uintptr_t ret_ref = (uintptr_t)ret_copy;
21860         return ret_ref;
21861 }
21862
21863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
21864         LDKPublicKey node_id_ref;
21865         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21866         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21867         LDKAcceptChannel msg_conv;
21868         msg_conv.inner = (void*)(msg & (~1));
21869         msg_conv.is_owned = (msg & 1) || (msg == 0);
21870         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21871         msg_conv = AcceptChannel_clone(&msg_conv);
21872         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21873         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
21874         uintptr_t ret_ref = (uintptr_t)ret_copy;
21875         return ret_ref;
21876 }
21877
21878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
21879         LDKPublicKey node_id_ref;
21880         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21881         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21882         LDKOpenChannel msg_conv;
21883         msg_conv.inner = (void*)(msg & (~1));
21884         msg_conv.is_owned = (msg & 1) || (msg == 0);
21885         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21886         msg_conv = OpenChannel_clone(&msg_conv);
21887         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21888         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
21889         uintptr_t ret_ref = (uintptr_t)ret_copy;
21890         return ret_ref;
21891 }
21892
21893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
21894         LDKPublicKey node_id_ref;
21895         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21896         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21897         LDKFundingCreated msg_conv;
21898         msg_conv.inner = (void*)(msg & (~1));
21899         msg_conv.is_owned = (msg & 1) || (msg == 0);
21900         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21901         msg_conv = FundingCreated_clone(&msg_conv);
21902         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21903         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
21904         uintptr_t ret_ref = (uintptr_t)ret_copy;
21905         return ret_ref;
21906 }
21907
21908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
21909         LDKPublicKey node_id_ref;
21910         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21911         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21912         LDKFundingSigned msg_conv;
21913         msg_conv.inner = (void*)(msg & (~1));
21914         msg_conv.is_owned = (msg & 1) || (msg == 0);
21915         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21916         msg_conv = FundingSigned_clone(&msg_conv);
21917         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21918         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
21919         uintptr_t ret_ref = (uintptr_t)ret_copy;
21920         return ret_ref;
21921 }
21922
21923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
21924         LDKPublicKey node_id_ref;
21925         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21926         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21927         LDKFundingLocked msg_conv;
21928         msg_conv.inner = (void*)(msg & (~1));
21929         msg_conv.is_owned = (msg & 1) || (msg == 0);
21930         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21931         msg_conv = FundingLocked_clone(&msg_conv);
21932         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21933         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
21934         uintptr_t ret_ref = (uintptr_t)ret_copy;
21935         return ret_ref;
21936 }
21937
21938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
21939         LDKPublicKey node_id_ref;
21940         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21941         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21942         LDKAnnouncementSignatures msg_conv;
21943         msg_conv.inner = (void*)(msg & (~1));
21944         msg_conv.is_owned = (msg & 1) || (msg == 0);
21945         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21946         msg_conv = AnnouncementSignatures_clone(&msg_conv);
21947         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21948         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
21949         uintptr_t ret_ref = (uintptr_t)ret_copy;
21950         return ret_ref;
21951 }
21952
21953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
21954         LDKPublicKey node_id_ref;
21955         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21956         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21957         LDKCommitmentUpdate updates_conv;
21958         updates_conv.inner = (void*)(updates & (~1));
21959         updates_conv.is_owned = (updates & 1) || (updates == 0);
21960         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
21961         updates_conv = CommitmentUpdate_clone(&updates_conv);
21962         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21963         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
21964         uintptr_t ret_ref = (uintptr_t)ret_copy;
21965         return ret_ref;
21966 }
21967
21968 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) {
21969         LDKPublicKey node_id_ref;
21970         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21971         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21972         LDKRevokeAndACK msg_conv;
21973         msg_conv.inner = (void*)(msg & (~1));
21974         msg_conv.is_owned = (msg & 1) || (msg == 0);
21975         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21976         msg_conv = RevokeAndACK_clone(&msg_conv);
21977         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21978         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
21979         uintptr_t ret_ref = (uintptr_t)ret_copy;
21980         return ret_ref;
21981 }
21982
21983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
21984         LDKPublicKey node_id_ref;
21985         CHECK((*env)->GetArrayLength(env, node_id) == 33);
21986         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
21987         LDKClosingSigned msg_conv;
21988         msg_conv.inner = (void*)(msg & (~1));
21989         msg_conv.is_owned = (msg & 1) || (msg == 0);
21990         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21991         msg_conv = ClosingSigned_clone(&msg_conv);
21992         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21993         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
21994         uintptr_t ret_ref = (uintptr_t)ret_copy;
21995         return ret_ref;
21996 }
21997
21998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
21999         LDKPublicKey node_id_ref;
22000         CHECK((*env)->GetArrayLength(env, node_id) == 33);
22001         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
22002         LDKShutdown msg_conv;
22003         msg_conv.inner = (void*)(msg & (~1));
22004         msg_conv.is_owned = (msg & 1) || (msg == 0);
22005         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
22006         msg_conv = Shutdown_clone(&msg_conv);
22007         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
22008         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
22009         uintptr_t ret_ref = (uintptr_t)ret_copy;
22010         return ret_ref;
22011 }
22012
22013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
22014         LDKPublicKey node_id_ref;
22015         CHECK((*env)->GetArrayLength(env, node_id) == 33);
22016         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
22017         LDKChannelReestablish msg_conv;
22018         msg_conv.inner = (void*)(msg & (~1));
22019         msg_conv.is_owned = (msg & 1) || (msg == 0);
22020         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
22021         msg_conv = ChannelReestablish_clone(&msg_conv);
22022         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
22023         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
22024         uintptr_t ret_ref = (uintptr_t)ret_copy;
22025         return ret_ref;
22026 }
22027
22028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
22029         LDKChannelAnnouncement msg_conv;
22030         msg_conv.inner = (void*)(msg & (~1));
22031         msg_conv.is_owned = (msg & 1) || (msg == 0);
22032         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
22033         msg_conv = ChannelAnnouncement_clone(&msg_conv);
22034         LDKChannelUpdate update_msg_conv;
22035         update_msg_conv.inner = (void*)(update_msg & (~1));
22036         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
22037         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
22038         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
22039         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
22040         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
22041         uintptr_t ret_ref = (uintptr_t)ret_copy;
22042         return ret_ref;
22043 }
22044
22045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
22046         LDKNodeAnnouncement msg_conv;
22047         msg_conv.inner = (void*)(msg & (~1));
22048         msg_conv.is_owned = (msg & 1) || (msg == 0);
22049         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
22050         msg_conv = NodeAnnouncement_clone(&msg_conv);
22051         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
22052         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
22053         uintptr_t ret_ref = (uintptr_t)ret_copy;
22054         return ret_ref;
22055 }
22056
22057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
22058         LDKChannelUpdate msg_conv;
22059         msg_conv.inner = (void*)(msg & (~1));
22060         msg_conv.is_owned = (msg & 1) || (msg == 0);
22061         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
22062         msg_conv = ChannelUpdate_clone(&msg_conv);
22063         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
22064         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
22065         uintptr_t ret_ref = (uintptr_t)ret_copy;
22066         return ret_ref;
22067 }
22068
22069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
22070         LDKPublicKey node_id_ref;
22071         CHECK((*env)->GetArrayLength(env, node_id) == 33);
22072         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
22073         LDKChannelUpdate msg_conv;
22074         msg_conv.inner = (void*)(msg & (~1));
22075         msg_conv.is_owned = (msg & 1) || (msg == 0);
22076         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
22077         msg_conv = ChannelUpdate_clone(&msg_conv);
22078         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
22079         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
22080         uintptr_t ret_ref = (uintptr_t)ret_copy;
22081         return ret_ref;
22082 }
22083
22084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
22085         LDKPublicKey node_id_ref;
22086         CHECK((*env)->GetArrayLength(env, node_id) == 33);
22087         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
22088         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
22089         CHECK_ACCESS(action_ptr);
22090         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
22091         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
22092         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
22093         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
22094         uintptr_t ret_ref = (uintptr_t)ret_copy;
22095         return ret_ref;
22096 }
22097
22098 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) {
22099         LDKPublicKey node_id_ref;
22100         CHECK((*env)->GetArrayLength(env, node_id) == 33);
22101         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
22102         LDKQueryChannelRange msg_conv;
22103         msg_conv.inner = (void*)(msg & (~1));
22104         msg_conv.is_owned = (msg & 1) || (msg == 0);
22105         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
22106         msg_conv = QueryChannelRange_clone(&msg_conv);
22107         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
22108         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
22109         uintptr_t ret_ref = (uintptr_t)ret_copy;
22110         return ret_ref;
22111 }
22112
22113 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) {
22114         LDKPublicKey node_id_ref;
22115         CHECK((*env)->GetArrayLength(env, node_id) == 33);
22116         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
22117         LDKQueryShortChannelIds msg_conv;
22118         msg_conv.inner = (void*)(msg & (~1));
22119         msg_conv.is_owned = (msg & 1) || (msg == 0);
22120         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
22121         msg_conv = QueryShortChannelIds_clone(&msg_conv);
22122         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
22123         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
22124         uintptr_t ret_ref = (uintptr_t)ret_copy;
22125         return ret_ref;
22126 }
22127
22128 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) {
22129         LDKPublicKey node_id_ref;
22130         CHECK((*env)->GetArrayLength(env, node_id) == 33);
22131         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
22132         LDKReplyChannelRange msg_conv;
22133         msg_conv.inner = (void*)(msg & (~1));
22134         msg_conv.is_owned = (msg & 1) || (msg == 0);
22135         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
22136         msg_conv = ReplyChannelRange_clone(&msg_conv);
22137         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
22138         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
22139         uintptr_t ret_ref = (uintptr_t)ret_copy;
22140         return ret_ref;
22141 }
22142
22143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22144         if ((this_ptr & 1) != 0) return;
22145         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22146         CHECK_ACCESS(this_ptr_ptr);
22147         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
22148         FREE((void*)this_ptr);
22149         MessageSendEventsProvider_free(this_ptr_conv);
22150 }
22151
22152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22153         if ((this_ptr & 1) != 0) return;
22154         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22155         CHECK_ACCESS(this_ptr_ptr);
22156         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
22157         FREE((void*)this_ptr);
22158         EventsProvider_free(this_ptr_conv);
22159 }
22160
22161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22162         if ((this_ptr & 1) != 0) return;
22163         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22164         CHECK_ACCESS(this_ptr_ptr);
22165         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
22166         FREE((void*)this_ptr);
22167         EventHandler_free(this_ptr_conv);
22168 }
22169
22170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22171         if ((this_ptr & 1) != 0) return;
22172         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22173         CHECK_ACCESS(this_ptr_ptr);
22174         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
22175         FREE((void*)this_ptr);
22176         APIError_free(this_ptr_conv);
22177 }
22178
22179 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
22180         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
22181         *ret_copy = APIError_clone(arg);
22182 uintptr_t ret_ref = (uintptr_t)ret_copy;
22183         return ret_ref;
22184 }
22185 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22186         LDKAPIError* arg_conv = (LDKAPIError*)arg;
22187         intptr_t ret_val = APIError_clone_ptr(arg_conv);
22188         return ret_val;
22189 }
22190
22191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22192         LDKAPIError* orig_conv = (LDKAPIError*)orig;
22193         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
22194         *ret_copy = APIError_clone(orig_conv);
22195         uintptr_t ret_ref = (uintptr_t)ret_copy;
22196         return ret_ref;
22197 }
22198
22199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
22200         LDKStr err_conv = java_to_owned_str(env, err);
22201         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
22202         *ret_copy = APIError_apimisuse_error(err_conv);
22203         uintptr_t ret_ref = (uintptr_t)ret_copy;
22204         return ret_ref;
22205 }
22206
22207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
22208         LDKStr err_conv = java_to_owned_str(env, err);
22209         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
22210         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
22211         uintptr_t ret_ref = (uintptr_t)ret_copy;
22212         return ret_ref;
22213 }
22214
22215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
22216         LDKStr err_conv = java_to_owned_str(env, err);
22217         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
22218         *ret_copy = APIError_route_error(err_conv);
22219         uintptr_t ret_ref = (uintptr_t)ret_copy;
22220         return ret_ref;
22221 }
22222
22223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
22224         LDKStr err_conv = java_to_owned_str(env, err);
22225         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
22226         *ret_copy = APIError_channel_unavailable(err_conv);
22227         uintptr_t ret_ref = (uintptr_t)ret_copy;
22228         return ret_ref;
22229 }
22230
22231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
22232         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
22233         *ret_copy = APIError_monitor_update_failed();
22234         uintptr_t ret_ref = (uintptr_t)ret_copy;
22235         return ret_ref;
22236 }
22237
22238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
22239         LDKShutdownScript script_conv;
22240         script_conv.inner = (void*)(script & (~1));
22241         script_conv.is_owned = (script & 1) || (script == 0);
22242         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
22243         script_conv = ShutdownScript_clone(&script_conv);
22244         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
22245         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
22246         uintptr_t ret_ref = (uintptr_t)ret_copy;
22247         return ret_ref;
22248 }
22249
22250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
22251         LDKu8slice msg_ref;
22252         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
22253         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
22254         unsigned char sk_arr[32];
22255         CHECK((*env)->GetArrayLength(env, sk) == 32);
22256         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
22257         unsigned char (*sk_ref)[32] = &sk_arr;
22258         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22259         *ret_conv = sign(msg_ref, sk_ref);
22260         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
22261         return (uintptr_t)ret_conv;
22262 }
22263
22264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
22265         LDKu8slice msg_ref;
22266         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
22267         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
22268         LDKStr sig_conv = java_to_owned_str(env, sig);
22269         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22270         *ret_conv = recover_pk(msg_ref, sig_conv);
22271         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
22272         return (uintptr_t)ret_conv;
22273 }
22274
22275 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
22276         LDKu8slice msg_ref;
22277         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
22278         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
22279         LDKStr sig_conv = java_to_owned_str(env, sig);
22280         LDKPublicKey pk_ref;
22281         CHECK((*env)->GetArrayLength(env, pk) == 33);
22282         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
22283         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
22284         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
22285         return ret_val;
22286 }
22287
22288 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22289         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
22290         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
22291         return ret_conv;
22292 }
22293
22294 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
22295         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
22296         return ret_conv;
22297 }
22298
22299 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
22300         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
22301         return ret_conv;
22302 }
22303
22304 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
22305         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
22306         return ret_conv;
22307 }
22308
22309 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
22310         jclass ret_conv = LDKLevel_to_java(env, Level_info());
22311         return ret_conv;
22312 }
22313
22314 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
22315         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
22316         return ret_conv;
22317 }
22318
22319 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
22320         jclass ret_conv = LDKLevel_to_java(env, Level_error());
22321         return ret_conv;
22322 }
22323
22324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22325         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
22326         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
22327         jboolean ret_val = Level_eq(a_conv, b_conv);
22328         return ret_val;
22329 }
22330
22331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
22332         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
22333         int64_t ret_val = Level_hash(o_conv);
22334         return ret_val;
22335 }
22336
22337 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
22338         jclass ret_conv = LDKLevel_to_java(env, Level_max());
22339         return ret_conv;
22340 }
22341
22342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22343         LDKRecord this_obj_conv;
22344         this_obj_conv.inner = (void*)(this_obj & (~1));
22345         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22347         Record_free(this_obj_conv);
22348 }
22349
22350 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
22351         LDKRecord this_ptr_conv;
22352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22353         this_ptr_conv.is_owned = false;
22354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22355         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
22356         return ret_conv;
22357 }
22358
22359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
22360         LDKRecord this_ptr_conv;
22361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22362         this_ptr_conv.is_owned = false;
22363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22364         LDKLevel val_conv = LDKLevel_from_java(env, val);
22365         Record_set_level(&this_ptr_conv, val_conv);
22366 }
22367
22368 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
22369         LDKRecord this_ptr_conv;
22370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22371         this_ptr_conv.is_owned = false;
22372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22373         LDKStr ret_str = Record_get_args(&this_ptr_conv);
22374         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
22375         Str_free(ret_str);
22376         return ret_conv;
22377 }
22378
22379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
22380         LDKRecord this_ptr_conv;
22381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22382         this_ptr_conv.is_owned = false;
22383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22384         LDKStr val_conv = java_to_owned_str(env, val);
22385         Record_set_args(&this_ptr_conv, val_conv);
22386 }
22387
22388 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
22389         LDKRecord this_ptr_conv;
22390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22391         this_ptr_conv.is_owned = false;
22392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22393         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
22394         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
22395         Str_free(ret_str);
22396         return ret_conv;
22397 }
22398
22399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
22400         LDKRecord this_ptr_conv;
22401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22402         this_ptr_conv.is_owned = false;
22403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22404         LDKStr val_conv = java_to_owned_str(env, val);
22405         Record_set_module_path(&this_ptr_conv, val_conv);
22406 }
22407
22408 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
22409         LDKRecord this_ptr_conv;
22410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22411         this_ptr_conv.is_owned = false;
22412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22413         LDKStr ret_str = Record_get_file(&this_ptr_conv);
22414         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
22415         Str_free(ret_str);
22416         return ret_conv;
22417 }
22418
22419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
22420         LDKRecord this_ptr_conv;
22421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22422         this_ptr_conv.is_owned = false;
22423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22424         LDKStr val_conv = java_to_owned_str(env, val);
22425         Record_set_file(&this_ptr_conv, val_conv);
22426 }
22427
22428 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
22429         LDKRecord this_ptr_conv;
22430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22431         this_ptr_conv.is_owned = false;
22432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22433         int32_t ret_val = Record_get_line(&this_ptr_conv);
22434         return ret_val;
22435 }
22436
22437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22438         LDKRecord this_ptr_conv;
22439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22440         this_ptr_conv.is_owned = false;
22441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22442         Record_set_line(&this_ptr_conv, val);
22443 }
22444
22445 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
22446         LDKRecord ret_var = Record_clone(arg);
22447 uintptr_t ret_ref = 0;
22448 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22449 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22450 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22451 ret_ref = (uintptr_t)ret_var.inner;
22452 if (ret_var.is_owned) {
22453         ret_ref |= 1;
22454 }
22455         return ret_ref;
22456 }
22457 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22458         LDKRecord arg_conv;
22459         arg_conv.inner = (void*)(arg & (~1));
22460         arg_conv.is_owned = false;
22461         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22462         intptr_t ret_val = Record_clone_ptr(&arg_conv);
22463         return ret_val;
22464 }
22465
22466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22467         LDKRecord orig_conv;
22468         orig_conv.inner = (void*)(orig & (~1));
22469         orig_conv.is_owned = false;
22470         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22471         LDKRecord ret_var = Record_clone(&orig_conv);
22472         uintptr_t ret_ref = 0;
22473         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22474         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22476         ret_ref = (uintptr_t)ret_var.inner;
22477         if (ret_var.is_owned) {
22478                 ret_ref |= 1;
22479         }
22480         return ret_ref;
22481 }
22482
22483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
22484         if ((this_ptr & 1) != 0) return;
22485         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22486         CHECK_ACCESS(this_ptr_ptr);
22487         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
22488         FREE((void*)this_ptr);
22489         Logger_free(this_ptr_conv);
22490 }
22491
22492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22493         LDKChannelHandshakeConfig this_obj_conv;
22494         this_obj_conv.inner = (void*)(this_obj & (~1));
22495         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22497         ChannelHandshakeConfig_free(this_obj_conv);
22498 }
22499
22500 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
22501         LDKChannelHandshakeConfig this_ptr_conv;
22502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22503         this_ptr_conv.is_owned = false;
22504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22505         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
22506         return ret_val;
22507 }
22508
22509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22510         LDKChannelHandshakeConfig this_ptr_conv;
22511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22512         this_ptr_conv.is_owned = false;
22513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22514         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
22515 }
22516
22517 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22518         LDKChannelHandshakeConfig this_ptr_conv;
22519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22520         this_ptr_conv.is_owned = false;
22521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22522         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
22523         return ret_val;
22524 }
22525
22526 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) {
22527         LDKChannelHandshakeConfig this_ptr_conv;
22528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22529         this_ptr_conv.is_owned = false;
22530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22531         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
22532 }
22533
22534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22535         LDKChannelHandshakeConfig this_ptr_conv;
22536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22537         this_ptr_conv.is_owned = false;
22538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22539         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
22540         return ret_val;
22541 }
22542
22543 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) {
22544         LDKChannelHandshakeConfig this_ptr_conv;
22545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22546         this_ptr_conv.is_owned = false;
22547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22548         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
22549 }
22550
22551 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) {
22552         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
22553         uintptr_t ret_ref = 0;
22554         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22555         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22557         ret_ref = (uintptr_t)ret_var.inner;
22558         if (ret_var.is_owned) {
22559                 ret_ref |= 1;
22560         }
22561         return ret_ref;
22562 }
22563
22564 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
22565         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
22566 uintptr_t ret_ref = 0;
22567 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22568 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22569 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22570 ret_ref = (uintptr_t)ret_var.inner;
22571 if (ret_var.is_owned) {
22572         ret_ref |= 1;
22573 }
22574         return ret_ref;
22575 }
22576 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22577         LDKChannelHandshakeConfig arg_conv;
22578         arg_conv.inner = (void*)(arg & (~1));
22579         arg_conv.is_owned = false;
22580         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22581         intptr_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
22582         return ret_val;
22583 }
22584
22585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22586         LDKChannelHandshakeConfig orig_conv;
22587         orig_conv.inner = (void*)(orig & (~1));
22588         orig_conv.is_owned = false;
22589         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22590         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
22591         uintptr_t ret_ref = 0;
22592         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22593         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22595         ret_ref = (uintptr_t)ret_var.inner;
22596         if (ret_var.is_owned) {
22597                 ret_ref |= 1;
22598         }
22599         return ret_ref;
22600 }
22601
22602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
22603         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
22604         uintptr_t ret_ref = 0;
22605         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22606         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22608         ret_ref = (uintptr_t)ret_var.inner;
22609         if (ret_var.is_owned) {
22610                 ret_ref |= 1;
22611         }
22612         return ret_ref;
22613 }
22614
22615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22616         LDKChannelHandshakeLimits 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         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22620         ChannelHandshakeLimits_free(this_obj_conv);
22621 }
22622
22623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
22624         LDKChannelHandshakeLimits this_ptr_conv;
22625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22626         this_ptr_conv.is_owned = false;
22627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22628         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
22629         return ret_val;
22630 }
22631
22632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22633         LDKChannelHandshakeLimits this_ptr_conv;
22634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22635         this_ptr_conv.is_owned = false;
22636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22637         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
22638 }
22639
22640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22641         LDKChannelHandshakeLimits this_ptr_conv;
22642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22643         this_ptr_conv.is_owned = false;
22644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22645         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
22646         return ret_val;
22647 }
22648
22649 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) {
22650         LDKChannelHandshakeLimits this_ptr_conv;
22651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22652         this_ptr_conv.is_owned = false;
22653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22654         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
22655 }
22656
22657 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) {
22658         LDKChannelHandshakeLimits this_ptr_conv;
22659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22660         this_ptr_conv.is_owned = false;
22661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22662         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
22663         return ret_val;
22664 }
22665
22666 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) {
22667         LDKChannelHandshakeLimits this_ptr_conv;
22668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22669         this_ptr_conv.is_owned = false;
22670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22671         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
22672 }
22673
22674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
22675         LDKChannelHandshakeLimits this_ptr_conv;
22676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22677         this_ptr_conv.is_owned = false;
22678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22679         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
22680         return ret_val;
22681 }
22682
22683 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) {
22684         LDKChannelHandshakeLimits this_ptr_conv;
22685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22686         this_ptr_conv.is_owned = false;
22687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22688         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
22689 }
22690
22691 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
22692         LDKChannelHandshakeLimits this_ptr_conv;
22693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22694         this_ptr_conv.is_owned = false;
22695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22696         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
22697         return ret_val;
22698 }
22699
22700 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) {
22701         LDKChannelHandshakeLimits this_ptr_conv;
22702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22703         this_ptr_conv.is_owned = false;
22704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22705         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
22706 }
22707
22708 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
22709         LDKChannelHandshakeLimits this_ptr_conv;
22710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22711         this_ptr_conv.is_owned = false;
22712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22713         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
22714         return ret_val;
22715 }
22716
22717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
22718         LDKChannelHandshakeLimits this_ptr_conv;
22719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22720         this_ptr_conv.is_owned = false;
22721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22722         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
22723 }
22724
22725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
22726         LDKChannelHandshakeLimits this_ptr_conv;
22727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22728         this_ptr_conv.is_owned = false;
22729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22730         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
22731         return ret_val;
22732 }
22733
22734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22735         LDKChannelHandshakeLimits this_ptr_conv;
22736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22737         this_ptr_conv.is_owned = false;
22738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22739         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
22740 }
22741
22742 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22743         LDKChannelHandshakeLimits this_ptr_conv;
22744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22745         this_ptr_conv.is_owned = false;
22746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22747         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
22748         return ret_val;
22749 }
22750
22751 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) {
22752         LDKChannelHandshakeLimits this_ptr_conv;
22753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22754         this_ptr_conv.is_owned = false;
22755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22756         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
22757 }
22758
22759 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) {
22760         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);
22761         uintptr_t ret_ref = 0;
22762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22765         ret_ref = (uintptr_t)ret_var.inner;
22766         if (ret_var.is_owned) {
22767                 ret_ref |= 1;
22768         }
22769         return ret_ref;
22770 }
22771
22772 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
22773         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
22774 uintptr_t ret_ref = 0;
22775 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22776 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22777 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22778 ret_ref = (uintptr_t)ret_var.inner;
22779 if (ret_var.is_owned) {
22780         ret_ref |= 1;
22781 }
22782         return ret_ref;
22783 }
22784 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22785         LDKChannelHandshakeLimits arg_conv;
22786         arg_conv.inner = (void*)(arg & (~1));
22787         arg_conv.is_owned = false;
22788         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22789         intptr_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
22790         return ret_val;
22791 }
22792
22793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22794         LDKChannelHandshakeLimits orig_conv;
22795         orig_conv.inner = (void*)(orig & (~1));
22796         orig_conv.is_owned = false;
22797         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22798         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
22799         uintptr_t ret_ref = 0;
22800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22803         ret_ref = (uintptr_t)ret_var.inner;
22804         if (ret_var.is_owned) {
22805                 ret_ref |= 1;
22806         }
22807         return ret_ref;
22808 }
22809
22810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
22811         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
22812         uintptr_t ret_ref = 0;
22813         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22814         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22816         ret_ref = (uintptr_t)ret_var.inner;
22817         if (ret_var.is_owned) {
22818                 ret_ref |= 1;
22819         }
22820         return ret_ref;
22821 }
22822
22823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22824         LDKChannelConfig this_obj_conv;
22825         this_obj_conv.inner = (void*)(this_obj & (~1));
22826         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22828         ChannelConfig_free(this_obj_conv);
22829 }
22830
22831 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
22832         LDKChannelConfig this_ptr_conv;
22833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22834         this_ptr_conv.is_owned = false;
22835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22836         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
22837         return ret_val;
22838 }
22839
22840 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) {
22841         LDKChannelConfig this_ptr_conv;
22842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22843         this_ptr_conv.is_owned = false;
22844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22845         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
22846 }
22847
22848 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22849         LDKChannelConfig this_ptr_conv;
22850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22851         this_ptr_conv.is_owned = false;
22852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22853         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
22854         return ret_val;
22855 }
22856
22857 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) {
22858         LDKChannelConfig this_ptr_conv;
22859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22860         this_ptr_conv.is_owned = false;
22861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22862         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
22863 }
22864
22865 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
22866         LDKChannelConfig this_ptr_conv;
22867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22868         this_ptr_conv.is_owned = false;
22869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22870         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
22871         return ret_val;
22872 }
22873
22874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22875         LDKChannelConfig this_ptr_conv;
22876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22877         this_ptr_conv.is_owned = false;
22878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22879         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
22880 }
22881
22882 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
22883         LDKChannelConfig this_ptr_conv;
22884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22885         this_ptr_conv.is_owned = false;
22886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22887         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
22888         return ret_val;
22889 }
22890
22891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22892         LDKChannelConfig this_ptr_conv;
22893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22894         this_ptr_conv.is_owned = false;
22895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22896         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
22897 }
22898
22899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
22900         LDKChannelConfig this_ptr_conv;
22901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22902         this_ptr_conv.is_owned = false;
22903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22904         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
22905         return ret_val;
22906 }
22907
22908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
22909         LDKChannelConfig this_ptr_conv;
22910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22911         this_ptr_conv.is_owned = false;
22912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22913         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
22914 }
22915
22916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
22917         LDKChannelConfig this_ptr_conv;
22918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22919         this_ptr_conv.is_owned = false;
22920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22921         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
22922         return ret_val;
22923 }
22924
22925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22926         LDKChannelConfig this_ptr_conv;
22927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22928         this_ptr_conv.is_owned = false;
22929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22930         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
22931 }
22932
22933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1force_1close_1avoidance_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
22934         LDKChannelConfig this_ptr_conv;
22935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22936         this_ptr_conv.is_owned = false;
22937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22938         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
22939         return ret_val;
22940 }
22941
22942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1force_1close_1avoidance_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22943         LDKChannelConfig this_ptr_conv;
22944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22945         this_ptr_conv.is_owned = false;
22946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22947         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
22948 }
22949
22950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
22951         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
22952         uintptr_t ret_ref = 0;
22953         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22954         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22956         ret_ref = (uintptr_t)ret_var.inner;
22957         if (ret_var.is_owned) {
22958                 ret_ref |= 1;
22959         }
22960         return ret_ref;
22961 }
22962
22963 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
22964         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
22965 uintptr_t ret_ref = 0;
22966 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22967 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22968 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22969 ret_ref = (uintptr_t)ret_var.inner;
22970 if (ret_var.is_owned) {
22971         ret_ref |= 1;
22972 }
22973         return ret_ref;
22974 }
22975 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22976         LDKChannelConfig arg_conv;
22977         arg_conv.inner = (void*)(arg & (~1));
22978         arg_conv.is_owned = false;
22979         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22980         intptr_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
22981         return ret_val;
22982 }
22983
22984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22985         LDKChannelConfig orig_conv;
22986         orig_conv.inner = (void*)(orig & (~1));
22987         orig_conv.is_owned = false;
22988         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22989         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
22990         uintptr_t ret_ref = 0;
22991         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22992         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22994         ret_ref = (uintptr_t)ret_var.inner;
22995         if (ret_var.is_owned) {
22996                 ret_ref |= 1;
22997         }
22998         return ret_ref;
22999 }
23000
23001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
23002         LDKChannelConfig ret_var = ChannelConfig_default();
23003         uintptr_t ret_ref = 0;
23004         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23005         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23007         ret_ref = (uintptr_t)ret_var.inner;
23008         if (ret_var.is_owned) {
23009                 ret_ref |= 1;
23010         }
23011         return ret_ref;
23012 }
23013
23014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
23015         LDKChannelConfig obj_conv;
23016         obj_conv.inner = (void*)(obj & (~1));
23017         obj_conv.is_owned = false;
23018         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23019         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
23020         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23021         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23022         CVec_u8Z_free(ret_var);
23023         return ret_arr;
23024 }
23025
23026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23027         LDKu8slice ser_ref;
23028         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23029         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23030         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
23031         *ret_conv = ChannelConfig_read(ser_ref);
23032         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23033         return (uintptr_t)ret_conv;
23034 }
23035
23036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23037         LDKUserConfig this_obj_conv;
23038         this_obj_conv.inner = (void*)(this_obj & (~1));
23039         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23041         UserConfig_free(this_obj_conv);
23042 }
23043
23044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
23045         LDKUserConfig this_ptr_conv;
23046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23047         this_ptr_conv.is_owned = false;
23048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23049         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
23050         uintptr_t ret_ref = 0;
23051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23054         ret_ref = (uintptr_t)ret_var.inner;
23055         if (ret_var.is_owned) {
23056                 ret_ref |= 1;
23057         }
23058         return ret_ref;
23059 }
23060
23061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23062         LDKUserConfig this_ptr_conv;
23063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23064         this_ptr_conv.is_owned = false;
23065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23066         LDKChannelHandshakeConfig val_conv;
23067         val_conv.inner = (void*)(val & (~1));
23068         val_conv.is_owned = (val & 1) || (val == 0);
23069         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23070         val_conv = ChannelHandshakeConfig_clone(&val_conv);
23071         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
23072 }
23073
23074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
23075         LDKUserConfig this_ptr_conv;
23076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23077         this_ptr_conv.is_owned = false;
23078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23079         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
23080         uintptr_t ret_ref = 0;
23081         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23082         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23084         ret_ref = (uintptr_t)ret_var.inner;
23085         if (ret_var.is_owned) {
23086                 ret_ref |= 1;
23087         }
23088         return ret_ref;
23089 }
23090
23091 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) {
23092         LDKUserConfig this_ptr_conv;
23093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23094         this_ptr_conv.is_owned = false;
23095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23096         LDKChannelHandshakeLimits val_conv;
23097         val_conv.inner = (void*)(val & (~1));
23098         val_conv.is_owned = (val & 1) || (val == 0);
23099         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23100         val_conv = ChannelHandshakeLimits_clone(&val_conv);
23101         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
23102 }
23103
23104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
23105         LDKUserConfig this_ptr_conv;
23106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23107         this_ptr_conv.is_owned = false;
23108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23109         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
23110         uintptr_t ret_ref = 0;
23111         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23112         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23114         ret_ref = (uintptr_t)ret_var.inner;
23115         if (ret_var.is_owned) {
23116                 ret_ref |= 1;
23117         }
23118         return ret_ref;
23119 }
23120
23121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23122         LDKUserConfig this_ptr_conv;
23123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23124         this_ptr_conv.is_owned = false;
23125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23126         LDKChannelConfig val_conv;
23127         val_conv.inner = (void*)(val & (~1));
23128         val_conv.is_owned = (val & 1) || (val == 0);
23129         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23130         val_conv = ChannelConfig_clone(&val_conv);
23131         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
23132 }
23133
23134 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
23135         LDKUserConfig this_ptr_conv;
23136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23137         this_ptr_conv.is_owned = false;
23138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23139         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
23140         return ret_val;
23141 }
23142
23143 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) {
23144         LDKUserConfig this_ptr_conv;
23145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23146         this_ptr_conv.is_owned = false;
23147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23148         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
23149 }
23150
23151 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
23152         LDKUserConfig this_ptr_conv;
23153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23154         this_ptr_conv.is_owned = false;
23155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23156         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
23157         return ret_val;
23158 }
23159
23160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
23161         LDKUserConfig this_ptr_conv;
23162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23163         this_ptr_conv.is_owned = false;
23164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23165         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
23166 }
23167
23168 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, jboolean accept_inbound_channels_arg) {
23169         LDKChannelHandshakeConfig own_channel_config_arg_conv;
23170         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
23171         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
23172         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
23173         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
23174         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
23175         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
23176         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
23177         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
23178         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
23179         LDKChannelConfig channel_options_arg_conv;
23180         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
23181         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
23182         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
23183         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
23184         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, accept_inbound_channels_arg);
23185         uintptr_t ret_ref = 0;
23186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23189         ret_ref = (uintptr_t)ret_var.inner;
23190         if (ret_var.is_owned) {
23191                 ret_ref |= 1;
23192         }
23193         return ret_ref;
23194 }
23195
23196 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
23197         LDKUserConfig ret_var = UserConfig_clone(arg);
23198 uintptr_t ret_ref = 0;
23199 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23200 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23201 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23202 ret_ref = (uintptr_t)ret_var.inner;
23203 if (ret_var.is_owned) {
23204         ret_ref |= 1;
23205 }
23206         return ret_ref;
23207 }
23208 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23209         LDKUserConfig arg_conv;
23210         arg_conv.inner = (void*)(arg & (~1));
23211         arg_conv.is_owned = false;
23212         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23213         intptr_t ret_val = UserConfig_clone_ptr(&arg_conv);
23214         return ret_val;
23215 }
23216
23217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23218         LDKUserConfig orig_conv;
23219         orig_conv.inner = (void*)(orig & (~1));
23220         orig_conv.is_owned = false;
23221         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23222         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
23223         uintptr_t ret_ref = 0;
23224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23227         ret_ref = (uintptr_t)ret_var.inner;
23228         if (ret_var.is_owned) {
23229                 ret_ref |= 1;
23230         }
23231         return ret_ref;
23232 }
23233
23234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
23235         LDKUserConfig ret_var = UserConfig_default();
23236         uintptr_t ret_ref = 0;
23237         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23238         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23240         ret_ref = (uintptr_t)ret_var.inner;
23241         if (ret_var.is_owned) {
23242                 ret_ref |= 1;
23243         }
23244         return ret_ref;
23245 }
23246
23247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23248         LDKBestBlock this_obj_conv;
23249         this_obj_conv.inner = (void*)(this_obj & (~1));
23250         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23252         BestBlock_free(this_obj_conv);
23253 }
23254
23255 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
23256         LDKBestBlock ret_var = BestBlock_clone(arg);
23257 uintptr_t ret_ref = 0;
23258 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23259 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23260 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23261 ret_ref = (uintptr_t)ret_var.inner;
23262 if (ret_var.is_owned) {
23263         ret_ref |= 1;
23264 }
23265         return ret_ref;
23266 }
23267 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23268         LDKBestBlock arg_conv;
23269         arg_conv.inner = (void*)(arg & (~1));
23270         arg_conv.is_owned = false;
23271         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23272         intptr_t ret_val = BestBlock_clone_ptr(&arg_conv);
23273         return ret_val;
23274 }
23275
23276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23277         LDKBestBlock orig_conv;
23278         orig_conv.inner = (void*)(orig & (~1));
23279         orig_conv.is_owned = false;
23280         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23281         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
23282         uintptr_t ret_ref = 0;
23283         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23284         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23286         ret_ref = (uintptr_t)ret_var.inner;
23287         if (ret_var.is_owned) {
23288                 ret_ref |= 1;
23289         }
23290         return ret_ref;
23291 }
23292
23293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
23294         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
23295         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
23296         uintptr_t ret_ref = 0;
23297         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23298         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23300         ret_ref = (uintptr_t)ret_var.inner;
23301         if (ret_var.is_owned) {
23302                 ret_ref |= 1;
23303         }
23304         return ret_ref;
23305 }
23306
23307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
23308         LDKThirtyTwoBytes block_hash_ref;
23309         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
23310         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
23311         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
23312         uintptr_t ret_ref = 0;
23313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23316         ret_ref = (uintptr_t)ret_var.inner;
23317         if (ret_var.is_owned) {
23318                 ret_ref |= 1;
23319         }
23320         return ret_ref;
23321 }
23322
23323 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
23324         LDKBestBlock this_arg_conv;
23325         this_arg_conv.inner = (void*)(this_arg & (~1));
23326         this_arg_conv.is_owned = false;
23327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23328         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23329         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
23330         return ret_arr;
23331 }
23332
23333 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
23334         LDKBestBlock this_arg_conv;
23335         this_arg_conv.inner = (void*)(this_arg & (~1));
23336         this_arg_conv.is_owned = false;
23337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23338         int32_t ret_val = BestBlock_height(&this_arg_conv);
23339         return ret_val;
23340 }
23341
23342 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23343         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
23344         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
23345         return ret_conv;
23346 }
23347
23348 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
23349         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
23350         return ret_conv;
23351 }
23352
23353 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
23354         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
23355         return ret_conv;
23356 }
23357
23358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23359         if ((this_ptr & 1) != 0) return;
23360         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23361         CHECK_ACCESS(this_ptr_ptr);
23362         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
23363         FREE((void*)this_ptr);
23364         Access_free(this_ptr_conv);
23365 }
23366
23367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23368         if ((this_ptr & 1) != 0) return;
23369         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23370         CHECK_ACCESS(this_ptr_ptr);
23371         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
23372         FREE((void*)this_ptr);
23373         Listen_free(this_ptr_conv);
23374 }
23375
23376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23377         if ((this_ptr & 1) != 0) return;
23378         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23379         CHECK_ACCESS(this_ptr_ptr);
23380         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
23381         FREE((void*)this_ptr);
23382         Confirm_free(this_ptr_conv);
23383 }
23384
23385 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23386         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
23387         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
23388         return ret_conv;
23389 }
23390
23391 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
23392         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
23393         return ret_conv;
23394 }
23395
23396 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
23397         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
23398         return ret_conv;
23399 }
23400
23401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23402         if ((this_ptr & 1) != 0) return;
23403         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23404         CHECK_ACCESS(this_ptr_ptr);
23405         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
23406         FREE((void*)this_ptr);
23407         Watch_free(this_ptr_conv);
23408 }
23409
23410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23411         if ((this_ptr & 1) != 0) return;
23412         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23413         CHECK_ACCESS(this_ptr_ptr);
23414         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
23415         FREE((void*)this_ptr);
23416         Filter_free(this_ptr_conv);
23417 }
23418
23419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23420         LDKWatchedOutput this_obj_conv;
23421         this_obj_conv.inner = (void*)(this_obj & (~1));
23422         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23424         WatchedOutput_free(this_obj_conv);
23425 }
23426
23427 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
23428         LDKWatchedOutput this_ptr_conv;
23429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23430         this_ptr_conv.is_owned = false;
23431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23432         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23433         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
23434         return ret_arr;
23435 }
23436
23437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23438         LDKWatchedOutput this_ptr_conv;
23439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23440         this_ptr_conv.is_owned = false;
23441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23442         LDKThirtyTwoBytes val_ref;
23443         CHECK((*env)->GetArrayLength(env, val) == 32);
23444         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23445         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
23446 }
23447
23448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
23449         LDKWatchedOutput this_ptr_conv;
23450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23451         this_ptr_conv.is_owned = false;
23452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23453         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
23454         uintptr_t ret_ref = 0;
23455         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23456         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23457         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23458         ret_ref = (uintptr_t)ret_var.inner;
23459         if (ret_var.is_owned) {
23460                 ret_ref |= 1;
23461         }
23462         return ret_ref;
23463 }
23464
23465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23466         LDKWatchedOutput this_ptr_conv;
23467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23468         this_ptr_conv.is_owned = false;
23469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23470         LDKOutPoint val_conv;
23471         val_conv.inner = (void*)(val & (~1));
23472         val_conv.is_owned = (val & 1) || (val == 0);
23473         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23474         val_conv = OutPoint_clone(&val_conv);
23475         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
23476 }
23477
23478 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
23479         LDKWatchedOutput this_ptr_conv;
23480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23481         this_ptr_conv.is_owned = false;
23482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23483         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
23484         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23485         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23486         return ret_arr;
23487 }
23488
23489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23490         LDKWatchedOutput this_ptr_conv;
23491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23492         this_ptr_conv.is_owned = false;
23493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23494         LDKCVec_u8Z val_ref;
23495         val_ref.datalen = (*env)->GetArrayLength(env, val);
23496         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
23497         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
23498         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
23499 }
23500
23501 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) {
23502         LDKThirtyTwoBytes block_hash_arg_ref;
23503         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
23504         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
23505         LDKOutPoint outpoint_arg_conv;
23506         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23507         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23508         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23509         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23510         LDKCVec_u8Z script_pubkey_arg_ref;
23511         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
23512         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
23513         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
23514         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
23515         uintptr_t ret_ref = 0;
23516         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23517         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23519         ret_ref = (uintptr_t)ret_var.inner;
23520         if (ret_var.is_owned) {
23521                 ret_ref |= 1;
23522         }
23523         return ret_ref;
23524 }
23525
23526 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
23527         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
23528 uintptr_t ret_ref = 0;
23529 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23530 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23531 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23532 ret_ref = (uintptr_t)ret_var.inner;
23533 if (ret_var.is_owned) {
23534         ret_ref |= 1;
23535 }
23536         return ret_ref;
23537 }
23538 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23539         LDKWatchedOutput arg_conv;
23540         arg_conv.inner = (void*)(arg & (~1));
23541         arg_conv.is_owned = false;
23542         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23543         intptr_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
23544         return ret_val;
23545 }
23546
23547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23548         LDKWatchedOutput orig_conv;
23549         orig_conv.inner = (void*)(orig & (~1));
23550         orig_conv.is_owned = false;
23551         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23552         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
23553         uintptr_t ret_ref = 0;
23554         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23555         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23557         ret_ref = (uintptr_t)ret_var.inner;
23558         if (ret_var.is_owned) {
23559                 ret_ref |= 1;
23560         }
23561         return ret_ref;
23562 }
23563
23564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
23565         LDKWatchedOutput o_conv;
23566         o_conv.inner = (void*)(o & (~1));
23567         o_conv.is_owned = false;
23568         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23569         int64_t ret_val = WatchedOutput_hash(&o_conv);
23570         return ret_val;
23571 }
23572
23573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23574         if ((this_ptr & 1) != 0) return;
23575         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23576         CHECK_ACCESS(this_ptr_ptr);
23577         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
23578         FREE((void*)this_ptr);
23579         BroadcasterInterface_free(this_ptr_conv);
23580 }
23581
23582 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23583         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
23584         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
23585         return ret_conv;
23586 }
23587
23588 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
23589         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
23590         return ret_conv;
23591 }
23592
23593 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
23594         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
23595         return ret_conv;
23596 }
23597
23598 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
23599         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
23600         return ret_conv;
23601 }
23602
23603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23604         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
23605         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
23606         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
23607         return ret_val;
23608 }
23609
23610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23611         if ((this_ptr & 1) != 0) return;
23612         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23613         CHECK_ACCESS(this_ptr_ptr);
23614         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
23615         FREE((void*)this_ptr);
23616         FeeEstimator_free(this_ptr_conv);
23617 }
23618
23619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23620         LDKMonitorUpdateId this_obj_conv;
23621         this_obj_conv.inner = (void*)(this_obj & (~1));
23622         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23624         MonitorUpdateId_free(this_obj_conv);
23625 }
23626
23627 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
23628         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
23629 uintptr_t ret_ref = 0;
23630 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23631 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23632 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23633 ret_ref = (uintptr_t)ret_var.inner;
23634 if (ret_var.is_owned) {
23635         ret_ref |= 1;
23636 }
23637         return ret_ref;
23638 }
23639 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23640         LDKMonitorUpdateId arg_conv;
23641         arg_conv.inner = (void*)(arg & (~1));
23642         arg_conv.is_owned = false;
23643         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23644         intptr_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
23645         return ret_val;
23646 }
23647
23648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23649         LDKMonitorUpdateId orig_conv;
23650         orig_conv.inner = (void*)(orig & (~1));
23651         orig_conv.is_owned = false;
23652         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23653         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
23654         uintptr_t ret_ref = 0;
23655         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23656         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23658         ret_ref = (uintptr_t)ret_var.inner;
23659         if (ret_var.is_owned) {
23660                 ret_ref |= 1;
23661         }
23662         return ret_ref;
23663 }
23664
23665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
23666         LDKMonitorUpdateId o_conv;
23667         o_conv.inner = (void*)(o & (~1));
23668         o_conv.is_owned = false;
23669         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23670         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
23671         return ret_val;
23672 }
23673
23674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
23675         LDKMonitorUpdateId a_conv;
23676         a_conv.inner = (void*)(a & (~1));
23677         a_conv.is_owned = false;
23678         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23679         LDKMonitorUpdateId b_conv;
23680         b_conv.inner = (void*)(b & (~1));
23681         b_conv.is_owned = false;
23682         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
23683         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
23684         return ret_val;
23685 }
23686
23687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23688         if ((this_ptr & 1) != 0) return;
23689         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23690         CHECK_ACCESS(this_ptr_ptr);
23691         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
23692         FREE((void*)this_ptr);
23693         Persist_free(this_ptr_conv);
23694 }
23695
23696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23697         LDKLockedChannelMonitor this_obj_conv;
23698         this_obj_conv.inner = (void*)(this_obj & (~1));
23699         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23701         LockedChannelMonitor_free(this_obj_conv);
23702 }
23703
23704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23705         LDKChainMonitor this_obj_conv;
23706         this_obj_conv.inner = (void*)(this_obj & (~1));
23707         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23709         ChainMonitor_free(this_obj_conv);
23710 }
23711
23712 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) {
23713         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
23714         CHECK_ACCESS(chain_source_ptr);
23715         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
23716         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
23717         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
23718                 // Manually implement clone for Java trait instances
23719                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
23720                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23721                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
23722                 }
23723         }
23724         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23725         CHECK_ACCESS(broadcaster_ptr);
23726         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23727         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23728                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23729                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23730         }
23731         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23732         CHECK_ACCESS(logger_ptr);
23733         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23734         if (logger_conv.free == LDKLogger_JCalls_free) {
23735                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23736                 LDKLogger_JCalls_cloned(&logger_conv);
23737         }
23738         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
23739         CHECK_ACCESS(feeest_ptr);
23740         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
23741         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
23742                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23743                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
23744         }
23745         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
23746         CHECK_ACCESS(persister_ptr);
23747         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
23748         if (persister_conv.free == LDKPersist_JCalls_free) {
23749                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23750                 LDKPersist_JCalls_cloned(&persister_conv);
23751         }
23752         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
23753         uintptr_t ret_ref = 0;
23754         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23755         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23757         ret_ref = (uintptr_t)ret_var.inner;
23758         if (ret_var.is_owned) {
23759                 ret_ref |= 1;
23760         }
23761         return ret_ref;
23762 }
23763
23764 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray ignored_channels) {
23765         LDKChainMonitor this_arg_conv;
23766         this_arg_conv.inner = (void*)(this_arg & (~1));
23767         this_arg_conv.is_owned = false;
23768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23769         LDKCVec_ChannelDetailsZ ignored_channels_constr;
23770         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
23771         if (ignored_channels_constr.datalen > 0)
23772                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23773         else
23774                 ignored_channels_constr.data = NULL;
23775         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
23776         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
23777                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
23778                 LDKChannelDetails ignored_channels_conv_16_conv;
23779                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
23780                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
23781                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
23782                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
23783                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
23784         }
23785         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
23786         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
23787         int64_tArray ret_arr = NULL;
23788         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
23789         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
23790         for (size_t j = 0; j < ret_var.datalen; j++) {
23791                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23792                 *ret_conv_9_copy = ret_var.data[j];
23793                 uintptr_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
23794                 ret_arr_ptr[j] = ret_conv_9_ref;
23795         }
23796         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
23797         FREE(ret_var.data);
23798         return ret_arr;
23799 }
23800
23801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
23802         LDKChainMonitor this_arg_conv;
23803         this_arg_conv.inner = (void*)(this_arg & (~1));
23804         this_arg_conv.is_owned = false;
23805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23806         LDKOutPoint funding_txo_conv;
23807         funding_txo_conv.inner = (void*)(funding_txo & (~1));
23808         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
23809         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23810         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23811         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23812         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
23813         return (uintptr_t)ret_conv;
23814 }
23815
23816 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
23817         LDKChainMonitor this_arg_conv;
23818         this_arg_conv.inner = (void*)(this_arg & (~1));
23819         this_arg_conv.is_owned = false;
23820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23821         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
23822         int64_tArray ret_arr = NULL;
23823         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
23824         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
23825         for (size_t k = 0; k < ret_var.datalen; k++) {
23826                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
23827                 uintptr_t ret_conv_10_ref = 0;
23828                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23829                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23830                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
23831                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
23832                 if (ret_conv_10_var.is_owned) {
23833                         ret_conv_10_ref |= 1;
23834                 }
23835                 ret_arr_ptr[k] = ret_conv_10_ref;
23836         }
23837         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
23838         FREE(ret_var.data);
23839         return ret_arr;
23840 }
23841
23842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1channel_1monitor_1updated(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t completed_update_id) {
23843         LDKChainMonitor this_arg_conv;
23844         this_arg_conv.inner = (void*)(this_arg & (~1));
23845         this_arg_conv.is_owned = false;
23846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23847         LDKOutPoint funding_txo_conv;
23848         funding_txo_conv.inner = (void*)(funding_txo & (~1));
23849         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
23850         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23851         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23852         LDKMonitorUpdateId completed_update_id_conv;
23853         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
23854         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
23855         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
23856         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
23857         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
23858         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
23859         return (uintptr_t)ret_conv;
23860 }
23861
23862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
23863         LDKChainMonitor this_arg_conv;
23864         this_arg_conv.inner = (void*)(this_arg & (~1));
23865         this_arg_conv.is_owned = false;
23866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23867         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
23868         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
23869         return (uintptr_t)ret_ret;
23870 }
23871
23872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
23873         LDKChainMonitor this_arg_conv;
23874         this_arg_conv.inner = (void*)(this_arg & (~1));
23875         this_arg_conv.is_owned = false;
23876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23877         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
23878         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
23879         return (uintptr_t)ret_ret;
23880 }
23881
23882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
23883         LDKChainMonitor this_arg_conv;
23884         this_arg_conv.inner = (void*)(this_arg & (~1));
23885         this_arg_conv.is_owned = false;
23886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23887         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
23888         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
23889         return (uintptr_t)ret_ret;
23890 }
23891
23892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
23893         LDKChainMonitor this_arg_conv;
23894         this_arg_conv.inner = (void*)(this_arg & (~1));
23895         this_arg_conv.is_owned = false;
23896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23897         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
23898         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
23899         return (uintptr_t)ret_ret;
23900 }
23901
23902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23903         LDKChannelMonitorUpdate this_obj_conv;
23904         this_obj_conv.inner = (void*)(this_obj & (~1));
23905         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23907         ChannelMonitorUpdate_free(this_obj_conv);
23908 }
23909
23910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23911         LDKChannelMonitorUpdate this_ptr_conv;
23912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23913         this_ptr_conv.is_owned = false;
23914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23915         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
23916         return ret_val;
23917 }
23918
23919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23920         LDKChannelMonitorUpdate this_ptr_conv;
23921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23922         this_ptr_conv.is_owned = false;
23923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23924         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
23925 }
23926
23927 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
23928         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
23929 uintptr_t ret_ref = 0;
23930 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23931 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23932 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23933 ret_ref = (uintptr_t)ret_var.inner;
23934 if (ret_var.is_owned) {
23935         ret_ref |= 1;
23936 }
23937         return ret_ref;
23938 }
23939 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23940         LDKChannelMonitorUpdate arg_conv;
23941         arg_conv.inner = (void*)(arg & (~1));
23942         arg_conv.is_owned = false;
23943         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23944         intptr_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
23945         return ret_val;
23946 }
23947
23948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23949         LDKChannelMonitorUpdate orig_conv;
23950         orig_conv.inner = (void*)(orig & (~1));
23951         orig_conv.is_owned = false;
23952         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23953         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
23954         uintptr_t ret_ref = 0;
23955         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23956         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23958         ret_ref = (uintptr_t)ret_var.inner;
23959         if (ret_var.is_owned) {
23960                 ret_ref |= 1;
23961         }
23962         return ret_ref;
23963 }
23964
23965 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
23966         LDKChannelMonitorUpdate obj_conv;
23967         obj_conv.inner = (void*)(obj & (~1));
23968         obj_conv.is_owned = false;
23969         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23970         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
23971         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23972         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23973         CVec_u8Z_free(ret_var);
23974         return ret_arr;
23975 }
23976
23977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23978         LDKu8slice ser_ref;
23979         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23980         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23981         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
23982         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
23983         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23984         return (uintptr_t)ret_conv;
23985 }
23986
23987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23988         if ((this_ptr & 1) != 0) return;
23989         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23990         CHECK_ACCESS(this_ptr_ptr);
23991         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
23992         FREE((void*)this_ptr);
23993         MonitorEvent_free(this_ptr_conv);
23994 }
23995
23996 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
23997         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23998         *ret_copy = MonitorEvent_clone(arg);
23999 uintptr_t ret_ref = (uintptr_t)ret_copy;
24000         return ret_ref;
24001 }
24002 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24003         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
24004         intptr_t ret_val = MonitorEvent_clone_ptr(arg_conv);
24005         return ret_val;
24006 }
24007
24008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24009         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
24010         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
24011         *ret_copy = MonitorEvent_clone(orig_conv);
24012         uintptr_t ret_ref = (uintptr_t)ret_copy;
24013         return ret_ref;
24014 }
24015
24016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
24017         LDKHTLCUpdate a_conv;
24018         a_conv.inner = (void*)(a & (~1));
24019         a_conv.is_owned = (a & 1) || (a == 0);
24020         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24021         a_conv = HTLCUpdate_clone(&a_conv);
24022         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
24023         *ret_copy = MonitorEvent_htlcevent(a_conv);
24024         uintptr_t ret_ref = (uintptr_t)ret_copy;
24025         return ret_ref;
24026 }
24027
24028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
24029         LDKOutPoint a_conv;
24030         a_conv.inner = (void*)(a & (~1));
24031         a_conv.is_owned = (a & 1) || (a == 0);
24032         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24033         a_conv = OutPoint_clone(&a_conv);
24034         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
24035         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
24036         uintptr_t ret_ref = (uintptr_t)ret_copy;
24037         return ret_ref;
24038 }
24039
24040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
24041         LDKOutPoint funding_txo_conv;
24042         funding_txo_conv.inner = (void*)(funding_txo & (~1));
24043         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
24044         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
24045         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
24046         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
24047         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
24048         uintptr_t ret_ref = (uintptr_t)ret_copy;
24049         return ret_ref;
24050 }
24051
24052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
24053         LDKOutPoint a_conv;
24054         a_conv.inner = (void*)(a & (~1));
24055         a_conv.is_owned = (a & 1) || (a == 0);
24056         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24057         a_conv = OutPoint_clone(&a_conv);
24058         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
24059         *ret_copy = MonitorEvent_update_failed(a_conv);
24060         uintptr_t ret_ref = (uintptr_t)ret_copy;
24061         return ret_ref;
24062 }
24063
24064 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
24065         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
24066         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
24067         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24068         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24069         CVec_u8Z_free(ret_var);
24070         return ret_arr;
24071 }
24072
24073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24074         LDKu8slice ser_ref;
24075         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24076         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24077         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
24078         *ret_conv = MonitorEvent_read(ser_ref);
24079         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24080         return (uintptr_t)ret_conv;
24081 }
24082
24083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24084         LDKHTLCUpdate this_obj_conv;
24085         this_obj_conv.inner = (void*)(this_obj & (~1));
24086         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24088         HTLCUpdate_free(this_obj_conv);
24089 }
24090
24091 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
24092         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
24093 uintptr_t ret_ref = 0;
24094 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24095 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24096 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24097 ret_ref = (uintptr_t)ret_var.inner;
24098 if (ret_var.is_owned) {
24099         ret_ref |= 1;
24100 }
24101         return ret_ref;
24102 }
24103 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24104         LDKHTLCUpdate arg_conv;
24105         arg_conv.inner = (void*)(arg & (~1));
24106         arg_conv.is_owned = false;
24107         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24108         intptr_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
24109         return ret_val;
24110 }
24111
24112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24113         LDKHTLCUpdate orig_conv;
24114         orig_conv.inner = (void*)(orig & (~1));
24115         orig_conv.is_owned = false;
24116         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24117         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
24118         uintptr_t ret_ref = 0;
24119         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24120         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24122         ret_ref = (uintptr_t)ret_var.inner;
24123         if (ret_var.is_owned) {
24124                 ret_ref |= 1;
24125         }
24126         return ret_ref;
24127 }
24128
24129 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
24130         LDKHTLCUpdate obj_conv;
24131         obj_conv.inner = (void*)(obj & (~1));
24132         obj_conv.is_owned = false;
24133         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24134         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
24135         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24136         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24137         CVec_u8Z_free(ret_var);
24138         return ret_arr;
24139 }
24140
24141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24142         LDKu8slice ser_ref;
24143         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24144         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24145         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
24146         *ret_conv = HTLCUpdate_read(ser_ref);
24147         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24148         return (uintptr_t)ret_conv;
24149 }
24150
24151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24152         if ((this_ptr & 1) != 0) return;
24153         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24154         CHECK_ACCESS(this_ptr_ptr);
24155         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
24156         FREE((void*)this_ptr);
24157         Balance_free(this_ptr_conv);
24158 }
24159
24160 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
24161         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
24162         *ret_copy = Balance_clone(arg);
24163 uintptr_t ret_ref = (uintptr_t)ret_copy;
24164         return ret_ref;
24165 }
24166 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24167         LDKBalance* arg_conv = (LDKBalance*)arg;
24168         intptr_t ret_val = Balance_clone_ptr(arg_conv);
24169         return ret_val;
24170 }
24171
24172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24173         LDKBalance* orig_conv = (LDKBalance*)orig;
24174         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
24175         *ret_copy = Balance_clone(orig_conv);
24176         uintptr_t ret_ref = (uintptr_t)ret_copy;
24177         return ret_ref;
24178 }
24179
24180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
24181         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
24182         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
24183         uintptr_t ret_ref = (uintptr_t)ret_copy;
24184         return ret_ref;
24185 }
24186
24187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1awaiting_1confirmations(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t confirmation_height) {
24188         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
24189         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
24190         uintptr_t ret_ref = (uintptr_t)ret_copy;
24191         return ret_ref;
24192 }
24193
24194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1contentious_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t timeout_height) {
24195         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
24196         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
24197         uintptr_t ret_ref = (uintptr_t)ret_copy;
24198         return ret_ref;
24199 }
24200
24201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1claimable_1htlcawaiting_1timeout(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t claimable_height) {
24202         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
24203         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
24204         uintptr_t ret_ref = (uintptr_t)ret_copy;
24205         return ret_ref;
24206 }
24207
24208 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24209         LDKBalance* a_conv = (LDKBalance*)a;
24210         LDKBalance* b_conv = (LDKBalance*)b;
24211         jboolean ret_val = Balance_eq(a_conv, b_conv);
24212         return ret_val;
24213 }
24214
24215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24216         LDKChannelMonitor this_obj_conv;
24217         this_obj_conv.inner = (void*)(this_obj & (~1));
24218         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24220         ChannelMonitor_free(this_obj_conv);
24221 }
24222
24223 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
24224         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
24225 uintptr_t ret_ref = 0;
24226 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24227 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24228 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24229 ret_ref = (uintptr_t)ret_var.inner;
24230 if (ret_var.is_owned) {
24231         ret_ref |= 1;
24232 }
24233         return ret_ref;
24234 }
24235 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24236         LDKChannelMonitor arg_conv;
24237         arg_conv.inner = (void*)(arg & (~1));
24238         arg_conv.is_owned = false;
24239         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24240         intptr_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
24241         return ret_val;
24242 }
24243
24244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24245         LDKChannelMonitor orig_conv;
24246         orig_conv.inner = (void*)(orig & (~1));
24247         orig_conv.is_owned = false;
24248         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24249         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
24250         uintptr_t ret_ref = 0;
24251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24254         ret_ref = (uintptr_t)ret_var.inner;
24255         if (ret_var.is_owned) {
24256                 ret_ref |= 1;
24257         }
24258         return ret_ref;
24259 }
24260
24261 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
24262         LDKChannelMonitor obj_conv;
24263         obj_conv.inner = (void*)(obj & (~1));
24264         obj_conv.is_owned = false;
24265         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24266         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
24267         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24268         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24269         CVec_u8Z_free(ret_var);
24270         return ret_arr;
24271 }
24272
24273 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) {
24274         LDKChannelMonitor this_arg_conv;
24275         this_arg_conv.inner = (void*)(this_arg & (~1));
24276         this_arg_conv.is_owned = false;
24277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24278         LDKChannelMonitorUpdate updates_conv;
24279         updates_conv.inner = (void*)(updates & (~1));
24280         updates_conv.is_owned = false;
24281         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
24282         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24283         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
24284         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
24285         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24286         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
24287         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
24288         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24289         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
24290         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
24291         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
24292         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
24293         return (uintptr_t)ret_conv;
24294 }
24295
24296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
24297         LDKChannelMonitor this_arg_conv;
24298         this_arg_conv.inner = (void*)(this_arg & (~1));
24299         this_arg_conv.is_owned = false;
24300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24301         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
24302         return ret_val;
24303 }
24304
24305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
24306         LDKChannelMonitor this_arg_conv;
24307         this_arg_conv.inner = (void*)(this_arg & (~1));
24308         this_arg_conv.is_owned = false;
24309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24310         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
24311         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
24312         return ((uintptr_t)ret_conv);
24313 }
24314
24315 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
24316         LDKChannelMonitor this_arg_conv;
24317         this_arg_conv.inner = (void*)(this_arg & (~1));
24318         this_arg_conv.is_owned = false;
24319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24320         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
24321         int64_tArray ret_arr = NULL;
24322         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24323         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24324         for (size_t o = 0; o < ret_var.datalen; o++) {
24325                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
24326                 *ret_conv_40_conv = ret_var.data[o];
24327                 ret_arr_ptr[o] = ((uintptr_t)ret_conv_40_conv);
24328         }
24329         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24330         FREE(ret_var.data);
24331         return ret_arr;
24332 }
24333
24334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
24335         LDKChannelMonitor this_arg_conv;
24336         this_arg_conv.inner = (void*)(this_arg & (~1));
24337         this_arg_conv.is_owned = false;
24338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24339         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
24340         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
24341         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
24342         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
24343 }
24344
24345 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
24346         LDKChannelMonitor this_arg_conv;
24347         this_arg_conv.inner = (void*)(this_arg & (~1));
24348         this_arg_conv.is_owned = false;
24349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24350         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
24351         int64_tArray ret_arr = NULL;
24352         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24353         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24354         for (size_t o = 0; o < ret_var.datalen; o++) {
24355                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
24356                 *ret_conv_14_copy = ret_var.data[o];
24357                 uintptr_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
24358                 ret_arr_ptr[o] = ret_conv_14_ref;
24359         }
24360         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24361         FREE(ret_var.data);
24362         return ret_arr;
24363 }
24364
24365 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
24366         LDKChannelMonitor this_arg_conv;
24367         this_arg_conv.inner = (void*)(this_arg & (~1));
24368         this_arg_conv.is_owned = false;
24369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24370         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
24371         int64_tArray ret_arr = NULL;
24372         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24373         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24374         for (size_t h = 0; h < ret_var.datalen; h++) {
24375                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24376                 *ret_conv_7_copy = ret_var.data[h];
24377                 uintptr_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
24378                 ret_arr_ptr[h] = ret_conv_7_ref;
24379         }
24380         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24381         FREE(ret_var.data);
24382         return ret_arr;
24383 }
24384
24385 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) {
24386         LDKChannelMonitor this_arg_conv;
24387         this_arg_conv.inner = (void*)(this_arg & (~1));
24388         this_arg_conv.is_owned = false;
24389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24390         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24391         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
24392         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
24393         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
24394         jobjectArray ret_arr = NULL;
24395         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
24396         ;
24397         for (size_t i = 0; i < ret_var.datalen; i++) {
24398                 LDKTransaction ret_conv_8_var = ret_var.data[i];
24399                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
24400                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
24401                 Transaction_free(ret_conv_8_var);
24402                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
24403         }
24404         
24405         FREE(ret_var.data);
24406         return ret_arr;
24407 }
24408
24409 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) {
24410         LDKChannelMonitor this_arg_conv;
24411         this_arg_conv.inner = (void*)(this_arg & (~1));
24412         this_arg_conv.is_owned = false;
24413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24414         unsigned char header_arr[80];
24415         CHECK((*env)->GetArrayLength(env, header) == 80);
24416         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
24417         unsigned char (*header_ref)[80] = &header_arr;
24418         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
24419         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
24420         if (txdata_constr.datalen > 0)
24421                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
24422         else
24423                 txdata_constr.data = NULL;
24424         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
24425         for (size_t c = 0; c < txdata_constr.datalen; c++) {
24426                 int64_t txdata_conv_28 = txdata_vals[c];
24427                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
24428                 CHECK_ACCESS(txdata_conv_28_ptr);
24429                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
24430                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
24431                 txdata_constr.data[c] = txdata_conv_28_conv;
24432         }
24433         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
24434         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24435         CHECK_ACCESS(broadcaster_ptr);
24436         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24437         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24438                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24439                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24440         }
24441         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24442         CHECK_ACCESS(fee_estimator_ptr);
24443         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24444         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24445                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24446                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24447         }
24448         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24449         CHECK_ACCESS(logger_ptr);
24450         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24451         if (logger_conv.free == LDKLogger_JCalls_free) {
24452                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24453                 LDKLogger_JCalls_cloned(&logger_conv);
24454         }
24455         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);
24456         int64_tArray ret_arr = NULL;
24457         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24458         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24459         for (size_t n = 0; n < ret_var.datalen; n++) {
24460                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24461                 *ret_conv_39_conv = ret_var.data[n];
24462                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
24463         }
24464         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24465         FREE(ret_var.data);
24466         return ret_arr;
24467 }
24468
24469 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) {
24470         LDKChannelMonitor this_arg_conv;
24471         this_arg_conv.inner = (void*)(this_arg & (~1));
24472         this_arg_conv.is_owned = false;
24473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24474         unsigned char header_arr[80];
24475         CHECK((*env)->GetArrayLength(env, header) == 80);
24476         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
24477         unsigned char (*header_ref)[80] = &header_arr;
24478         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24479         CHECK_ACCESS(broadcaster_ptr);
24480         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24481         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24482                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24483                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24484         }
24485         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24486         CHECK_ACCESS(fee_estimator_ptr);
24487         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24488         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24489                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24490                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24491         }
24492         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24493         CHECK_ACCESS(logger_ptr);
24494         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24495         if (logger_conv.free == LDKLogger_JCalls_free) {
24496                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24497                 LDKLogger_JCalls_cloned(&logger_conv);
24498         }
24499         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
24500 }
24501
24502 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) {
24503         LDKChannelMonitor this_arg_conv;
24504         this_arg_conv.inner = (void*)(this_arg & (~1));
24505         this_arg_conv.is_owned = false;
24506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24507         unsigned char header_arr[80];
24508         CHECK((*env)->GetArrayLength(env, header) == 80);
24509         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
24510         unsigned char (*header_ref)[80] = &header_arr;
24511         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
24512         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
24513         if (txdata_constr.datalen > 0)
24514                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
24515         else
24516                 txdata_constr.data = NULL;
24517         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
24518         for (size_t c = 0; c < txdata_constr.datalen; c++) {
24519                 int64_t txdata_conv_28 = txdata_vals[c];
24520                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
24521                 CHECK_ACCESS(txdata_conv_28_ptr);
24522                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
24523                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
24524                 txdata_constr.data[c] = txdata_conv_28_conv;
24525         }
24526         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
24527         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24528         CHECK_ACCESS(broadcaster_ptr);
24529         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24530         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24531                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24532                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24533         }
24534         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24535         CHECK_ACCESS(fee_estimator_ptr);
24536         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24537         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24538                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24539                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24540         }
24541         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24542         CHECK_ACCESS(logger_ptr);
24543         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24544         if (logger_conv.free == LDKLogger_JCalls_free) {
24545                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24546                 LDKLogger_JCalls_cloned(&logger_conv);
24547         }
24548         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);
24549         int64_tArray ret_arr = NULL;
24550         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24551         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24552         for (size_t n = 0; n < ret_var.datalen; n++) {
24553                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24554                 *ret_conv_39_conv = ret_var.data[n];
24555                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
24556         }
24557         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24558         FREE(ret_var.data);
24559         return ret_arr;
24560 }
24561
24562 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) {
24563         LDKChannelMonitor this_arg_conv;
24564         this_arg_conv.inner = (void*)(this_arg & (~1));
24565         this_arg_conv.is_owned = false;
24566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24567         unsigned char txid_arr[32];
24568         CHECK((*env)->GetArrayLength(env, txid) == 32);
24569         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
24570         unsigned char (*txid_ref)[32] = &txid_arr;
24571         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24572         CHECK_ACCESS(broadcaster_ptr);
24573         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24574         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24575                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24576                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24577         }
24578         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24579         CHECK_ACCESS(fee_estimator_ptr);
24580         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24581         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24582                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24583                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24584         }
24585         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24586         CHECK_ACCESS(logger_ptr);
24587         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24588         if (logger_conv.free == LDKLogger_JCalls_free) {
24589                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24590                 LDKLogger_JCalls_cloned(&logger_conv);
24591         }
24592         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
24593 }
24594
24595 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) {
24596         LDKChannelMonitor this_arg_conv;
24597         this_arg_conv.inner = (void*)(this_arg & (~1));
24598         this_arg_conv.is_owned = false;
24599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24600         unsigned char header_arr[80];
24601         CHECK((*env)->GetArrayLength(env, header) == 80);
24602         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
24603         unsigned char (*header_ref)[80] = &header_arr;
24604         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24605         CHECK_ACCESS(broadcaster_ptr);
24606         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24607         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24608                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24609                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24610         }
24611         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24612         CHECK_ACCESS(fee_estimator_ptr);
24613         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24614         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24615                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24616                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24617         }
24618         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24619         CHECK_ACCESS(logger_ptr);
24620         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24621         if (logger_conv.free == LDKLogger_JCalls_free) {
24622                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24623                 LDKLogger_JCalls_cloned(&logger_conv);
24624         }
24625         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
24626         int64_tArray ret_arr = NULL;
24627         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24628         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24629         for (size_t n = 0; n < ret_var.datalen; n++) {
24630                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24631                 *ret_conv_39_conv = ret_var.data[n];
24632                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
24633         }
24634         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24635         FREE(ret_var.data);
24636         return ret_arr;
24637 }
24638
24639 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
24640         LDKChannelMonitor this_arg_conv;
24641         this_arg_conv.inner = (void*)(this_arg & (~1));
24642         this_arg_conv.is_owned = false;
24643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24644         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
24645         jobjectArray ret_arr = NULL;
24646         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
24647         ;
24648         for (size_t i = 0; i < ret_var.datalen; i++) {
24649                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
24650                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
24651                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
24652         }
24653         
24654         FREE(ret_var.data);
24655         return ret_arr;
24656 }
24657
24658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
24659         LDKChannelMonitor this_arg_conv;
24660         this_arg_conv.inner = (void*)(this_arg & (~1));
24661         this_arg_conv.is_owned = false;
24662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24663         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
24664         uintptr_t ret_ref = 0;
24665         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24666         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24668         ret_ref = (uintptr_t)ret_var.inner;
24669         if (ret_var.is_owned) {
24670                 ret_ref |= 1;
24671         }
24672         return ret_ref;
24673 }
24674
24675 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
24676         LDKChannelMonitor this_arg_conv;
24677         this_arg_conv.inner = (void*)(this_arg & (~1));
24678         this_arg_conv.is_owned = false;
24679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24680         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
24681         int64_tArray ret_arr = NULL;
24682         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24683         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24684         for (size_t j = 0; j < ret_var.datalen; j++) {
24685                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
24686                 *ret_conv_9_copy = ret_var.data[j];
24687                 uintptr_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
24688                 ret_arr_ptr[j] = ret_conv_9_ref;
24689         }
24690         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24691         FREE(ret_var.data);
24692         return ret_arr;
24693 }
24694
24695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
24696         LDKu8slice ser_ref;
24697         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24698         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24699         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
24700         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
24701         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
24702         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
24703         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
24704         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24705         return (uintptr_t)ret_conv;
24706 }
24707
24708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24709         LDKOutPoint this_obj_conv;
24710         this_obj_conv.inner = (void*)(this_obj & (~1));
24711         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24713         OutPoint_free(this_obj_conv);
24714 }
24715
24716 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
24717         LDKOutPoint this_ptr_conv;
24718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24719         this_ptr_conv.is_owned = false;
24720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24721         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24722         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
24723         return ret_arr;
24724 }
24725
24726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24727         LDKOutPoint this_ptr_conv;
24728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24729         this_ptr_conv.is_owned = false;
24730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24731         LDKThirtyTwoBytes val_ref;
24732         CHECK((*env)->GetArrayLength(env, val) == 32);
24733         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24734         OutPoint_set_txid(&this_ptr_conv, val_ref);
24735 }
24736
24737 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
24738         LDKOutPoint this_ptr_conv;
24739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24740         this_ptr_conv.is_owned = false;
24741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24742         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
24743         return ret_val;
24744 }
24745
24746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24747         LDKOutPoint this_ptr_conv;
24748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24749         this_ptr_conv.is_owned = false;
24750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24751         OutPoint_set_index(&this_ptr_conv, val);
24752 }
24753
24754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
24755         LDKThirtyTwoBytes txid_arg_ref;
24756         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
24757         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
24758         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
24759         uintptr_t ret_ref = 0;
24760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24763         ret_ref = (uintptr_t)ret_var.inner;
24764         if (ret_var.is_owned) {
24765                 ret_ref |= 1;
24766         }
24767         return ret_ref;
24768 }
24769
24770 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
24771         LDKOutPoint ret_var = OutPoint_clone(arg);
24772 uintptr_t ret_ref = 0;
24773 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24774 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24775 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24776 ret_ref = (uintptr_t)ret_var.inner;
24777 if (ret_var.is_owned) {
24778         ret_ref |= 1;
24779 }
24780         return ret_ref;
24781 }
24782 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24783         LDKOutPoint arg_conv;
24784         arg_conv.inner = (void*)(arg & (~1));
24785         arg_conv.is_owned = false;
24786         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24787         intptr_t ret_val = OutPoint_clone_ptr(&arg_conv);
24788         return ret_val;
24789 }
24790
24791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24792         LDKOutPoint orig_conv;
24793         orig_conv.inner = (void*)(orig & (~1));
24794         orig_conv.is_owned = false;
24795         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24796         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
24797         uintptr_t ret_ref = 0;
24798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24801         ret_ref = (uintptr_t)ret_var.inner;
24802         if (ret_var.is_owned) {
24803                 ret_ref |= 1;
24804         }
24805         return ret_ref;
24806 }
24807
24808 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24809         LDKOutPoint a_conv;
24810         a_conv.inner = (void*)(a & (~1));
24811         a_conv.is_owned = false;
24812         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24813         LDKOutPoint b_conv;
24814         b_conv.inner = (void*)(b & (~1));
24815         b_conv.is_owned = false;
24816         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
24817         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
24818         return ret_val;
24819 }
24820
24821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
24822         LDKOutPoint o_conv;
24823         o_conv.inner = (void*)(o & (~1));
24824         o_conv.is_owned = false;
24825         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24826         int64_t ret_val = OutPoint_hash(&o_conv);
24827         return ret_val;
24828 }
24829
24830 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
24831         LDKOutPoint this_arg_conv;
24832         this_arg_conv.inner = (void*)(this_arg & (~1));
24833         this_arg_conv.is_owned = false;
24834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24835         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24836         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
24837         return ret_arr;
24838 }
24839
24840 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
24841         LDKOutPoint obj_conv;
24842         obj_conv.inner = (void*)(obj & (~1));
24843         obj_conv.is_owned = false;
24844         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24845         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
24846         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24847         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24848         CVec_u8Z_free(ret_var);
24849         return ret_arr;
24850 }
24851
24852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24853         LDKu8slice ser_ref;
24854         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24855         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24856         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
24857         *ret_conv = OutPoint_read(ser_ref);
24858         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24859         return (uintptr_t)ret_conv;
24860 }
24861
24862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24863         LDKDelayedPaymentOutputDescriptor this_obj_conv;
24864         this_obj_conv.inner = (void*)(this_obj & (~1));
24865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24867         DelayedPaymentOutputDescriptor_free(this_obj_conv);
24868 }
24869
24870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
24871         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24873         this_ptr_conv.is_owned = false;
24874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24875         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
24876         uintptr_t ret_ref = 0;
24877         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24878         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24880         ret_ref = (uintptr_t)ret_var.inner;
24881         if (ret_var.is_owned) {
24882                 ret_ref |= 1;
24883         }
24884         return ret_ref;
24885 }
24886
24887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24888         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24890         this_ptr_conv.is_owned = false;
24891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24892         LDKOutPoint val_conv;
24893         val_conv.inner = (void*)(val & (~1));
24894         val_conv.is_owned = (val & 1) || (val == 0);
24895         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24896         val_conv = OutPoint_clone(&val_conv);
24897         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
24898 }
24899
24900 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
24901         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24903         this_ptr_conv.is_owned = false;
24904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24905         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24906         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
24907         return ret_arr;
24908 }
24909
24910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24911         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24913         this_ptr_conv.is_owned = false;
24914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24915         LDKPublicKey val_ref;
24916         CHECK((*env)->GetArrayLength(env, val) == 33);
24917         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24918         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
24919 }
24920
24921 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
24922         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24924         this_ptr_conv.is_owned = false;
24925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24926         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
24927         return ret_val;
24928 }
24929
24930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24931         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24933         this_ptr_conv.is_owned = false;
24934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24935         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
24936 }
24937
24938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24939         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24941         this_ptr_conv.is_owned = false;
24942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24943         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24944         CHECK_ACCESS(val_ptr);
24945         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
24946         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
24947         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
24948 }
24949
24950 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
24951         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24953         this_ptr_conv.is_owned = false;
24954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24955         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24956         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
24957         return ret_arr;
24958 }
24959
24960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24961         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24963         this_ptr_conv.is_owned = false;
24964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24965         LDKPublicKey val_ref;
24966         CHECK((*env)->GetArrayLength(env, val) == 33);
24967         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
24968         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
24969 }
24970
24971 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24972         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24974         this_ptr_conv.is_owned = false;
24975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24976         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24977         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
24978         return ret_arr;
24979 }
24980
24981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24982         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24984         this_ptr_conv.is_owned = false;
24985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24986         LDKThirtyTwoBytes val_ref;
24987         CHECK((*env)->GetArrayLength(env, val) == 32);
24988         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24989         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
24990 }
24991
24992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24993         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24995         this_ptr_conv.is_owned = false;
24996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24997         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
24998         return ret_val;
24999 }
25000
25001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25002         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
25003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25004         this_ptr_conv.is_owned = false;
25005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25006         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
25007 }
25008
25009 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) {
25010         LDKOutPoint outpoint_arg_conv;
25011         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
25012         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
25013         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
25014         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
25015         LDKPublicKey per_commitment_point_arg_ref;
25016         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
25017         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
25018         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
25019         CHECK_ACCESS(output_arg_ptr);
25020         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
25021         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
25022         LDKPublicKey revocation_pubkey_arg_ref;
25023         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
25024         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
25025         LDKThirtyTwoBytes channel_keys_id_arg_ref;
25026         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
25027         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
25028         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);
25029         uintptr_t ret_ref = 0;
25030         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25031         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25033         ret_ref = (uintptr_t)ret_var.inner;
25034         if (ret_var.is_owned) {
25035                 ret_ref |= 1;
25036         }
25037         return ret_ref;
25038 }
25039
25040 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
25041         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
25042 uintptr_t ret_ref = 0;
25043 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25044 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25045 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25046 ret_ref = (uintptr_t)ret_var.inner;
25047 if (ret_var.is_owned) {
25048         ret_ref |= 1;
25049 }
25050         return ret_ref;
25051 }
25052 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25053         LDKDelayedPaymentOutputDescriptor arg_conv;
25054         arg_conv.inner = (void*)(arg & (~1));
25055         arg_conv.is_owned = false;
25056         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25057         intptr_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
25058         return ret_val;
25059 }
25060
25061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25062         LDKDelayedPaymentOutputDescriptor orig_conv;
25063         orig_conv.inner = (void*)(orig & (~1));
25064         orig_conv.is_owned = false;
25065         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25066         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
25067         uintptr_t ret_ref = 0;
25068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25071         ret_ref = (uintptr_t)ret_var.inner;
25072         if (ret_var.is_owned) {
25073                 ret_ref |= 1;
25074         }
25075         return ret_ref;
25076 }
25077
25078 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
25079         LDKDelayedPaymentOutputDescriptor obj_conv;
25080         obj_conv.inner = (void*)(obj & (~1));
25081         obj_conv.is_owned = false;
25082         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25083         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
25084         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25085         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25086         CVec_u8Z_free(ret_var);
25087         return ret_arr;
25088 }
25089
25090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25091         LDKu8slice ser_ref;
25092         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25093         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25094         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
25095         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
25096         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25097         return (uintptr_t)ret_conv;
25098 }
25099
25100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25101         LDKStaticPaymentOutputDescriptor this_obj_conv;
25102         this_obj_conv.inner = (void*)(this_obj & (~1));
25103         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25105         StaticPaymentOutputDescriptor_free(this_obj_conv);
25106 }
25107
25108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25109         LDKStaticPaymentOutputDescriptor this_ptr_conv;
25110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25111         this_ptr_conv.is_owned = false;
25112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25113         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
25114         uintptr_t ret_ref = 0;
25115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25118         ret_ref = (uintptr_t)ret_var.inner;
25119         if (ret_var.is_owned) {
25120                 ret_ref |= 1;
25121         }
25122         return ret_ref;
25123 }
25124
25125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25126         LDKStaticPaymentOutputDescriptor this_ptr_conv;
25127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25128         this_ptr_conv.is_owned = false;
25129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25130         LDKOutPoint val_conv;
25131         val_conv.inner = (void*)(val & (~1));
25132         val_conv.is_owned = (val & 1) || (val == 0);
25133         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25134         val_conv = OutPoint_clone(&val_conv);
25135         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
25136 }
25137
25138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25139         LDKStaticPaymentOutputDescriptor this_ptr_conv;
25140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25141         this_ptr_conv.is_owned = false;
25142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25143         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25144         CHECK_ACCESS(val_ptr);
25145         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
25146         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
25147         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
25148 }
25149
25150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
25151         LDKStaticPaymentOutputDescriptor this_ptr_conv;
25152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25153         this_ptr_conv.is_owned = false;
25154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25155         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25156         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
25157         return ret_arr;
25158 }
25159
25160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25161         LDKStaticPaymentOutputDescriptor this_ptr_conv;
25162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25163         this_ptr_conv.is_owned = false;
25164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25165         LDKThirtyTwoBytes val_ref;
25166         CHECK((*env)->GetArrayLength(env, val) == 32);
25167         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25168         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
25169 }
25170
25171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25172         LDKStaticPaymentOutputDescriptor this_ptr_conv;
25173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25174         this_ptr_conv.is_owned = false;
25175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25176         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
25177         return ret_val;
25178 }
25179
25180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25181         LDKStaticPaymentOutputDescriptor this_ptr_conv;
25182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25183         this_ptr_conv.is_owned = false;
25184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25185         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
25186 }
25187
25188 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) {
25189         LDKOutPoint outpoint_arg_conv;
25190         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
25191         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
25192         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
25193         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
25194         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
25195         CHECK_ACCESS(output_arg_ptr);
25196         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
25197         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
25198         LDKThirtyTwoBytes channel_keys_id_arg_ref;
25199         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
25200         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
25201         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
25202         uintptr_t ret_ref = 0;
25203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25206         ret_ref = (uintptr_t)ret_var.inner;
25207         if (ret_var.is_owned) {
25208                 ret_ref |= 1;
25209         }
25210         return ret_ref;
25211 }
25212
25213 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
25214         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
25215 uintptr_t ret_ref = 0;
25216 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25217 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25218 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25219 ret_ref = (uintptr_t)ret_var.inner;
25220 if (ret_var.is_owned) {
25221         ret_ref |= 1;
25222 }
25223         return ret_ref;
25224 }
25225 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25226         LDKStaticPaymentOutputDescriptor arg_conv;
25227         arg_conv.inner = (void*)(arg & (~1));
25228         arg_conv.is_owned = false;
25229         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25230         intptr_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
25231         return ret_val;
25232 }
25233
25234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25235         LDKStaticPaymentOutputDescriptor orig_conv;
25236         orig_conv.inner = (void*)(orig & (~1));
25237         orig_conv.is_owned = false;
25238         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25239         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
25240         uintptr_t ret_ref = 0;
25241         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25242         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25244         ret_ref = (uintptr_t)ret_var.inner;
25245         if (ret_var.is_owned) {
25246                 ret_ref |= 1;
25247         }
25248         return ret_ref;
25249 }
25250
25251 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
25252         LDKStaticPaymentOutputDescriptor obj_conv;
25253         obj_conv.inner = (void*)(obj & (~1));
25254         obj_conv.is_owned = false;
25255         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25256         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
25257         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25258         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25259         CVec_u8Z_free(ret_var);
25260         return ret_arr;
25261 }
25262
25263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25264         LDKu8slice ser_ref;
25265         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25266         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25267         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
25268         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
25269         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25270         return (uintptr_t)ret_conv;
25271 }
25272
25273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25274         if ((this_ptr & 1) != 0) return;
25275         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25276         CHECK_ACCESS(this_ptr_ptr);
25277         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
25278         FREE((void*)this_ptr);
25279         SpendableOutputDescriptor_free(this_ptr_conv);
25280 }
25281
25282 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
25283         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25284         *ret_copy = SpendableOutputDescriptor_clone(arg);
25285 uintptr_t ret_ref = (uintptr_t)ret_copy;
25286         return ret_ref;
25287 }
25288 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25289         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
25290         intptr_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
25291         return ret_val;
25292 }
25293
25294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25295         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
25296         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25297         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
25298         uintptr_t ret_ref = (uintptr_t)ret_copy;
25299         return ret_ref;
25300 }
25301
25302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
25303         LDKOutPoint outpoint_conv;
25304         outpoint_conv.inner = (void*)(outpoint & (~1));
25305         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
25306         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
25307         outpoint_conv = OutPoint_clone(&outpoint_conv);
25308         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
25309         CHECK_ACCESS(output_ptr);
25310         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
25311         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
25312         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25313         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
25314         uintptr_t ret_ref = (uintptr_t)ret_copy;
25315         return ret_ref;
25316 }
25317
25318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
25319         LDKDelayedPaymentOutputDescriptor a_conv;
25320         a_conv.inner = (void*)(a & (~1));
25321         a_conv.is_owned = (a & 1) || (a == 0);
25322         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25323         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
25324         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25325         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
25326         uintptr_t ret_ref = (uintptr_t)ret_copy;
25327         return ret_ref;
25328 }
25329
25330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
25331         LDKStaticPaymentOutputDescriptor a_conv;
25332         a_conv.inner = (void*)(a & (~1));
25333         a_conv.is_owned = (a & 1) || (a == 0);
25334         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25335         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
25336         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25337         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
25338         uintptr_t ret_ref = (uintptr_t)ret_copy;
25339         return ret_ref;
25340 }
25341
25342 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
25343         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
25344         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
25345         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25346         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25347         CVec_u8Z_free(ret_var);
25348         return ret_arr;
25349 }
25350
25351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25352         LDKu8slice ser_ref;
25353         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25354         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25355         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
25356         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
25357         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25358         return (uintptr_t)ret_conv;
25359 }
25360
25361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25362         if ((this_ptr & 1) != 0) return;
25363         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25364         CHECK_ACCESS(this_ptr_ptr);
25365         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
25366         FREE((void*)this_ptr);
25367         BaseSign_free(this_ptr_conv);
25368 }
25369
25370 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
25371         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25372         *ret_ret = Sign_clone(arg);
25373         return (uintptr_t)ret_ret;
25374 }
25375 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25376         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
25377         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
25378         LDKSign* arg_conv = (LDKSign*)arg_ptr;
25379         intptr_t ret_val = Sign_clone_ptr(arg_conv);
25380         return ret_val;
25381 }
25382
25383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25384         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
25385         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
25386         LDKSign* orig_conv = (LDKSign*)orig_ptr;
25387         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25388         *ret_ret = Sign_clone(orig_conv);
25389         return (uintptr_t)ret_ret;
25390 }
25391
25392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25393         if ((this_ptr & 1) != 0) return;
25394         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25395         CHECK_ACCESS(this_ptr_ptr);
25396         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
25397         FREE((void*)this_ptr);
25398         Sign_free(this_ptr_conv);
25399 }
25400
25401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25402         if ((this_ptr & 1) != 0) return;
25403         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25404         CHECK_ACCESS(this_ptr_ptr);
25405         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
25406         FREE((void*)this_ptr);
25407         KeysInterface_free(this_ptr_conv);
25408 }
25409
25410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25411         LDKInMemorySigner this_obj_conv;
25412         this_obj_conv.inner = (void*)(this_obj & (~1));
25413         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25415         InMemorySigner_free(this_obj_conv);
25416 }
25417
25418 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
25419         LDKInMemorySigner this_ptr_conv;
25420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25421         this_ptr_conv.is_owned = false;
25422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25423         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25424         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
25425         return ret_arr;
25426 }
25427
25428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25429         LDKInMemorySigner this_ptr_conv;
25430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25431         this_ptr_conv.is_owned = false;
25432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25433         LDKSecretKey val_ref;
25434         CHECK((*env)->GetArrayLength(env, val) == 32);
25435         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
25436         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
25437 }
25438
25439 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
25440         LDKInMemorySigner this_ptr_conv;
25441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25442         this_ptr_conv.is_owned = false;
25443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25444         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25445         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
25446         return ret_arr;
25447 }
25448
25449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25450         LDKInMemorySigner this_ptr_conv;
25451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25452         this_ptr_conv.is_owned = false;
25453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25454         LDKSecretKey val_ref;
25455         CHECK((*env)->GetArrayLength(env, val) == 32);
25456         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
25457         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
25458 }
25459
25460 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
25461         LDKInMemorySigner this_ptr_conv;
25462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25463         this_ptr_conv.is_owned = false;
25464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25465         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25466         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
25467         return ret_arr;
25468 }
25469
25470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25471         LDKInMemorySigner this_ptr_conv;
25472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25473         this_ptr_conv.is_owned = false;
25474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25475         LDKSecretKey val_ref;
25476         CHECK((*env)->GetArrayLength(env, val) == 32);
25477         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
25478         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
25479 }
25480
25481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
25482         LDKInMemorySigner this_ptr_conv;
25483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25484         this_ptr_conv.is_owned = false;
25485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25486         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25487         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
25488         return ret_arr;
25489 }
25490
25491 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) {
25492         LDKInMemorySigner this_ptr_conv;
25493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25494         this_ptr_conv.is_owned = false;
25495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25496         LDKSecretKey val_ref;
25497         CHECK((*env)->GetArrayLength(env, val) == 32);
25498         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
25499         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
25500 }
25501
25502 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
25503         LDKInMemorySigner this_ptr_conv;
25504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25505         this_ptr_conv.is_owned = false;
25506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25507         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25508         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
25509         return ret_arr;
25510 }
25511
25512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25513         LDKInMemorySigner this_ptr_conv;
25514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25515         this_ptr_conv.is_owned = false;
25516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25517         LDKSecretKey val_ref;
25518         CHECK((*env)->GetArrayLength(env, val) == 32);
25519         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
25520         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
25521 }
25522
25523 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
25524         LDKInMemorySigner this_ptr_conv;
25525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25526         this_ptr_conv.is_owned = false;
25527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25528         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25529         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
25530         return ret_arr;
25531 }
25532
25533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25534         LDKInMemorySigner this_ptr_conv;
25535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25536         this_ptr_conv.is_owned = false;
25537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25538         LDKThirtyTwoBytes val_ref;
25539         CHECK((*env)->GetArrayLength(env, val) == 32);
25540         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25541         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
25542 }
25543
25544 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
25545         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
25546 uintptr_t ret_ref = 0;
25547 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25548 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25549 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25550 ret_ref = (uintptr_t)ret_var.inner;
25551 if (ret_var.is_owned) {
25552         ret_ref |= 1;
25553 }
25554         return ret_ref;
25555 }
25556 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25557         LDKInMemorySigner arg_conv;
25558         arg_conv.inner = (void*)(arg & (~1));
25559         arg_conv.is_owned = false;
25560         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25561         intptr_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
25562         return ret_val;
25563 }
25564
25565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25566         LDKInMemorySigner orig_conv;
25567         orig_conv.inner = (void*)(orig & (~1));
25568         orig_conv.is_owned = false;
25569         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25570         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
25571         uintptr_t ret_ref = 0;
25572         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25573         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25575         ret_ref = (uintptr_t)ret_var.inner;
25576         if (ret_var.is_owned) {
25577                 ret_ref |= 1;
25578         }
25579         return ret_ref;
25580 }
25581
25582 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) {
25583         LDKSecretKey funding_key_ref;
25584         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
25585         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
25586         LDKSecretKey revocation_base_key_ref;
25587         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
25588         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
25589         LDKSecretKey payment_key_ref;
25590         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
25591         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
25592         LDKSecretKey delayed_payment_base_key_ref;
25593         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
25594         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
25595         LDKSecretKey htlc_base_key_ref;
25596         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
25597         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
25598         LDKThirtyTwoBytes commitment_seed_ref;
25599         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
25600         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
25601         LDKThirtyTwoBytes channel_keys_id_ref;
25602         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
25603         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
25604         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);
25605         uintptr_t ret_ref = 0;
25606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25609         ret_ref = (uintptr_t)ret_var.inner;
25610         if (ret_var.is_owned) {
25611                 ret_ref |= 1;
25612         }
25613         return ret_ref;
25614 }
25615
25616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
25617         LDKInMemorySigner this_arg_conv;
25618         this_arg_conv.inner = (void*)(this_arg & (~1));
25619         this_arg_conv.is_owned = false;
25620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25621         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
25622         uintptr_t ret_ref = 0;
25623         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25624         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25626         ret_ref = (uintptr_t)ret_var.inner;
25627         if (ret_var.is_owned) {
25628                 ret_ref |= 1;
25629         }
25630         return ret_ref;
25631 }
25632
25633 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
25634         LDKInMemorySigner this_arg_conv;
25635         this_arg_conv.inner = (void*)(this_arg & (~1));
25636         this_arg_conv.is_owned = false;
25637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25638         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
25639         return ret_val;
25640 }
25641
25642 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
25643         LDKInMemorySigner this_arg_conv;
25644         this_arg_conv.inner = (void*)(this_arg & (~1));
25645         this_arg_conv.is_owned = false;
25646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25647         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
25648         return ret_val;
25649 }
25650
25651 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
25652         LDKInMemorySigner this_arg_conv;
25653         this_arg_conv.inner = (void*)(this_arg & (~1));
25654         this_arg_conv.is_owned = false;
25655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25656         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
25657         return ret_val;
25658 }
25659
25660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
25661         LDKInMemorySigner this_arg_conv;
25662         this_arg_conv.inner = (void*)(this_arg & (~1));
25663         this_arg_conv.is_owned = false;
25664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25665         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
25666         uintptr_t ret_ref = 0;
25667         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25668         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25670         ret_ref = (uintptr_t)ret_var.inner;
25671         if (ret_var.is_owned) {
25672                 ret_ref |= 1;
25673         }
25674         return ret_ref;
25675 }
25676
25677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
25678         LDKInMemorySigner this_arg_conv;
25679         this_arg_conv.inner = (void*)(this_arg & (~1));
25680         this_arg_conv.is_owned = false;
25681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25682         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
25683         uintptr_t ret_ref = 0;
25684         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25685         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25687         ret_ref = (uintptr_t)ret_var.inner;
25688         if (ret_var.is_owned) {
25689                 ret_ref |= 1;
25690         }
25691         return ret_ref;
25692 }
25693
25694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
25695         LDKInMemorySigner this_arg_conv;
25696         this_arg_conv.inner = (void*)(this_arg & (~1));
25697         this_arg_conv.is_owned = false;
25698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25699         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
25700         return ret_val;
25701 }
25702
25703 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, intptr_t input_idx, int64_t descriptor) {
25704         LDKInMemorySigner this_arg_conv;
25705         this_arg_conv.inner = (void*)(this_arg & (~1));
25706         this_arg_conv.is_owned = false;
25707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25708         LDKTransaction spend_tx_ref;
25709         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
25710         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
25711         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
25712         spend_tx_ref.data_is_owned = true;
25713         LDKStaticPaymentOutputDescriptor descriptor_conv;
25714         descriptor_conv.inner = (void*)(descriptor & (~1));
25715         descriptor_conv.is_owned = false;
25716         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
25717         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
25718         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
25719         return (uintptr_t)ret_conv;
25720 }
25721
25722 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, intptr_t input_idx, int64_t descriptor) {
25723         LDKInMemorySigner this_arg_conv;
25724         this_arg_conv.inner = (void*)(this_arg & (~1));
25725         this_arg_conv.is_owned = false;
25726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25727         LDKTransaction spend_tx_ref;
25728         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
25729         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
25730         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
25731         spend_tx_ref.data_is_owned = true;
25732         LDKDelayedPaymentOutputDescriptor descriptor_conv;
25733         descriptor_conv.inner = (void*)(descriptor & (~1));
25734         descriptor_conv.is_owned = false;
25735         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
25736         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
25737         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
25738         return (uintptr_t)ret_conv;
25739 }
25740
25741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
25742         LDKInMemorySigner this_arg_conv;
25743         this_arg_conv.inner = (void*)(this_arg & (~1));
25744         this_arg_conv.is_owned = false;
25745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25746         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
25747         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
25748         return (uintptr_t)ret_ret;
25749 }
25750
25751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
25752         LDKInMemorySigner this_arg_conv;
25753         this_arg_conv.inner = (void*)(this_arg & (~1));
25754         this_arg_conv.is_owned = false;
25755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25756         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25757         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
25758         return (uintptr_t)ret_ret;
25759 }
25760
25761 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
25762         LDKInMemorySigner obj_conv;
25763         obj_conv.inner = (void*)(obj & (~1));
25764         obj_conv.is_owned = false;
25765         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25766         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
25767         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25768         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25769         CVec_u8Z_free(ret_var);
25770         return ret_arr;
25771 }
25772
25773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25774         LDKu8slice ser_ref;
25775         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25776         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25777         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
25778         *ret_conv = InMemorySigner_read(ser_ref);
25779         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25780         return (uintptr_t)ret_conv;
25781 }
25782
25783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25784         LDKKeysManager this_obj_conv;
25785         this_obj_conv.inner = (void*)(this_obj & (~1));
25786         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25788         KeysManager_free(this_obj_conv);
25789 }
25790
25791 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) {
25792         unsigned char seed_arr[32];
25793         CHECK((*env)->GetArrayLength(env, seed) == 32);
25794         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
25795         unsigned char (*seed_ref)[32] = &seed_arr;
25796         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
25797         uintptr_t ret_ref = 0;
25798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25801         ret_ref = (uintptr_t)ret_var.inner;
25802         if (ret_var.is_owned) {
25803                 ret_ref |= 1;
25804         }
25805         return ret_ref;
25806 }
25807
25808 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) {
25809         LDKKeysManager this_arg_conv;
25810         this_arg_conv.inner = (void*)(this_arg & (~1));
25811         this_arg_conv.is_owned = false;
25812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25813         unsigned char params_arr[32];
25814         CHECK((*env)->GetArrayLength(env, params) == 32);
25815         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
25816         unsigned char (*params_ref)[32] = &params_arr;
25817         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
25818         uintptr_t ret_ref = 0;
25819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25822         ret_ref = (uintptr_t)ret_var.inner;
25823         if (ret_var.is_owned) {
25824                 ret_ref |= 1;
25825         }
25826         return ret_ref;
25827 }
25828
25829 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) {
25830         LDKKeysManager this_arg_conv;
25831         this_arg_conv.inner = (void*)(this_arg & (~1));
25832         this_arg_conv.is_owned = false;
25833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25834         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
25835         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
25836         if (descriptors_constr.datalen > 0)
25837                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25838         else
25839                 descriptors_constr.data = NULL;
25840         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
25841         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
25842                 int64_t descriptors_conv_27 = descriptors_vals[b];
25843                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
25844                 CHECK_ACCESS(descriptors_conv_27_ptr);
25845                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
25846                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
25847                 descriptors_constr.data[b] = descriptors_conv_27_conv;
25848         }
25849         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
25850         LDKCVec_TxOutZ outputs_constr;
25851         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
25852         if (outputs_constr.datalen > 0)
25853                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
25854         else
25855                 outputs_constr.data = NULL;
25856         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
25857         for (size_t h = 0; h < outputs_constr.datalen; h++) {
25858                 int64_t outputs_conv_7 = outputs_vals[h];
25859                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
25860                 CHECK_ACCESS(outputs_conv_7_ptr);
25861                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
25862                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
25863                 outputs_constr.data[h] = outputs_conv_7_conv;
25864         }
25865         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
25866         LDKCVec_u8Z change_destination_script_ref;
25867         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
25868         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
25869         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
25870         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
25871         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
25872         return (uintptr_t)ret_conv;
25873 }
25874
25875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
25876         LDKKeysManager this_arg_conv;
25877         this_arg_conv.inner = (void*)(this_arg & (~1));
25878         this_arg_conv.is_owned = false;
25879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25880         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
25881         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
25882         return (uintptr_t)ret_ret;
25883 }
25884
25885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25886         LDKChannelManager this_obj_conv;
25887         this_obj_conv.inner = (void*)(this_obj & (~1));
25888         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25890         ChannelManager_free(this_obj_conv);
25891 }
25892
25893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25894         LDKChainParameters this_obj_conv;
25895         this_obj_conv.inner = (void*)(this_obj & (~1));
25896         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25898         ChainParameters_free(this_obj_conv);
25899 }
25900
25901 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
25902         LDKChainParameters this_ptr_conv;
25903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25904         this_ptr_conv.is_owned = false;
25905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25906         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
25907         return ret_conv;
25908 }
25909
25910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
25911         LDKChainParameters this_ptr_conv;
25912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25913         this_ptr_conv.is_owned = false;
25914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25915         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
25916         ChainParameters_set_network(&this_ptr_conv, val_conv);
25917 }
25918
25919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
25920         LDKChainParameters this_ptr_conv;
25921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25922         this_ptr_conv.is_owned = false;
25923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25924         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
25925         uintptr_t ret_ref = 0;
25926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25929         ret_ref = (uintptr_t)ret_var.inner;
25930         if (ret_var.is_owned) {
25931                 ret_ref |= 1;
25932         }
25933         return ret_ref;
25934 }
25935
25936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25937         LDKChainParameters this_ptr_conv;
25938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25939         this_ptr_conv.is_owned = false;
25940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25941         LDKBestBlock val_conv;
25942         val_conv.inner = (void*)(val & (~1));
25943         val_conv.is_owned = (val & 1) || (val == 0);
25944         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25945         val_conv = BestBlock_clone(&val_conv);
25946         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
25947 }
25948
25949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
25950         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
25951         LDKBestBlock best_block_arg_conv;
25952         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
25953         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
25954         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
25955         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
25956         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
25957         uintptr_t ret_ref = 0;
25958         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25959         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25961         ret_ref = (uintptr_t)ret_var.inner;
25962         if (ret_var.is_owned) {
25963                 ret_ref |= 1;
25964         }
25965         return ret_ref;
25966 }
25967
25968 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
25969         LDKChainParameters ret_var = ChainParameters_clone(arg);
25970 uintptr_t ret_ref = 0;
25971 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25972 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25973 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25974 ret_ref = (uintptr_t)ret_var.inner;
25975 if (ret_var.is_owned) {
25976         ret_ref |= 1;
25977 }
25978         return ret_ref;
25979 }
25980 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25981         LDKChainParameters arg_conv;
25982         arg_conv.inner = (void*)(arg & (~1));
25983         arg_conv.is_owned = false;
25984         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25985         intptr_t ret_val = ChainParameters_clone_ptr(&arg_conv);
25986         return ret_val;
25987 }
25988
25989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25990         LDKChainParameters orig_conv;
25991         orig_conv.inner = (void*)(orig & (~1));
25992         orig_conv.is_owned = false;
25993         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25994         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
25995         uintptr_t ret_ref = 0;
25996         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25997         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25999         ret_ref = (uintptr_t)ret_var.inner;
26000         if (ret_var.is_owned) {
26001                 ret_ref |= 1;
26002         }
26003         return ret_ref;
26004 }
26005
26006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26007         LDKCounterpartyForwardingInfo this_obj_conv;
26008         this_obj_conv.inner = (void*)(this_obj & (~1));
26009         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26011         CounterpartyForwardingInfo_free(this_obj_conv);
26012 }
26013
26014 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26015         LDKCounterpartyForwardingInfo this_ptr_conv;
26016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26017         this_ptr_conv.is_owned = false;
26018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26019         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
26020         return ret_val;
26021 }
26022
26023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26024         LDKCounterpartyForwardingInfo this_ptr_conv;
26025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26026         this_ptr_conv.is_owned = false;
26027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26028         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
26029 }
26030
26031 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
26032         LDKCounterpartyForwardingInfo this_ptr_conv;
26033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26034         this_ptr_conv.is_owned = false;
26035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26036         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
26037         return ret_val;
26038 }
26039
26040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26041         LDKCounterpartyForwardingInfo this_ptr_conv;
26042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26043         this_ptr_conv.is_owned = false;
26044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26045         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
26046 }
26047
26048 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
26049         LDKCounterpartyForwardingInfo this_ptr_conv;
26050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26051         this_ptr_conv.is_owned = false;
26052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26053         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
26054         return ret_val;
26055 }
26056
26057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26058         LDKCounterpartyForwardingInfo this_ptr_conv;
26059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26060         this_ptr_conv.is_owned = false;
26061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26062         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
26063 }
26064
26065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1new(JNIEnv *env, jclass clz, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) {
26066         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
26067         uintptr_t ret_ref = 0;
26068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26071         ret_ref = (uintptr_t)ret_var.inner;
26072         if (ret_var.is_owned) {
26073                 ret_ref |= 1;
26074         }
26075         return ret_ref;
26076 }
26077
26078 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
26079         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
26080 uintptr_t ret_ref = 0;
26081 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26082 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26083 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26084 ret_ref = (uintptr_t)ret_var.inner;
26085 if (ret_var.is_owned) {
26086         ret_ref |= 1;
26087 }
26088         return ret_ref;
26089 }
26090 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26091         LDKCounterpartyForwardingInfo arg_conv;
26092         arg_conv.inner = (void*)(arg & (~1));
26093         arg_conv.is_owned = false;
26094         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26095         intptr_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
26096         return ret_val;
26097 }
26098
26099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26100         LDKCounterpartyForwardingInfo orig_conv;
26101         orig_conv.inner = (void*)(orig & (~1));
26102         orig_conv.is_owned = false;
26103         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26104         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
26105         uintptr_t ret_ref = 0;
26106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26109         ret_ref = (uintptr_t)ret_var.inner;
26110         if (ret_var.is_owned) {
26111                 ret_ref |= 1;
26112         }
26113         return ret_ref;
26114 }
26115
26116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26117         LDKChannelCounterparty this_obj_conv;
26118         this_obj_conv.inner = (void*)(this_obj & (~1));
26119         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26121         ChannelCounterparty_free(this_obj_conv);
26122 }
26123
26124 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26125         LDKChannelCounterparty this_ptr_conv;
26126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26127         this_ptr_conv.is_owned = false;
26128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26129         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26130         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
26131         return ret_arr;
26132 }
26133
26134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26135         LDKChannelCounterparty this_ptr_conv;
26136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26137         this_ptr_conv.is_owned = false;
26138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26139         LDKPublicKey val_ref;
26140         CHECK((*env)->GetArrayLength(env, val) == 33);
26141         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26142         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
26143 }
26144
26145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
26146         LDKChannelCounterparty this_ptr_conv;
26147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26148         this_ptr_conv.is_owned = false;
26149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26150         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
26151         uintptr_t ret_ref = 0;
26152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26155         ret_ref = (uintptr_t)ret_var.inner;
26156         if (ret_var.is_owned) {
26157                 ret_ref |= 1;
26158         }
26159         return ret_ref;
26160 }
26161
26162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26163         LDKChannelCounterparty this_ptr_conv;
26164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26165         this_ptr_conv.is_owned = false;
26166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26167         LDKInitFeatures val_conv;
26168         val_conv.inner = (void*)(val & (~1));
26169         val_conv.is_owned = (val & 1) || (val == 0);
26170         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26171         val_conv = InitFeatures_clone(&val_conv);
26172         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
26173 }
26174
26175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
26176         LDKChannelCounterparty this_ptr_conv;
26177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26178         this_ptr_conv.is_owned = false;
26179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26180         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
26181         return ret_val;
26182 }
26183
26184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26185         LDKChannelCounterparty this_ptr_conv;
26186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26187         this_ptr_conv.is_owned = false;
26188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26189         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
26190 }
26191
26192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
26193         LDKChannelCounterparty this_ptr_conv;
26194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26195         this_ptr_conv.is_owned = false;
26196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26197         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
26198         uintptr_t ret_ref = 0;
26199         if ((uintptr_t)ret_var.inner > 4096) {
26200                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26201                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26203                 ret_ref = (uintptr_t)ret_var.inner;
26204                 if (ret_var.is_owned) {
26205                         ret_ref |= 1;
26206                 }
26207         }
26208         return ret_ref;
26209 }
26210
26211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26212         LDKChannelCounterparty this_ptr_conv;
26213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26214         this_ptr_conv.is_owned = false;
26215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26216         LDKCounterpartyForwardingInfo val_conv;
26217         val_conv.inner = (void*)(val & (~1));
26218         val_conv.is_owned = (val & 1) || (val == 0);
26219         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26220         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
26221         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
26222 }
26223
26224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1new(JNIEnv *env, jclass clz, int8_tArray node_id_arg, int64_t features_arg, int64_t unspendable_punishment_reserve_arg, int64_t forwarding_info_arg) {
26225         LDKPublicKey node_id_arg_ref;
26226         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
26227         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
26228         LDKInitFeatures features_arg_conv;
26229         features_arg_conv.inner = (void*)(features_arg & (~1));
26230         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
26231         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
26232         features_arg_conv = InitFeatures_clone(&features_arg_conv);
26233         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
26234         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
26235         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
26236         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
26237         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
26238         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
26239         uintptr_t ret_ref = 0;
26240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26243         ret_ref = (uintptr_t)ret_var.inner;
26244         if (ret_var.is_owned) {
26245                 ret_ref |= 1;
26246         }
26247         return ret_ref;
26248 }
26249
26250 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
26251         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
26252 uintptr_t ret_ref = 0;
26253 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26254 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26255 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26256 ret_ref = (uintptr_t)ret_var.inner;
26257 if (ret_var.is_owned) {
26258         ret_ref |= 1;
26259 }
26260         return ret_ref;
26261 }
26262 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26263         LDKChannelCounterparty arg_conv;
26264         arg_conv.inner = (void*)(arg & (~1));
26265         arg_conv.is_owned = false;
26266         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26267         intptr_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
26268         return ret_val;
26269 }
26270
26271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26272         LDKChannelCounterparty orig_conv;
26273         orig_conv.inner = (void*)(orig & (~1));
26274         orig_conv.is_owned = false;
26275         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26276         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
26277         uintptr_t ret_ref = 0;
26278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26281         ret_ref = (uintptr_t)ret_var.inner;
26282         if (ret_var.is_owned) {
26283                 ret_ref |= 1;
26284         }
26285         return ret_ref;
26286 }
26287
26288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26289         LDKChannelDetails this_obj_conv;
26290         this_obj_conv.inner = (void*)(this_obj & (~1));
26291         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26293         ChannelDetails_free(this_obj_conv);
26294 }
26295
26296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26297         LDKChannelDetails this_ptr_conv;
26298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26299         this_ptr_conv.is_owned = false;
26300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26301         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26302         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
26303         return ret_arr;
26304 }
26305
26306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26307         LDKChannelDetails this_ptr_conv;
26308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26309         this_ptr_conv.is_owned = false;
26310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26311         LDKThirtyTwoBytes val_ref;
26312         CHECK((*env)->GetArrayLength(env, val) == 32);
26313         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26314         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
26315 }
26316
26317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
26318         LDKChannelDetails this_ptr_conv;
26319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26320         this_ptr_conv.is_owned = false;
26321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26322         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
26323         uintptr_t ret_ref = 0;
26324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26327         ret_ref = (uintptr_t)ret_var.inner;
26328         if (ret_var.is_owned) {
26329                 ret_ref |= 1;
26330         }
26331         return ret_ref;
26332 }
26333
26334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26335         LDKChannelDetails this_ptr_conv;
26336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26337         this_ptr_conv.is_owned = false;
26338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26339         LDKChannelCounterparty val_conv;
26340         val_conv.inner = (void*)(val & (~1));
26341         val_conv.is_owned = (val & 1) || (val == 0);
26342         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26343         val_conv = ChannelCounterparty_clone(&val_conv);
26344         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
26345 }
26346
26347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
26348         LDKChannelDetails this_ptr_conv;
26349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26350         this_ptr_conv.is_owned = false;
26351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26352         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
26353         uintptr_t ret_ref = 0;
26354         if ((uintptr_t)ret_var.inner > 4096) {
26355                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26356                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26358                 ret_ref = (uintptr_t)ret_var.inner;
26359                 if (ret_var.is_owned) {
26360                         ret_ref |= 1;
26361                 }
26362         }
26363         return ret_ref;
26364 }
26365
26366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26367         LDKChannelDetails this_ptr_conv;
26368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26369         this_ptr_conv.is_owned = false;
26370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26371         LDKOutPoint val_conv;
26372         val_conv.inner = (void*)(val & (~1));
26373         val_conv.is_owned = (val & 1) || (val == 0);
26374         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26375         val_conv = OutPoint_clone(&val_conv);
26376         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
26377 }
26378
26379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26380         LDKChannelDetails this_ptr_conv;
26381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26382         this_ptr_conv.is_owned = false;
26383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26384         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26385         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
26386         uintptr_t ret_ref = (uintptr_t)ret_copy;
26387         return ret_ref;
26388 }
26389
26390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26391         LDKChannelDetails this_ptr_conv;
26392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26393         this_ptr_conv.is_owned = false;
26394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26395         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26396         CHECK_ACCESS(val_ptr);
26397         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26398         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26399         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
26400 }
26401
26402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26403         LDKChannelDetails this_ptr_conv;
26404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26405         this_ptr_conv.is_owned = false;
26406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26407         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
26408         return ret_val;
26409 }
26410
26411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26412         LDKChannelDetails this_ptr_conv;
26413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26414         this_ptr_conv.is_owned = false;
26415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26416         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
26417 }
26418
26419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
26420         LDKChannelDetails this_ptr_conv;
26421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26422         this_ptr_conv.is_owned = false;
26423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26424         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26425         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
26426         uintptr_t ret_ref = (uintptr_t)ret_copy;
26427         return ret_ref;
26428 }
26429
26430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26431         LDKChannelDetails this_ptr_conv;
26432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26433         this_ptr_conv.is_owned = false;
26434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26435         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26436         CHECK_ACCESS(val_ptr);
26437         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26438         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26439         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
26440 }
26441
26442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26443         LDKChannelDetails this_ptr_conv;
26444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26445         this_ptr_conv.is_owned = false;
26446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26447         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
26448         return ret_val;
26449 }
26450
26451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26452         LDKChannelDetails this_ptr_conv;
26453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26454         this_ptr_conv.is_owned = false;
26455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26456         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
26457 }
26458
26459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26460         LDKChannelDetails this_ptr_conv;
26461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26462         this_ptr_conv.is_owned = false;
26463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26464         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
26465         return ret_val;
26466 }
26467
26468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26469         LDKChannelDetails this_ptr_conv;
26470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26471         this_ptr_conv.is_owned = false;
26472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26473         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
26474 }
26475
26476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26477         LDKChannelDetails this_ptr_conv;
26478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26479         this_ptr_conv.is_owned = false;
26480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26481         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
26482         return ret_val;
26483 }
26484
26485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26486         LDKChannelDetails this_ptr_conv;
26487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26488         this_ptr_conv.is_owned = false;
26489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26490         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
26491 }
26492
26493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26494         LDKChannelDetails this_ptr_conv;
26495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26496         this_ptr_conv.is_owned = false;
26497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26498         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
26499         return ret_val;
26500 }
26501
26502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26503         LDKChannelDetails this_ptr_conv;
26504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26505         this_ptr_conv.is_owned = false;
26506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26507         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
26508 }
26509
26510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
26511         LDKChannelDetails this_ptr_conv;
26512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26513         this_ptr_conv.is_owned = false;
26514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26515         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
26516         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
26517         uintptr_t ret_ref = (uintptr_t)ret_copy;
26518         return ret_ref;
26519 }
26520
26521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26522         LDKChannelDetails this_ptr_conv;
26523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26524         this_ptr_conv.is_owned = false;
26525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26526         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26527         CHECK_ACCESS(val_ptr);
26528         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
26529         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
26530         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
26531 }
26532
26533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26534         LDKChannelDetails this_ptr_conv;
26535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26536         this_ptr_conv.is_owned = false;
26537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26538         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
26539         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
26540         uintptr_t ret_ref = (uintptr_t)ret_copy;
26541         return ret_ref;
26542 }
26543
26544 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) {
26545         LDKChannelDetails this_ptr_conv;
26546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26547         this_ptr_conv.is_owned = false;
26548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26549         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26550         CHECK_ACCESS(val_ptr);
26551         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
26552         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
26553         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
26554 }
26555
26556 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
26557         LDKChannelDetails this_ptr_conv;
26558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26559         this_ptr_conv.is_owned = false;
26560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26561         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
26562         return ret_val;
26563 }
26564
26565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26566         LDKChannelDetails this_ptr_conv;
26567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26568         this_ptr_conv.is_owned = false;
26569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26570         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
26571 }
26572
26573 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
26574         LDKChannelDetails this_ptr_conv;
26575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26576         this_ptr_conv.is_owned = false;
26577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26578         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
26579         return ret_val;
26580 }
26581
26582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26583         LDKChannelDetails this_ptr_conv;
26584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26585         this_ptr_conv.is_owned = false;
26586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26587         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
26588 }
26589
26590 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
26591         LDKChannelDetails this_ptr_conv;
26592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26593         this_ptr_conv.is_owned = false;
26594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26595         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
26596         return ret_val;
26597 }
26598
26599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26600         LDKChannelDetails this_ptr_conv;
26601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26602         this_ptr_conv.is_owned = false;
26603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26604         ChannelDetails_set_is_usable(&this_ptr_conv, val);
26605 }
26606
26607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
26608         LDKChannelDetails this_ptr_conv;
26609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26610         this_ptr_conv.is_owned = false;
26611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26612         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
26613         return ret_val;
26614 }
26615
26616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26617         LDKChannelDetails this_ptr_conv;
26618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26619         this_ptr_conv.is_owned = false;
26620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26621         ChannelDetails_set_is_public(&this_ptr_conv, val);
26622 }
26623
26624 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_channel_id_arg, int64_t balance_msat_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) {
26625         LDKThirtyTwoBytes channel_id_arg_ref;
26626         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
26627         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
26628         LDKChannelCounterparty counterparty_arg_conv;
26629         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
26630         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
26631         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
26632         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
26633         LDKOutPoint funding_txo_arg_conv;
26634         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
26635         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
26636         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
26637         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
26638         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
26639         CHECK_ACCESS(short_channel_id_arg_ptr);
26640         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
26641         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
26642         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
26643         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
26644         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
26645         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
26646         CHECK_ACCESS(confirmations_required_arg_ptr);
26647         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
26648         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
26649         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
26650         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
26651         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
26652         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
26653         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_channel_id_arg, balance_msat_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);
26654         uintptr_t ret_ref = 0;
26655         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26656         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26658         ret_ref = (uintptr_t)ret_var.inner;
26659         if (ret_var.is_owned) {
26660                 ret_ref |= 1;
26661         }
26662         return ret_ref;
26663 }
26664
26665 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
26666         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
26667 uintptr_t ret_ref = 0;
26668 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26669 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26670 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26671 ret_ref = (uintptr_t)ret_var.inner;
26672 if (ret_var.is_owned) {
26673         ret_ref |= 1;
26674 }
26675         return ret_ref;
26676 }
26677 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26678         LDKChannelDetails arg_conv;
26679         arg_conv.inner = (void*)(arg & (~1));
26680         arg_conv.is_owned = false;
26681         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26682         intptr_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
26683         return ret_val;
26684 }
26685
26686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26687         LDKChannelDetails orig_conv;
26688         orig_conv.inner = (void*)(orig & (~1));
26689         orig_conv.is_owned = false;
26690         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26691         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
26692         uintptr_t ret_ref = 0;
26693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26696         ret_ref = (uintptr_t)ret_var.inner;
26697         if (ret_var.is_owned) {
26698                 ret_ref |= 1;
26699         }
26700         return ret_ref;
26701 }
26702
26703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26704         if ((this_ptr & 1) != 0) return;
26705         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26706         CHECK_ACCESS(this_ptr_ptr);
26707         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
26708         FREE((void*)this_ptr);
26709         PaymentSendFailure_free(this_ptr_conv);
26710 }
26711
26712 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
26713         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26714         *ret_copy = PaymentSendFailure_clone(arg);
26715 uintptr_t ret_ref = (uintptr_t)ret_copy;
26716         return ret_ref;
26717 }
26718 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26719         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
26720         intptr_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
26721         return ret_val;
26722 }
26723
26724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26725         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
26726         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26727         *ret_copy = PaymentSendFailure_clone(orig_conv);
26728         uintptr_t ret_ref = (uintptr_t)ret_copy;
26729         return ret_ref;
26730 }
26731
26732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
26733         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
26734         CHECK_ACCESS(a_ptr);
26735         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
26736         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
26737         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26738         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
26739         uintptr_t ret_ref = (uintptr_t)ret_copy;
26740         return ret_ref;
26741 }
26742
26743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
26744         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
26745         a_constr.datalen = (*env)->GetArrayLength(env, a);
26746         if (a_constr.datalen > 0)
26747                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26748         else
26749                 a_constr.data = NULL;
26750         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
26751         for (size_t w = 0; w < a_constr.datalen; w++) {
26752                 int64_t a_conv_22 = a_vals[w];
26753                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
26754                 CHECK_ACCESS(a_conv_22_ptr);
26755                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
26756                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
26757                 a_constr.data[w] = a_conv_22_conv;
26758         }
26759         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
26760         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26761         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
26762         uintptr_t ret_ref = (uintptr_t)ret_copy;
26763         return ret_ref;
26764 }
26765
26766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
26767         LDKCVec_APIErrorZ a_constr;
26768         a_constr.datalen = (*env)->GetArrayLength(env, a);
26769         if (a_constr.datalen > 0)
26770                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
26771         else
26772                 a_constr.data = NULL;
26773         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
26774         for (size_t k = 0; k < a_constr.datalen; k++) {
26775                 int64_t a_conv_10 = a_vals[k];
26776                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
26777                 CHECK_ACCESS(a_conv_10_ptr);
26778                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
26779                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
26780                 a_constr.data[k] = a_conv_10_conv;
26781         }
26782         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
26783         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26784         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
26785         uintptr_t ret_ref = (uintptr_t)ret_copy;
26786         return ret_ref;
26787 }
26788
26789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1partial_1failure(JNIEnv *env, jclass clz, int64_tArray results, int64_t failed_paths_retry, int8_tArray payment_id) {
26790         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
26791         results_constr.datalen = (*env)->GetArrayLength(env, results);
26792         if (results_constr.datalen > 0)
26793                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26794         else
26795                 results_constr.data = NULL;
26796         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
26797         for (size_t w = 0; w < results_constr.datalen; w++) {
26798                 int64_t results_conv_22 = results_vals[w];
26799                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
26800                 CHECK_ACCESS(results_conv_22_ptr);
26801                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
26802                 results_constr.data[w] = results_conv_22_conv;
26803         }
26804         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
26805         LDKRouteParameters failed_paths_retry_conv;
26806         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
26807         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
26808         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
26809         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
26810         LDKThirtyTwoBytes payment_id_ref;
26811         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26812         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26813         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26814         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
26815         uintptr_t ret_ref = (uintptr_t)ret_copy;
26816         return ret_ref;
26817 }
26818
26819 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) {
26820         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
26821         CHECK_ACCESS(fee_est_ptr);
26822         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
26823         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
26824                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26825                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
26826         }
26827         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
26828         CHECK_ACCESS(chain_monitor_ptr);
26829         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
26830         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
26831                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26832                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
26833         }
26834         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
26835         CHECK_ACCESS(tx_broadcaster_ptr);
26836         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
26837         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26838                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26839                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
26840         }
26841         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26842         CHECK_ACCESS(logger_ptr);
26843         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26844         if (logger_conv.free == LDKLogger_JCalls_free) {
26845                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26846                 LDKLogger_JCalls_cloned(&logger_conv);
26847         }
26848         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
26849         CHECK_ACCESS(keys_manager_ptr);
26850         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
26851         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26852                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26853                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26854         }
26855         LDKUserConfig config_conv;
26856         config_conv.inner = (void*)(config & (~1));
26857         config_conv.is_owned = (config & 1) || (config == 0);
26858         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
26859         config_conv = UserConfig_clone(&config_conv);
26860         LDKChainParameters params_conv;
26861         params_conv.inner = (void*)(params & (~1));
26862         params_conv.is_owned = (params & 1) || (params == 0);
26863         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
26864         params_conv = ChainParameters_clone(&params_conv);
26865         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
26866         uintptr_t ret_ref = 0;
26867         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26868         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26870         ret_ref = (uintptr_t)ret_var.inner;
26871         if (ret_var.is_owned) {
26872                 ret_ref |= 1;
26873         }
26874         return ret_ref;
26875 }
26876
26877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
26878         LDKChannelManager this_arg_conv;
26879         this_arg_conv.inner = (void*)(this_arg & (~1));
26880         this_arg_conv.is_owned = false;
26881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26882         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
26883         uintptr_t ret_ref = 0;
26884         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26885         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26887         ret_ref = (uintptr_t)ret_var.inner;
26888         if (ret_var.is_owned) {
26889                 ret_ref |= 1;
26890         }
26891         return ret_ref;
26892 }
26893
26894 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_channel_id, int64_t override_config) {
26895         LDKChannelManager this_arg_conv;
26896         this_arg_conv.inner = (void*)(this_arg & (~1));
26897         this_arg_conv.is_owned = false;
26898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26899         LDKPublicKey their_network_key_ref;
26900         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
26901         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
26902         LDKUserConfig override_config_conv;
26903         override_config_conv.inner = (void*)(override_config & (~1));
26904         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
26905         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
26906         override_config_conv = UserConfig_clone(&override_config_conv);
26907         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
26908         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
26909         return (uintptr_t)ret_conv;
26910 }
26911
26912 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
26913         LDKChannelManager this_arg_conv;
26914         this_arg_conv.inner = (void*)(this_arg & (~1));
26915         this_arg_conv.is_owned = false;
26916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26917         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
26918         int64_tArray ret_arr = NULL;
26919         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26920         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26921         for (size_t q = 0; q < ret_var.datalen; q++) {
26922                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26923                 uintptr_t ret_conv_16_ref = 0;
26924                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26925                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26926                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26927                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
26928                 if (ret_conv_16_var.is_owned) {
26929                         ret_conv_16_ref |= 1;
26930                 }
26931                 ret_arr_ptr[q] = ret_conv_16_ref;
26932         }
26933         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26934         FREE(ret_var.data);
26935         return ret_arr;
26936 }
26937
26938 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
26939         LDKChannelManager this_arg_conv;
26940         this_arg_conv.inner = (void*)(this_arg & (~1));
26941         this_arg_conv.is_owned = false;
26942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26943         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
26944         int64_tArray ret_arr = NULL;
26945         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26946         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26947         for (size_t q = 0; q < ret_var.datalen; q++) {
26948                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26949                 uintptr_t ret_conv_16_ref = 0;
26950                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26951                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26952                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26953                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
26954                 if (ret_conv_16_var.is_owned) {
26955                         ret_conv_16_ref |= 1;
26956                 }
26957                 ret_arr_ptr[q] = ret_conv_16_ref;
26958         }
26959         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26960         FREE(ret_var.data);
26961         return ret_arr;
26962 }
26963
26964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
26965         LDKChannelManager this_arg_conv;
26966         this_arg_conv.inner = (void*)(this_arg & (~1));
26967         this_arg_conv.is_owned = false;
26968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26969         unsigned char channel_id_arr[32];
26970         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26971         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
26972         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
26973         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26974         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
26975         return (uintptr_t)ret_conv;
26976 }
26977
26978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int32_t target_feerate_sats_per_1000_weight) {
26979         LDKChannelManager this_arg_conv;
26980         this_arg_conv.inner = (void*)(this_arg & (~1));
26981         this_arg_conv.is_owned = false;
26982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26983         unsigned char channel_id_arr[32];
26984         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26985         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
26986         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
26987         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26988         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
26989         return (uintptr_t)ret_conv;
26990 }
26991
26992 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) {
26993         LDKChannelManager this_arg_conv;
26994         this_arg_conv.inner = (void*)(this_arg & (~1));
26995         this_arg_conv.is_owned = false;
26996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26997         unsigned char channel_id_arr[32];
26998         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26999         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
27000         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27001         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27002         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
27003         return (uintptr_t)ret_conv;
27004 }
27005
27006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
27007         LDKChannelManager this_arg_conv;
27008         this_arg_conv.inner = (void*)(this_arg & (~1));
27009         this_arg_conv.is_owned = false;
27010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27011         ChannelManager_force_close_all_channels(&this_arg_conv);
27012 }
27013
27014 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) {
27015         LDKChannelManager this_arg_conv;
27016         this_arg_conv.inner = (void*)(this_arg & (~1));
27017         this_arg_conv.is_owned = false;
27018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27019         LDKRoute route_conv;
27020         route_conv.inner = (void*)(route & (~1));
27021         route_conv.is_owned = false;
27022         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27023         LDKThirtyTwoBytes payment_hash_ref;
27024         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
27025         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
27026         LDKThirtyTwoBytes payment_secret_ref;
27027         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
27028         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
27029         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
27030         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
27031         return (uintptr_t)ret_conv;
27032 }
27033
27034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_id) {
27035         LDKChannelManager this_arg_conv;
27036         this_arg_conv.inner = (void*)(this_arg & (~1));
27037         this_arg_conv.is_owned = false;
27038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27039         LDKRoute route_conv;
27040         route_conv.inner = (void*)(route & (~1));
27041         route_conv.is_owned = false;
27042         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27043         LDKThirtyTwoBytes payment_id_ref;
27044         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
27045         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
27046         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
27047         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
27048         return (uintptr_t)ret_conv;
27049 }
27050
27051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
27052         LDKChannelManager this_arg_conv;
27053         this_arg_conv.inner = (void*)(this_arg & (~1));
27054         this_arg_conv.is_owned = false;
27055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27056         LDKThirtyTwoBytes payment_id_ref;
27057         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
27058         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
27059         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
27060 }
27061
27062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1spontaneous_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_preimage) {
27063         LDKChannelManager this_arg_conv;
27064         this_arg_conv.inner = (void*)(this_arg & (~1));
27065         this_arg_conv.is_owned = false;
27066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27067         LDKRoute route_conv;
27068         route_conv.inner = (void*)(route & (~1));
27069         route_conv.is_owned = false;
27070         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27071         LDKThirtyTwoBytes payment_preimage_ref;
27072         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
27073         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
27074         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
27075         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
27076         return (uintptr_t)ret_conv;
27077 }
27078
27079 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) {
27080         LDKChannelManager this_arg_conv;
27081         this_arg_conv.inner = (void*)(this_arg & (~1));
27082         this_arg_conv.is_owned = false;
27083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27084         unsigned char temporary_channel_id_arr[32];
27085         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
27086         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
27087         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
27088         LDKTransaction funding_transaction_ref;
27089         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
27090         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
27091         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
27092         funding_transaction_ref.data_is_owned = true;
27093         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27094         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
27095         return (uintptr_t)ret_conv;
27096 }
27097
27098 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) {
27099         LDKChannelManager this_arg_conv;
27100         this_arg_conv.inner = (void*)(this_arg & (~1));
27101         this_arg_conv.is_owned = false;
27102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27103         LDKThreeBytes rgb_ref;
27104         CHECK((*env)->GetArrayLength(env, rgb) == 3);
27105         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
27106         LDKThirtyTwoBytes alias_ref;
27107         CHECK((*env)->GetArrayLength(env, alias) == 32);
27108         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
27109         LDKCVec_NetAddressZ addresses_constr;
27110         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
27111         if (addresses_constr.datalen > 0)
27112                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
27113         else
27114                 addresses_constr.data = NULL;
27115         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
27116         for (size_t m = 0; m < addresses_constr.datalen; m++) {
27117                 int64_t addresses_conv_12 = addresses_vals[m];
27118                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
27119                 CHECK_ACCESS(addresses_conv_12_ptr);
27120                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
27121                 addresses_constr.data[m] = addresses_conv_12_conv;
27122         }
27123         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
27124         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
27125 }
27126
27127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
27128         LDKChannelManager this_arg_conv;
27129         this_arg_conv.inner = (void*)(this_arg & (~1));
27130         this_arg_conv.is_owned = false;
27131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27132         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
27133 }
27134
27135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
27136         LDKChannelManager this_arg_conv;
27137         this_arg_conv.inner = (void*)(this_arg & (~1));
27138         this_arg_conv.is_owned = false;
27139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27140         ChannelManager_timer_tick_occurred(&this_arg_conv);
27141 }
27142
27143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
27144         LDKChannelManager this_arg_conv;
27145         this_arg_conv.inner = (void*)(this_arg & (~1));
27146         this_arg_conv.is_owned = false;
27147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27148         unsigned char payment_hash_arr[32];
27149         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
27150         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
27151         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
27152         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
27153         return ret_val;
27154 }
27155
27156 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
27157         LDKChannelManager this_arg_conv;
27158         this_arg_conv.inner = (void*)(this_arg & (~1));
27159         this_arg_conv.is_owned = false;
27160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27161         LDKThirtyTwoBytes payment_preimage_ref;
27162         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
27163         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
27164         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
27165         return ret_val;
27166 }
27167
27168 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
27169         LDKChannelManager this_arg_conv;
27170         this_arg_conv.inner = (void*)(this_arg & (~1));
27171         this_arg_conv.is_owned = false;
27172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27173         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27174         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
27175         return ret_arr;
27176 }
27177
27178 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) {
27179         LDKChannelManager this_arg_conv;
27180         this_arg_conv.inner = (void*)(this_arg & (~1));
27181         this_arg_conv.is_owned = false;
27182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27183         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27184         CHECK_ACCESS(min_value_msat_ptr);
27185         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27186         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27187         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
27188         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
27189         return (uintptr_t)ret_conv;
27190 }
27191
27192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inbound_1payment_1legacy(JNIEnv *env, jclass clz, int64_t this_arg, int64_t min_value_msat, int32_t invoice_expiry_delta_secs) {
27193         LDKChannelManager this_arg_conv;
27194         this_arg_conv.inner = (void*)(this_arg & (~1));
27195         this_arg_conv.is_owned = false;
27196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27197         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27198         CHECK_ACCESS(min_value_msat_ptr);
27199         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27200         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27201         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
27202         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
27203         return (uintptr_t)ret_conv;
27204 }
27205
27206 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) {
27207         LDKChannelManager this_arg_conv;
27208         this_arg_conv.inner = (void*)(this_arg & (~1));
27209         this_arg_conv.is_owned = false;
27210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27211         LDKThirtyTwoBytes payment_hash_ref;
27212         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
27213         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
27214         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27215         CHECK_ACCESS(min_value_msat_ptr);
27216         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27217         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27218         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
27219         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
27220         return (uintptr_t)ret_conv;
27221 }
27222
27223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1create_1inbound_1payment_1for_1hash_1legacy(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int64_t min_value_msat, int32_t invoice_expiry_delta_secs) {
27224         LDKChannelManager this_arg_conv;
27225         this_arg_conv.inner = (void*)(this_arg & (~1));
27226         this_arg_conv.is_owned = false;
27227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27228         LDKThirtyTwoBytes payment_hash_ref;
27229         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
27230         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
27231         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27232         CHECK_ACCESS(min_value_msat_ptr);
27233         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27234         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27235         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
27236         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
27237         return (uintptr_t)ret_conv;
27238 }
27239
27240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
27241         LDKChannelManager this_arg_conv;
27242         this_arg_conv.inner = (void*)(this_arg & (~1));
27243         this_arg_conv.is_owned = false;
27244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27245         LDKThirtyTwoBytes payment_hash_ref;
27246         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
27247         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
27248         LDKThirtyTwoBytes payment_secret_ref;
27249         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
27250         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
27251         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
27252         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
27253         return (uintptr_t)ret_conv;
27254 }
27255
27256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
27257         LDKChannelManager this_arg_conv;
27258         this_arg_conv.inner = (void*)(this_arg & (~1));
27259         this_arg_conv.is_owned = false;
27260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27261         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
27262         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
27263         return (uintptr_t)ret_ret;
27264 }
27265
27266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
27267         LDKChannelManager this_arg_conv;
27268         this_arg_conv.inner = (void*)(this_arg & (~1));
27269         this_arg_conv.is_owned = false;
27270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27271         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
27272         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
27273         return (uintptr_t)ret_ret;
27274 }
27275
27276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
27277         LDKChannelManager this_arg_conv;
27278         this_arg_conv.inner = (void*)(this_arg & (~1));
27279         this_arg_conv.is_owned = false;
27280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27281         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
27282         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
27283         return (uintptr_t)ret_ret;
27284 }
27285
27286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
27287         LDKChannelManager this_arg_conv;
27288         this_arg_conv.inner = (void*)(this_arg & (~1));
27289         this_arg_conv.is_owned = false;
27290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27291         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
27292         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
27293         return (uintptr_t)ret_ret;
27294 }
27295
27296 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) {
27297         LDKChannelManager this_arg_conv;
27298         this_arg_conv.inner = (void*)(this_arg & (~1));
27299         this_arg_conv.is_owned = false;
27300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27301         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
27302         return ret_val;
27303 }
27304
27305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
27306         LDKChannelManager this_arg_conv;
27307         this_arg_conv.inner = (void*)(this_arg & (~1));
27308         this_arg_conv.is_owned = false;
27309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27310         ChannelManager_await_persistable_update(&this_arg_conv);
27311 }
27312
27313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
27314         LDKChannelManager this_arg_conv;
27315         this_arg_conv.inner = (void*)(this_arg & (~1));
27316         this_arg_conv.is_owned = false;
27317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27318         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
27319         uintptr_t ret_ref = 0;
27320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27323         ret_ref = (uintptr_t)ret_var.inner;
27324         if (ret_var.is_owned) {
27325                 ret_ref |= 1;
27326         }
27327         return ret_ref;
27328 }
27329
27330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
27331         LDKChannelManager this_arg_conv;
27332         this_arg_conv.inner = (void*)(this_arg & (~1));
27333         this_arg_conv.is_owned = false;
27334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27335         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
27336         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
27337         return (uintptr_t)ret_ret;
27338 }
27339
27340 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
27341         LDKChannelManager obj_conv;
27342         obj_conv.inner = (void*)(obj & (~1));
27343         obj_conv.is_owned = false;
27344         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27345         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
27346         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27347         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27348         CVec_u8Z_free(ret_var);
27349         return ret_arr;
27350 }
27351
27352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27353         LDKChannelManagerReadArgs this_obj_conv;
27354         this_obj_conv.inner = (void*)(this_obj & (~1));
27355         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27357         ChannelManagerReadArgs_free(this_obj_conv);
27358 }
27359
27360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
27361         LDKChannelManagerReadArgs this_ptr_conv;
27362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27363         this_ptr_conv.is_owned = false;
27364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27365         // WARNING: This object doesn't live past this scope, needs clone!
27366         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
27367         return ret_ret;
27368 }
27369
27370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27371         LDKChannelManagerReadArgs this_ptr_conv;
27372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27373         this_ptr_conv.is_owned = false;
27374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27375         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27376         CHECK_ACCESS(val_ptr);
27377         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
27378         if (val_conv.free == LDKKeysInterface_JCalls_free) {
27379                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27380                 LDKKeysInterface_JCalls_cloned(&val_conv);
27381         }
27382         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
27383 }
27384
27385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
27386         LDKChannelManagerReadArgs this_ptr_conv;
27387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27388         this_ptr_conv.is_owned = false;
27389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27390         // WARNING: This object doesn't live past this scope, needs clone!
27391         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
27392         return ret_ret;
27393 }
27394
27395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27396         LDKChannelManagerReadArgs this_ptr_conv;
27397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27398         this_ptr_conv.is_owned = false;
27399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27400         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27401         CHECK_ACCESS(val_ptr);
27402         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
27403         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
27404                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27405                 LDKFeeEstimator_JCalls_cloned(&val_conv);
27406         }
27407         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
27408 }
27409
27410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
27411         LDKChannelManagerReadArgs this_ptr_conv;
27412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27413         this_ptr_conv.is_owned = false;
27414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27415         // WARNING: This object doesn't live past this scope, needs clone!
27416         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
27417         return ret_ret;
27418 }
27419
27420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27421         LDKChannelManagerReadArgs this_ptr_conv;
27422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27423         this_ptr_conv.is_owned = false;
27424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27425         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27426         CHECK_ACCESS(val_ptr);
27427         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
27428         if (val_conv.free == LDKWatch_JCalls_free) {
27429                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27430                 LDKWatch_JCalls_cloned(&val_conv);
27431         }
27432         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
27433 }
27434
27435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
27436         LDKChannelManagerReadArgs this_ptr_conv;
27437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27438         this_ptr_conv.is_owned = false;
27439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27440         // WARNING: This object doesn't live past this scope, needs clone!
27441         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
27442         return ret_ret;
27443 }
27444
27445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27446         LDKChannelManagerReadArgs this_ptr_conv;
27447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27448         this_ptr_conv.is_owned = false;
27449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27450         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27451         CHECK_ACCESS(val_ptr);
27452         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
27453         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
27454                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27455                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
27456         }
27457         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
27458 }
27459
27460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
27461         LDKChannelManagerReadArgs this_ptr_conv;
27462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27463         this_ptr_conv.is_owned = false;
27464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27465         // WARNING: This object doesn't live past this scope, needs clone!
27466         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
27467         return ret_ret;
27468 }
27469
27470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27471         LDKChannelManagerReadArgs this_ptr_conv;
27472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27473         this_ptr_conv.is_owned = false;
27474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27475         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27476         CHECK_ACCESS(val_ptr);
27477         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
27478         if (val_conv.free == LDKLogger_JCalls_free) {
27479                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27480                 LDKLogger_JCalls_cloned(&val_conv);
27481         }
27482         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
27483 }
27484
27485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
27486         LDKChannelManagerReadArgs this_ptr_conv;
27487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27488         this_ptr_conv.is_owned = false;
27489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27490         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
27491         uintptr_t ret_ref = 0;
27492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27495         ret_ref = (uintptr_t)ret_var.inner;
27496         if (ret_var.is_owned) {
27497                 ret_ref |= 1;
27498         }
27499         return ret_ref;
27500 }
27501
27502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27503         LDKChannelManagerReadArgs this_ptr_conv;
27504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27505         this_ptr_conv.is_owned = false;
27506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27507         LDKUserConfig val_conv;
27508         val_conv.inner = (void*)(val & (~1));
27509         val_conv.is_owned = (val & 1) || (val == 0);
27510         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27511         val_conv = UserConfig_clone(&val_conv);
27512         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
27513 }
27514
27515 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) {
27516         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
27517         CHECK_ACCESS(keys_manager_ptr);
27518         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
27519         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
27520                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27521                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
27522         }
27523         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27524         CHECK_ACCESS(fee_estimator_ptr);
27525         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27526         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27527                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27528                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27529         }
27530         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
27531         CHECK_ACCESS(chain_monitor_ptr);
27532         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
27533         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
27534                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27535                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
27536         }
27537         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
27538         CHECK_ACCESS(tx_broadcaster_ptr);
27539         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
27540         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27541                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27542                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
27543         }
27544         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27545         CHECK_ACCESS(logger_ptr);
27546         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27547         if (logger_conv.free == LDKLogger_JCalls_free) {
27548                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27549                 LDKLogger_JCalls_cloned(&logger_conv);
27550         }
27551         LDKUserConfig default_config_conv;
27552         default_config_conv.inner = (void*)(default_config & (~1));
27553         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
27554         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
27555         default_config_conv = UserConfig_clone(&default_config_conv);
27556         LDKCVec_ChannelMonitorZ channel_monitors_constr;
27557         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
27558         if (channel_monitors_constr.datalen > 0)
27559                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
27560         else
27561                 channel_monitors_constr.data = NULL;
27562         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
27563         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
27564                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
27565                 LDKChannelMonitor channel_monitors_conv_16_conv;
27566                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
27567                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
27568                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
27569                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
27570         }
27571         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
27572         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);
27573         uintptr_t ret_ref = 0;
27574         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27575         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27577         ret_ref = (uintptr_t)ret_var.inner;
27578         if (ret_var.is_owned) {
27579                 ret_ref |= 1;
27580         }
27581         return ret_ref;
27582 }
27583
27584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
27585         LDKu8slice ser_ref;
27586         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27587         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27588         LDKChannelManagerReadArgs arg_conv;
27589         arg_conv.inner = (void*)(arg & (~1));
27590         arg_conv.is_owned = (arg & 1) || (arg == 0);
27591         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27592         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
27593         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
27594         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
27595         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27596         return (uintptr_t)ret_conv;
27597 }
27598
27599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27600         LDKDecodeError this_obj_conv;
27601         this_obj_conv.inner = (void*)(this_obj & (~1));
27602         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27604         DecodeError_free(this_obj_conv);
27605 }
27606
27607 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
27608         LDKDecodeError ret_var = DecodeError_clone(arg);
27609 uintptr_t ret_ref = 0;
27610 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27611 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27612 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27613 ret_ref = (uintptr_t)ret_var.inner;
27614 if (ret_var.is_owned) {
27615         ret_ref |= 1;
27616 }
27617         return ret_ref;
27618 }
27619 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27620         LDKDecodeError arg_conv;
27621         arg_conv.inner = (void*)(arg & (~1));
27622         arg_conv.is_owned = false;
27623         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27624         intptr_t ret_val = DecodeError_clone_ptr(&arg_conv);
27625         return ret_val;
27626 }
27627
27628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27629         LDKDecodeError orig_conv;
27630         orig_conv.inner = (void*)(orig & (~1));
27631         orig_conv.is_owned = false;
27632         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27633         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
27634         uintptr_t ret_ref = 0;
27635         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27636         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27638         ret_ref = (uintptr_t)ret_var.inner;
27639         if (ret_var.is_owned) {
27640                 ret_ref |= 1;
27641         }
27642         return ret_ref;
27643 }
27644
27645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27646         LDKInit this_obj_conv;
27647         this_obj_conv.inner = (void*)(this_obj & (~1));
27648         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27650         Init_free(this_obj_conv);
27651 }
27652
27653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
27654         LDKInit this_ptr_conv;
27655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27656         this_ptr_conv.is_owned = false;
27657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27658         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
27659         uintptr_t ret_ref = 0;
27660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27663         ret_ref = (uintptr_t)ret_var.inner;
27664         if (ret_var.is_owned) {
27665                 ret_ref |= 1;
27666         }
27667         return ret_ref;
27668 }
27669
27670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27671         LDKInit this_ptr_conv;
27672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27673         this_ptr_conv.is_owned = false;
27674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27675         LDKInitFeatures val_conv;
27676         val_conv.inner = (void*)(val & (~1));
27677         val_conv.is_owned = (val & 1) || (val == 0);
27678         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27679         val_conv = InitFeatures_clone(&val_conv);
27680         Init_set_features(&this_ptr_conv, val_conv);
27681 }
27682
27683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
27684         LDKInitFeatures features_arg_conv;
27685         features_arg_conv.inner = (void*)(features_arg & (~1));
27686         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
27687         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
27688         features_arg_conv = InitFeatures_clone(&features_arg_conv);
27689         LDKInit ret_var = Init_new(features_arg_conv);
27690         uintptr_t ret_ref = 0;
27691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27694         ret_ref = (uintptr_t)ret_var.inner;
27695         if (ret_var.is_owned) {
27696                 ret_ref |= 1;
27697         }
27698         return ret_ref;
27699 }
27700
27701 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
27702         LDKInit ret_var = Init_clone(arg);
27703 uintptr_t ret_ref = 0;
27704 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27705 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27706 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27707 ret_ref = (uintptr_t)ret_var.inner;
27708 if (ret_var.is_owned) {
27709         ret_ref |= 1;
27710 }
27711         return ret_ref;
27712 }
27713 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27714         LDKInit arg_conv;
27715         arg_conv.inner = (void*)(arg & (~1));
27716         arg_conv.is_owned = false;
27717         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27718         intptr_t ret_val = Init_clone_ptr(&arg_conv);
27719         return ret_val;
27720 }
27721
27722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27723         LDKInit orig_conv;
27724         orig_conv.inner = (void*)(orig & (~1));
27725         orig_conv.is_owned = false;
27726         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27727         LDKInit ret_var = Init_clone(&orig_conv);
27728         uintptr_t ret_ref = 0;
27729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27732         ret_ref = (uintptr_t)ret_var.inner;
27733         if (ret_var.is_owned) {
27734                 ret_ref |= 1;
27735         }
27736         return ret_ref;
27737 }
27738
27739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27740         LDKErrorMessage this_obj_conv;
27741         this_obj_conv.inner = (void*)(this_obj & (~1));
27742         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27744         ErrorMessage_free(this_obj_conv);
27745 }
27746
27747 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27748         LDKErrorMessage this_ptr_conv;
27749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27750         this_ptr_conv.is_owned = false;
27751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27752         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27753         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
27754         return ret_arr;
27755 }
27756
27757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27758         LDKErrorMessage this_ptr_conv;
27759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27760         this_ptr_conv.is_owned = false;
27761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27762         LDKThirtyTwoBytes val_ref;
27763         CHECK((*env)->GetArrayLength(env, val) == 32);
27764         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27765         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
27766 }
27767
27768 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
27769         LDKErrorMessage this_ptr_conv;
27770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27771         this_ptr_conv.is_owned = false;
27772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27773         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
27774         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27775         Str_free(ret_str);
27776         return ret_conv;
27777 }
27778
27779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27780         LDKErrorMessage this_ptr_conv;
27781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27782         this_ptr_conv.is_owned = false;
27783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27784         LDKStr val_conv = java_to_owned_str(env, val);
27785         ErrorMessage_set_data(&this_ptr_conv, val_conv);
27786 }
27787
27788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
27789         LDKThirtyTwoBytes channel_id_arg_ref;
27790         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27791         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27792         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
27793         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
27794         uintptr_t ret_ref = 0;
27795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27798         ret_ref = (uintptr_t)ret_var.inner;
27799         if (ret_var.is_owned) {
27800                 ret_ref |= 1;
27801         }
27802         return ret_ref;
27803 }
27804
27805 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
27806         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
27807 uintptr_t ret_ref = 0;
27808 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27809 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27810 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27811 ret_ref = (uintptr_t)ret_var.inner;
27812 if (ret_var.is_owned) {
27813         ret_ref |= 1;
27814 }
27815         return ret_ref;
27816 }
27817 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27818         LDKErrorMessage arg_conv;
27819         arg_conv.inner = (void*)(arg & (~1));
27820         arg_conv.is_owned = false;
27821         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27822         intptr_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
27823         return ret_val;
27824 }
27825
27826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27827         LDKErrorMessage orig_conv;
27828         orig_conv.inner = (void*)(orig & (~1));
27829         orig_conv.is_owned = false;
27830         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27831         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
27832         uintptr_t ret_ref = 0;
27833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27836         ret_ref = (uintptr_t)ret_var.inner;
27837         if (ret_var.is_owned) {
27838                 ret_ref |= 1;
27839         }
27840         return ret_ref;
27841 }
27842
27843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27844         LDKPing this_obj_conv;
27845         this_obj_conv.inner = (void*)(this_obj & (~1));
27846         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27848         Ping_free(this_obj_conv);
27849 }
27850
27851 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
27852         LDKPing this_ptr_conv;
27853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27854         this_ptr_conv.is_owned = false;
27855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27856         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
27857         return ret_val;
27858 }
27859
27860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27861         LDKPing this_ptr_conv;
27862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27863         this_ptr_conv.is_owned = false;
27864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27865         Ping_set_ponglen(&this_ptr_conv, val);
27866 }
27867
27868 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
27869         LDKPing this_ptr_conv;
27870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27871         this_ptr_conv.is_owned = false;
27872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27873         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
27874         return ret_val;
27875 }
27876
27877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27878         LDKPing this_ptr_conv;
27879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27880         this_ptr_conv.is_owned = false;
27881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27882         Ping_set_byteslen(&this_ptr_conv, val);
27883 }
27884
27885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
27886         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
27887         uintptr_t ret_ref = 0;
27888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27891         ret_ref = (uintptr_t)ret_var.inner;
27892         if (ret_var.is_owned) {
27893                 ret_ref |= 1;
27894         }
27895         return ret_ref;
27896 }
27897
27898 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
27899         LDKPing ret_var = Ping_clone(arg);
27900 uintptr_t ret_ref = 0;
27901 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27902 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27903 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27904 ret_ref = (uintptr_t)ret_var.inner;
27905 if (ret_var.is_owned) {
27906         ret_ref |= 1;
27907 }
27908         return ret_ref;
27909 }
27910 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27911         LDKPing arg_conv;
27912         arg_conv.inner = (void*)(arg & (~1));
27913         arg_conv.is_owned = false;
27914         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27915         intptr_t ret_val = Ping_clone_ptr(&arg_conv);
27916         return ret_val;
27917 }
27918
27919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27920         LDKPing orig_conv;
27921         orig_conv.inner = (void*)(orig & (~1));
27922         orig_conv.is_owned = false;
27923         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27924         LDKPing ret_var = Ping_clone(&orig_conv);
27925         uintptr_t ret_ref = 0;
27926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27929         ret_ref = (uintptr_t)ret_var.inner;
27930         if (ret_var.is_owned) {
27931                 ret_ref |= 1;
27932         }
27933         return ret_ref;
27934 }
27935
27936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27937         LDKPong this_obj_conv;
27938         this_obj_conv.inner = (void*)(this_obj & (~1));
27939         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27941         Pong_free(this_obj_conv);
27942 }
27943
27944 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
27945         LDKPong this_ptr_conv;
27946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27947         this_ptr_conv.is_owned = false;
27948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27949         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
27950         return ret_val;
27951 }
27952
27953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27954         LDKPong this_ptr_conv;
27955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27956         this_ptr_conv.is_owned = false;
27957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27958         Pong_set_byteslen(&this_ptr_conv, val);
27959 }
27960
27961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
27962         LDKPong ret_var = Pong_new(byteslen_arg);
27963         uintptr_t ret_ref = 0;
27964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27967         ret_ref = (uintptr_t)ret_var.inner;
27968         if (ret_var.is_owned) {
27969                 ret_ref |= 1;
27970         }
27971         return ret_ref;
27972 }
27973
27974 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
27975         LDKPong ret_var = Pong_clone(arg);
27976 uintptr_t ret_ref = 0;
27977 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27978 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27979 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27980 ret_ref = (uintptr_t)ret_var.inner;
27981 if (ret_var.is_owned) {
27982         ret_ref |= 1;
27983 }
27984         return ret_ref;
27985 }
27986 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27987         LDKPong arg_conv;
27988         arg_conv.inner = (void*)(arg & (~1));
27989         arg_conv.is_owned = false;
27990         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27991         intptr_t ret_val = Pong_clone_ptr(&arg_conv);
27992         return ret_val;
27993 }
27994
27995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27996         LDKPong orig_conv;
27997         orig_conv.inner = (void*)(orig & (~1));
27998         orig_conv.is_owned = false;
27999         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28000         LDKPong ret_var = Pong_clone(&orig_conv);
28001         uintptr_t ret_ref = 0;
28002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28005         ret_ref = (uintptr_t)ret_var.inner;
28006         if (ret_var.is_owned) {
28007                 ret_ref |= 1;
28008         }
28009         return ret_ref;
28010 }
28011
28012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28013         LDKOpenChannel this_obj_conv;
28014         this_obj_conv.inner = (void*)(this_obj & (~1));
28015         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28017         OpenChannel_free(this_obj_conv);
28018 }
28019
28020 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
28021         LDKOpenChannel this_ptr_conv;
28022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28023         this_ptr_conv.is_owned = false;
28024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28025         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28026         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
28027         return ret_arr;
28028 }
28029
28030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28031         LDKOpenChannel this_ptr_conv;
28032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28033         this_ptr_conv.is_owned = false;
28034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28035         LDKThirtyTwoBytes val_ref;
28036         CHECK((*env)->GetArrayLength(env, val) == 32);
28037         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28038         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
28039 }
28040
28041 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28042         LDKOpenChannel this_ptr_conv;
28043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28044         this_ptr_conv.is_owned = false;
28045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28046         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28047         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
28048         return ret_arr;
28049 }
28050
28051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28052         LDKOpenChannel this_ptr_conv;
28053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28054         this_ptr_conv.is_owned = false;
28055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28056         LDKThirtyTwoBytes val_ref;
28057         CHECK((*env)->GetArrayLength(env, val) == 32);
28058         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28059         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
28060 }
28061
28062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28063         LDKOpenChannel this_ptr_conv;
28064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28065         this_ptr_conv.is_owned = false;
28066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28067         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
28068         return ret_val;
28069 }
28070
28071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28072         LDKOpenChannel this_ptr_conv;
28073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28074         this_ptr_conv.is_owned = false;
28075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28076         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
28077 }
28078
28079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28080         LDKOpenChannel this_ptr_conv;
28081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28082         this_ptr_conv.is_owned = false;
28083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28084         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
28085         return ret_val;
28086 }
28087
28088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28089         LDKOpenChannel this_ptr_conv;
28090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28091         this_ptr_conv.is_owned = false;
28092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28093         OpenChannel_set_push_msat(&this_ptr_conv, val);
28094 }
28095
28096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28097         LDKOpenChannel this_ptr_conv;
28098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28099         this_ptr_conv.is_owned = false;
28100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28101         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
28102         return ret_val;
28103 }
28104
28105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28106         LDKOpenChannel this_ptr_conv;
28107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28108         this_ptr_conv.is_owned = false;
28109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28110         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
28111 }
28112
28113 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) {
28114         LDKOpenChannel this_ptr_conv;
28115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28116         this_ptr_conv.is_owned = false;
28117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28118         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
28119         return ret_val;
28120 }
28121
28122 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) {
28123         LDKOpenChannel this_ptr_conv;
28124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28125         this_ptr_conv.is_owned = false;
28126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28127         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28128 }
28129
28130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28131         LDKOpenChannel this_ptr_conv;
28132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28133         this_ptr_conv.is_owned = false;
28134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28135         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
28136         return ret_val;
28137 }
28138
28139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28140         LDKOpenChannel this_ptr_conv;
28141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28142         this_ptr_conv.is_owned = false;
28143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28144         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
28145 }
28146
28147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28148         LDKOpenChannel this_ptr_conv;
28149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28150         this_ptr_conv.is_owned = false;
28151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28152         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
28153         return ret_val;
28154 }
28155
28156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28157         LDKOpenChannel this_ptr_conv;
28158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28159         this_ptr_conv.is_owned = false;
28160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28161         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
28162 }
28163
28164 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
28165         LDKOpenChannel this_ptr_conv;
28166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28167         this_ptr_conv.is_owned = false;
28168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28169         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
28170         return ret_val;
28171 }
28172
28173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28174         LDKOpenChannel this_ptr_conv;
28175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28176         this_ptr_conv.is_owned = false;
28177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28178         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
28179 }
28180
28181 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28182         LDKOpenChannel this_ptr_conv;
28183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28184         this_ptr_conv.is_owned = false;
28185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28186         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
28187         return ret_val;
28188 }
28189
28190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28191         LDKOpenChannel this_ptr_conv;
28192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28193         this_ptr_conv.is_owned = false;
28194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28195         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
28196 }
28197
28198 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28199         LDKOpenChannel this_ptr_conv;
28200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28201         this_ptr_conv.is_owned = false;
28202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28203         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
28204         return ret_val;
28205 }
28206
28207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28208         LDKOpenChannel this_ptr_conv;
28209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28210         this_ptr_conv.is_owned = false;
28211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28212         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
28213 }
28214
28215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28216         LDKOpenChannel this_ptr_conv;
28217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28218         this_ptr_conv.is_owned = false;
28219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28220         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28221         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
28222         return ret_arr;
28223 }
28224
28225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28226         LDKOpenChannel this_ptr_conv;
28227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28228         this_ptr_conv.is_owned = false;
28229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28230         LDKPublicKey val_ref;
28231         CHECK((*env)->GetArrayLength(env, val) == 33);
28232         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28233         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
28234 }
28235
28236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28237         LDKOpenChannel this_ptr_conv;
28238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28239         this_ptr_conv.is_owned = false;
28240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28241         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28242         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
28243         return ret_arr;
28244 }
28245
28246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28247         LDKOpenChannel this_ptr_conv;
28248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28249         this_ptr_conv.is_owned = false;
28250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28251         LDKPublicKey val_ref;
28252         CHECK((*env)->GetArrayLength(env, val) == 33);
28253         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28254         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
28255 }
28256
28257 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
28258         LDKOpenChannel this_ptr_conv;
28259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28260         this_ptr_conv.is_owned = false;
28261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28262         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28263         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
28264         return ret_arr;
28265 }
28266
28267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28268         LDKOpenChannel this_ptr_conv;
28269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28270         this_ptr_conv.is_owned = false;
28271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28272         LDKPublicKey val_ref;
28273         CHECK((*env)->GetArrayLength(env, val) == 33);
28274         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28275         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
28276 }
28277
28278 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28279         LDKOpenChannel this_ptr_conv;
28280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28281         this_ptr_conv.is_owned = false;
28282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28283         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28284         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
28285         return ret_arr;
28286 }
28287
28288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28289         LDKOpenChannel this_ptr_conv;
28290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28291         this_ptr_conv.is_owned = false;
28292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28293         LDKPublicKey val_ref;
28294         CHECK((*env)->GetArrayLength(env, val) == 33);
28295         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28296         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
28297 }
28298
28299 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28300         LDKOpenChannel this_ptr_conv;
28301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28302         this_ptr_conv.is_owned = false;
28303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28304         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28305         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
28306         return ret_arr;
28307 }
28308
28309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28310         LDKOpenChannel this_ptr_conv;
28311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28312         this_ptr_conv.is_owned = false;
28313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28314         LDKPublicKey val_ref;
28315         CHECK((*env)->GetArrayLength(env, val) == 33);
28316         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28317         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
28318 }
28319
28320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
28321         LDKOpenChannel this_ptr_conv;
28322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28323         this_ptr_conv.is_owned = false;
28324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28325         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28326         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
28327         return ret_arr;
28328 }
28329
28330 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) {
28331         LDKOpenChannel this_ptr_conv;
28332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28333         this_ptr_conv.is_owned = false;
28334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28335         LDKPublicKey val_ref;
28336         CHECK((*env)->GetArrayLength(env, val) == 33);
28337         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28338         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
28339 }
28340
28341 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
28342         LDKOpenChannel this_ptr_conv;
28343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28344         this_ptr_conv.is_owned = false;
28345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28346         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
28347         return ret_val;
28348 }
28349
28350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
28351         LDKOpenChannel this_ptr_conv;
28352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28353         this_ptr_conv.is_owned = false;
28354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28355         OpenChannel_set_channel_flags(&this_ptr_conv, val);
28356 }
28357
28358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
28359         LDKOpenChannel this_ptr_conv;
28360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28361         this_ptr_conv.is_owned = false;
28362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28363         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
28364         uintptr_t ret_ref = 0;
28365         if ((uintptr_t)ret_var.inner > 4096) {
28366                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28367                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28369                 ret_ref = (uintptr_t)ret_var.inner;
28370                 if (ret_var.is_owned) {
28371                         ret_ref |= 1;
28372                 }
28373         }
28374         return ret_ref;
28375 }
28376
28377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28378         LDKOpenChannel this_ptr_conv;
28379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28380         this_ptr_conv.is_owned = false;
28381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28382         LDKChannelTypeFeatures val_conv;
28383         val_conv.inner = (void*)(val & (~1));
28384         val_conv.is_owned = (val & 1) || (val == 0);
28385         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28386         val_conv = ChannelTypeFeatures_clone(&val_conv);
28387         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
28388 }
28389
28390 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
28391         LDKOpenChannel ret_var = OpenChannel_clone(arg);
28392 uintptr_t ret_ref = 0;
28393 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28394 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28395 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28396 ret_ref = (uintptr_t)ret_var.inner;
28397 if (ret_var.is_owned) {
28398         ret_ref |= 1;
28399 }
28400         return ret_ref;
28401 }
28402 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28403         LDKOpenChannel arg_conv;
28404         arg_conv.inner = (void*)(arg & (~1));
28405         arg_conv.is_owned = false;
28406         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28407         intptr_t ret_val = OpenChannel_clone_ptr(&arg_conv);
28408         return ret_val;
28409 }
28410
28411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28412         LDKOpenChannel orig_conv;
28413         orig_conv.inner = (void*)(orig & (~1));
28414         orig_conv.is_owned = false;
28415         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28416         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
28417         uintptr_t ret_ref = 0;
28418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28421         ret_ref = (uintptr_t)ret_var.inner;
28422         if (ret_var.is_owned) {
28423                 ret_ref |= 1;
28424         }
28425         return ret_ref;
28426 }
28427
28428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28429         LDKAcceptChannel this_obj_conv;
28430         this_obj_conv.inner = (void*)(this_obj & (~1));
28431         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28433         AcceptChannel_free(this_obj_conv);
28434 }
28435
28436 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28437         LDKAcceptChannel this_ptr_conv;
28438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28439         this_ptr_conv.is_owned = false;
28440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28441         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28442         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
28443         return ret_arr;
28444 }
28445
28446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28447         LDKAcceptChannel this_ptr_conv;
28448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28449         this_ptr_conv.is_owned = false;
28450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28451         LDKThirtyTwoBytes val_ref;
28452         CHECK((*env)->GetArrayLength(env, val) == 32);
28453         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28454         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
28455 }
28456
28457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28458         LDKAcceptChannel this_ptr_conv;
28459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28460         this_ptr_conv.is_owned = false;
28461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28462         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
28463         return ret_val;
28464 }
28465
28466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28467         LDKAcceptChannel this_ptr_conv;
28468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28469         this_ptr_conv.is_owned = false;
28470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28471         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
28472 }
28473
28474 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) {
28475         LDKAcceptChannel this_ptr_conv;
28476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28477         this_ptr_conv.is_owned = false;
28478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28479         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
28480         return ret_val;
28481 }
28482
28483 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) {
28484         LDKAcceptChannel this_ptr_conv;
28485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28486         this_ptr_conv.is_owned = false;
28487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28488         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28489 }
28490
28491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28492         LDKAcceptChannel this_ptr_conv;
28493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28494         this_ptr_conv.is_owned = false;
28495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28496         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
28497         return ret_val;
28498 }
28499
28500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28501         LDKAcceptChannel this_ptr_conv;
28502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28503         this_ptr_conv.is_owned = false;
28504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28505         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
28506 }
28507
28508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28509         LDKAcceptChannel this_ptr_conv;
28510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28511         this_ptr_conv.is_owned = false;
28512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28513         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
28514         return ret_val;
28515 }
28516
28517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28518         LDKAcceptChannel this_ptr_conv;
28519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28520         this_ptr_conv.is_owned = false;
28521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28522         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
28523 }
28524
28525 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
28526         LDKAcceptChannel this_ptr_conv;
28527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28528         this_ptr_conv.is_owned = false;
28529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28530         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
28531         return ret_val;
28532 }
28533
28534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28535         LDKAcceptChannel this_ptr_conv;
28536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28537         this_ptr_conv.is_owned = false;
28538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28539         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
28540 }
28541
28542 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28543         LDKAcceptChannel this_ptr_conv;
28544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28545         this_ptr_conv.is_owned = false;
28546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28547         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
28548         return ret_val;
28549 }
28550
28551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28552         LDKAcceptChannel this_ptr_conv;
28553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28554         this_ptr_conv.is_owned = false;
28555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28556         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
28557 }
28558
28559 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28560         LDKAcceptChannel this_ptr_conv;
28561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28562         this_ptr_conv.is_owned = false;
28563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28564         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
28565         return ret_val;
28566 }
28567
28568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28569         LDKAcceptChannel this_ptr_conv;
28570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28571         this_ptr_conv.is_owned = false;
28572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28573         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
28574 }
28575
28576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28577         LDKAcceptChannel this_ptr_conv;
28578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28579         this_ptr_conv.is_owned = false;
28580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28581         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28582         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
28583         return ret_arr;
28584 }
28585
28586 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28587         LDKAcceptChannel this_ptr_conv;
28588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28589         this_ptr_conv.is_owned = false;
28590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28591         LDKPublicKey val_ref;
28592         CHECK((*env)->GetArrayLength(env, val) == 33);
28593         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28594         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
28595 }
28596
28597 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28598         LDKAcceptChannel this_ptr_conv;
28599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28600         this_ptr_conv.is_owned = false;
28601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28602         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28603         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
28604         return ret_arr;
28605 }
28606
28607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28608         LDKAcceptChannel this_ptr_conv;
28609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28610         this_ptr_conv.is_owned = false;
28611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28612         LDKPublicKey val_ref;
28613         CHECK((*env)->GetArrayLength(env, val) == 33);
28614         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28615         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
28616 }
28617
28618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
28619         LDKAcceptChannel this_ptr_conv;
28620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28621         this_ptr_conv.is_owned = false;
28622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28623         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28624         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
28625         return ret_arr;
28626 }
28627
28628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28629         LDKAcceptChannel this_ptr_conv;
28630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28631         this_ptr_conv.is_owned = false;
28632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28633         LDKPublicKey val_ref;
28634         CHECK((*env)->GetArrayLength(env, val) == 33);
28635         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28636         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
28637 }
28638
28639 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28640         LDKAcceptChannel this_ptr_conv;
28641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28642         this_ptr_conv.is_owned = false;
28643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28644         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28645         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
28646         return ret_arr;
28647 }
28648
28649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28650         LDKAcceptChannel this_ptr_conv;
28651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28652         this_ptr_conv.is_owned = false;
28653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28654         LDKPublicKey val_ref;
28655         CHECK((*env)->GetArrayLength(env, val) == 33);
28656         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28657         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
28658 }
28659
28660 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28661         LDKAcceptChannel this_ptr_conv;
28662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28663         this_ptr_conv.is_owned = false;
28664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28665         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28666         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
28667         return ret_arr;
28668 }
28669
28670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28671         LDKAcceptChannel this_ptr_conv;
28672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28673         this_ptr_conv.is_owned = false;
28674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28675         LDKPublicKey val_ref;
28676         CHECK((*env)->GetArrayLength(env, val) == 33);
28677         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28678         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
28679 }
28680
28681 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
28682         LDKAcceptChannel this_ptr_conv;
28683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28684         this_ptr_conv.is_owned = false;
28685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28686         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28687         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
28688         return ret_arr;
28689 }
28690
28691 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) {
28692         LDKAcceptChannel this_ptr_conv;
28693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28694         this_ptr_conv.is_owned = false;
28695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28696         LDKPublicKey val_ref;
28697         CHECK((*env)->GetArrayLength(env, val) == 33);
28698         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28699         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
28700 }
28701
28702 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
28703         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
28704 uintptr_t ret_ref = 0;
28705 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28706 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28707 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28708 ret_ref = (uintptr_t)ret_var.inner;
28709 if (ret_var.is_owned) {
28710         ret_ref |= 1;
28711 }
28712         return ret_ref;
28713 }
28714 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28715         LDKAcceptChannel arg_conv;
28716         arg_conv.inner = (void*)(arg & (~1));
28717         arg_conv.is_owned = false;
28718         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28719         intptr_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
28720         return ret_val;
28721 }
28722
28723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28724         LDKAcceptChannel orig_conv;
28725         orig_conv.inner = (void*)(orig & (~1));
28726         orig_conv.is_owned = false;
28727         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28728         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
28729         uintptr_t ret_ref = 0;
28730         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28731         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28733         ret_ref = (uintptr_t)ret_var.inner;
28734         if (ret_var.is_owned) {
28735                 ret_ref |= 1;
28736         }
28737         return ret_ref;
28738 }
28739
28740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28741         LDKFundingCreated this_obj_conv;
28742         this_obj_conv.inner = (void*)(this_obj & (~1));
28743         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28745         FundingCreated_free(this_obj_conv);
28746 }
28747
28748 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28749         LDKFundingCreated this_ptr_conv;
28750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28751         this_ptr_conv.is_owned = false;
28752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28753         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28754         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
28755         return ret_arr;
28756 }
28757
28758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28759         LDKFundingCreated this_ptr_conv;
28760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28761         this_ptr_conv.is_owned = false;
28762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28763         LDKThirtyTwoBytes val_ref;
28764         CHECK((*env)->GetArrayLength(env, val) == 32);
28765         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28766         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
28767 }
28768
28769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
28770         LDKFundingCreated this_ptr_conv;
28771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28772         this_ptr_conv.is_owned = false;
28773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28774         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28775         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
28776         return ret_arr;
28777 }
28778
28779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28780         LDKFundingCreated this_ptr_conv;
28781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28782         this_ptr_conv.is_owned = false;
28783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28784         LDKThirtyTwoBytes val_ref;
28785         CHECK((*env)->GetArrayLength(env, val) == 32);
28786         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28787         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
28788 }
28789
28790 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
28791         LDKFundingCreated this_ptr_conv;
28792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28793         this_ptr_conv.is_owned = false;
28794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28795         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
28796         return ret_val;
28797 }
28798
28799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28800         LDKFundingCreated this_ptr_conv;
28801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28802         this_ptr_conv.is_owned = false;
28803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28804         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
28805 }
28806
28807 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
28808         LDKFundingCreated this_ptr_conv;
28809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28810         this_ptr_conv.is_owned = false;
28811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28812         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28813         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
28814         return ret_arr;
28815 }
28816
28817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28818         LDKFundingCreated this_ptr_conv;
28819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28820         this_ptr_conv.is_owned = false;
28821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28822         LDKSignature val_ref;
28823         CHECK((*env)->GetArrayLength(env, val) == 64);
28824         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28825         FundingCreated_set_signature(&this_ptr_conv, val_ref);
28826 }
28827
28828 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) {
28829         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
28830         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
28831         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
28832         LDKThirtyTwoBytes funding_txid_arg_ref;
28833         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
28834         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
28835         LDKSignature signature_arg_ref;
28836         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
28837         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
28838         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
28839         uintptr_t ret_ref = 0;
28840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28843         ret_ref = (uintptr_t)ret_var.inner;
28844         if (ret_var.is_owned) {
28845                 ret_ref |= 1;
28846         }
28847         return ret_ref;
28848 }
28849
28850 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
28851         LDKFundingCreated ret_var = FundingCreated_clone(arg);
28852 uintptr_t ret_ref = 0;
28853 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28854 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28855 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28856 ret_ref = (uintptr_t)ret_var.inner;
28857 if (ret_var.is_owned) {
28858         ret_ref |= 1;
28859 }
28860         return ret_ref;
28861 }
28862 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28863         LDKFundingCreated arg_conv;
28864         arg_conv.inner = (void*)(arg & (~1));
28865         arg_conv.is_owned = false;
28866         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28867         intptr_t ret_val = FundingCreated_clone_ptr(&arg_conv);
28868         return ret_val;
28869 }
28870
28871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28872         LDKFundingCreated orig_conv;
28873         orig_conv.inner = (void*)(orig & (~1));
28874         orig_conv.is_owned = false;
28875         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28876         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
28877         uintptr_t ret_ref = 0;
28878         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28879         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28881         ret_ref = (uintptr_t)ret_var.inner;
28882         if (ret_var.is_owned) {
28883                 ret_ref |= 1;
28884         }
28885         return ret_ref;
28886 }
28887
28888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28889         LDKFundingSigned this_obj_conv;
28890         this_obj_conv.inner = (void*)(this_obj & (~1));
28891         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28893         FundingSigned_free(this_obj_conv);
28894 }
28895
28896 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28897         LDKFundingSigned this_ptr_conv;
28898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28899         this_ptr_conv.is_owned = false;
28900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28901         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28902         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
28903         return ret_arr;
28904 }
28905
28906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28907         LDKFundingSigned this_ptr_conv;
28908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28909         this_ptr_conv.is_owned = false;
28910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28911         LDKThirtyTwoBytes val_ref;
28912         CHECK((*env)->GetArrayLength(env, val) == 32);
28913         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28914         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
28915 }
28916
28917 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
28918         LDKFundingSigned this_ptr_conv;
28919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28920         this_ptr_conv.is_owned = false;
28921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28922         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28923         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
28924         return ret_arr;
28925 }
28926
28927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28928         LDKFundingSigned this_ptr_conv;
28929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28930         this_ptr_conv.is_owned = false;
28931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28932         LDKSignature val_ref;
28933         CHECK((*env)->GetArrayLength(env, val) == 64);
28934         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28935         FundingSigned_set_signature(&this_ptr_conv, val_ref);
28936 }
28937
28938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
28939         LDKThirtyTwoBytes channel_id_arg_ref;
28940         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
28941         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
28942         LDKSignature signature_arg_ref;
28943         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
28944         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
28945         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
28946         uintptr_t ret_ref = 0;
28947         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28948         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28950         ret_ref = (uintptr_t)ret_var.inner;
28951         if (ret_var.is_owned) {
28952                 ret_ref |= 1;
28953         }
28954         return ret_ref;
28955 }
28956
28957 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
28958         LDKFundingSigned ret_var = FundingSigned_clone(arg);
28959 uintptr_t ret_ref = 0;
28960 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28961 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28962 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28963 ret_ref = (uintptr_t)ret_var.inner;
28964 if (ret_var.is_owned) {
28965         ret_ref |= 1;
28966 }
28967         return ret_ref;
28968 }
28969 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28970         LDKFundingSigned arg_conv;
28971         arg_conv.inner = (void*)(arg & (~1));
28972         arg_conv.is_owned = false;
28973         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28974         intptr_t ret_val = FundingSigned_clone_ptr(&arg_conv);
28975         return ret_val;
28976 }
28977
28978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28979         LDKFundingSigned orig_conv;
28980         orig_conv.inner = (void*)(orig & (~1));
28981         orig_conv.is_owned = false;
28982         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28983         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
28984         uintptr_t ret_ref = 0;
28985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28988         ret_ref = (uintptr_t)ret_var.inner;
28989         if (ret_var.is_owned) {
28990                 ret_ref |= 1;
28991         }
28992         return ret_ref;
28993 }
28994
28995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28996         LDKFundingLocked this_obj_conv;
28997         this_obj_conv.inner = (void*)(this_obj & (~1));
28998         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29000         FundingLocked_free(this_obj_conv);
29001 }
29002
29003 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29004         LDKFundingLocked this_ptr_conv;
29005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29006         this_ptr_conv.is_owned = false;
29007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29008         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29009         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
29010         return ret_arr;
29011 }
29012
29013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29014         LDKFundingLocked this_ptr_conv;
29015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29016         this_ptr_conv.is_owned = false;
29017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29018         LDKThirtyTwoBytes val_ref;
29019         CHECK((*env)->GetArrayLength(env, val) == 32);
29020         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29021         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
29022 }
29023
29024 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
29025         LDKFundingLocked this_ptr_conv;
29026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29027         this_ptr_conv.is_owned = false;
29028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29029         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29030         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
29031         return ret_arr;
29032 }
29033
29034 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) {
29035         LDKFundingLocked this_ptr_conv;
29036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29037         this_ptr_conv.is_owned = false;
29038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29039         LDKPublicKey val_ref;
29040         CHECK((*env)->GetArrayLength(env, val) == 33);
29041         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29042         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
29043 }
29044
29045 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) {
29046         LDKThirtyTwoBytes channel_id_arg_ref;
29047         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
29048         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
29049         LDKPublicKey next_per_commitment_point_arg_ref;
29050         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
29051         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
29052         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
29053         uintptr_t ret_ref = 0;
29054         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29055         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29057         ret_ref = (uintptr_t)ret_var.inner;
29058         if (ret_var.is_owned) {
29059                 ret_ref |= 1;
29060         }
29061         return ret_ref;
29062 }
29063
29064 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
29065         LDKFundingLocked ret_var = FundingLocked_clone(arg);
29066 uintptr_t ret_ref = 0;
29067 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29068 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29069 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29070 ret_ref = (uintptr_t)ret_var.inner;
29071 if (ret_var.is_owned) {
29072         ret_ref |= 1;
29073 }
29074         return ret_ref;
29075 }
29076 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29077         LDKFundingLocked arg_conv;
29078         arg_conv.inner = (void*)(arg & (~1));
29079         arg_conv.is_owned = false;
29080         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29081         intptr_t ret_val = FundingLocked_clone_ptr(&arg_conv);
29082         return ret_val;
29083 }
29084
29085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29086         LDKFundingLocked orig_conv;
29087         orig_conv.inner = (void*)(orig & (~1));
29088         orig_conv.is_owned = false;
29089         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29090         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
29091         uintptr_t ret_ref = 0;
29092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29095         ret_ref = (uintptr_t)ret_var.inner;
29096         if (ret_var.is_owned) {
29097                 ret_ref |= 1;
29098         }
29099         return ret_ref;
29100 }
29101
29102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29103         LDKShutdown this_obj_conv;
29104         this_obj_conv.inner = (void*)(this_obj & (~1));
29105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29107         Shutdown_free(this_obj_conv);
29108 }
29109
29110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29111         LDKShutdown this_ptr_conv;
29112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29113         this_ptr_conv.is_owned = false;
29114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29115         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29116         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
29117         return ret_arr;
29118 }
29119
29120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29121         LDKShutdown this_ptr_conv;
29122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29123         this_ptr_conv.is_owned = false;
29124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29125         LDKThirtyTwoBytes val_ref;
29126         CHECK((*env)->GetArrayLength(env, val) == 32);
29127         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29128         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
29129 }
29130
29131 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
29132         LDKShutdown this_ptr_conv;
29133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29134         this_ptr_conv.is_owned = false;
29135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29136         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
29137         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29138         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29139         return ret_arr;
29140 }
29141
29142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29143         LDKShutdown this_ptr_conv;
29144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29145         this_ptr_conv.is_owned = false;
29146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29147         LDKCVec_u8Z val_ref;
29148         val_ref.datalen = (*env)->GetArrayLength(env, val);
29149         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
29150         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
29151         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
29152 }
29153
29154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
29155         LDKThirtyTwoBytes channel_id_arg_ref;
29156         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
29157         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
29158         LDKCVec_u8Z scriptpubkey_arg_ref;
29159         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
29160         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
29161         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
29162         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
29163         uintptr_t ret_ref = 0;
29164         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29165         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29167         ret_ref = (uintptr_t)ret_var.inner;
29168         if (ret_var.is_owned) {
29169                 ret_ref |= 1;
29170         }
29171         return ret_ref;
29172 }
29173
29174 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
29175         LDKShutdown ret_var = Shutdown_clone(arg);
29176 uintptr_t ret_ref = 0;
29177 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29178 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29179 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29180 ret_ref = (uintptr_t)ret_var.inner;
29181 if (ret_var.is_owned) {
29182         ret_ref |= 1;
29183 }
29184         return ret_ref;
29185 }
29186 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29187         LDKShutdown arg_conv;
29188         arg_conv.inner = (void*)(arg & (~1));
29189         arg_conv.is_owned = false;
29190         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29191         intptr_t ret_val = Shutdown_clone_ptr(&arg_conv);
29192         return ret_val;
29193 }
29194
29195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29196         LDKShutdown orig_conv;
29197         orig_conv.inner = (void*)(orig & (~1));
29198         orig_conv.is_owned = false;
29199         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29200         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
29201         uintptr_t ret_ref = 0;
29202         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29203         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29205         ret_ref = (uintptr_t)ret_var.inner;
29206         if (ret_var.is_owned) {
29207                 ret_ref |= 1;
29208         }
29209         return ret_ref;
29210 }
29211
29212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29213         LDKClosingSignedFeeRange this_obj_conv;
29214         this_obj_conv.inner = (void*)(this_obj & (~1));
29215         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29217         ClosingSignedFeeRange_free(this_obj_conv);
29218 }
29219
29220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29221         LDKClosingSignedFeeRange this_ptr_conv;
29222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29223         this_ptr_conv.is_owned = false;
29224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29225         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
29226         return ret_val;
29227 }
29228
29229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29230         LDKClosingSignedFeeRange this_ptr_conv;
29231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29232         this_ptr_conv.is_owned = false;
29233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29234         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
29235 }
29236
29237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29238         LDKClosingSignedFeeRange this_ptr_conv;
29239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29240         this_ptr_conv.is_owned = false;
29241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29242         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
29243         return ret_val;
29244 }
29245
29246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29247         LDKClosingSignedFeeRange this_ptr_conv;
29248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29249         this_ptr_conv.is_owned = false;
29250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29251         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
29252 }
29253
29254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1new(JNIEnv *env, jclass clz, int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
29255         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
29256         uintptr_t ret_ref = 0;
29257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29260         ret_ref = (uintptr_t)ret_var.inner;
29261         if (ret_var.is_owned) {
29262                 ret_ref |= 1;
29263         }
29264         return ret_ref;
29265 }
29266
29267 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
29268         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
29269 uintptr_t ret_ref = 0;
29270 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29271 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29272 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29273 ret_ref = (uintptr_t)ret_var.inner;
29274 if (ret_var.is_owned) {
29275         ret_ref |= 1;
29276 }
29277         return ret_ref;
29278 }
29279 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29280         LDKClosingSignedFeeRange arg_conv;
29281         arg_conv.inner = (void*)(arg & (~1));
29282         arg_conv.is_owned = false;
29283         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29284         intptr_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
29285         return ret_val;
29286 }
29287
29288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29289         LDKClosingSignedFeeRange orig_conv;
29290         orig_conv.inner = (void*)(orig & (~1));
29291         orig_conv.is_owned = false;
29292         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29293         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
29294         uintptr_t ret_ref = 0;
29295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29298         ret_ref = (uintptr_t)ret_var.inner;
29299         if (ret_var.is_owned) {
29300                 ret_ref |= 1;
29301         }
29302         return ret_ref;
29303 }
29304
29305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29306         LDKClosingSigned this_obj_conv;
29307         this_obj_conv.inner = (void*)(this_obj & (~1));
29308         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29310         ClosingSigned_free(this_obj_conv);
29311 }
29312
29313 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29314         LDKClosingSigned this_ptr_conv;
29315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29316         this_ptr_conv.is_owned = false;
29317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29318         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29319         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
29320         return ret_arr;
29321 }
29322
29323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29324         LDKClosingSigned this_ptr_conv;
29325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29326         this_ptr_conv.is_owned = false;
29327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29328         LDKThirtyTwoBytes val_ref;
29329         CHECK((*env)->GetArrayLength(env, val) == 32);
29330         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29331         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
29332 }
29333
29334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29335         LDKClosingSigned this_ptr_conv;
29336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29337         this_ptr_conv.is_owned = false;
29338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29339         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
29340         return ret_val;
29341 }
29342
29343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29344         LDKClosingSigned this_ptr_conv;
29345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29346         this_ptr_conv.is_owned = false;
29347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29348         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
29349 }
29350
29351 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
29352         LDKClosingSigned this_ptr_conv;
29353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29354         this_ptr_conv.is_owned = false;
29355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29356         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
29357         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
29358         return ret_arr;
29359 }
29360
29361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29362         LDKClosingSigned this_ptr_conv;
29363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29364         this_ptr_conv.is_owned = false;
29365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29366         LDKSignature val_ref;
29367         CHECK((*env)->GetArrayLength(env, val) == 64);
29368         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
29369         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
29370 }
29371
29372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
29373         LDKClosingSigned this_ptr_conv;
29374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29375         this_ptr_conv.is_owned = false;
29376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29377         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
29378         uintptr_t ret_ref = 0;
29379         if ((uintptr_t)ret_var.inner > 4096) {
29380                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29381                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29383                 ret_ref = (uintptr_t)ret_var.inner;
29384                 if (ret_var.is_owned) {
29385                         ret_ref |= 1;
29386                 }
29387         }
29388         return ret_ref;
29389 }
29390
29391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29392         LDKClosingSigned this_ptr_conv;
29393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29394         this_ptr_conv.is_owned = false;
29395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29396         LDKClosingSignedFeeRange val_conv;
29397         val_conv.inner = (void*)(val & (~1));
29398         val_conv.is_owned = (val & 1) || (val == 0);
29399         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29400         val_conv = ClosingSignedFeeRange_clone(&val_conv);
29401         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
29402 }
29403
29404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg, int64_t fee_range_arg) {
29405         LDKThirtyTwoBytes channel_id_arg_ref;
29406         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
29407         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
29408         LDKSignature signature_arg_ref;
29409         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
29410         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
29411         LDKClosingSignedFeeRange fee_range_arg_conv;
29412         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
29413         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
29414         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
29415         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
29416         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
29417         uintptr_t ret_ref = 0;
29418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29421         ret_ref = (uintptr_t)ret_var.inner;
29422         if (ret_var.is_owned) {
29423                 ret_ref |= 1;
29424         }
29425         return ret_ref;
29426 }
29427
29428 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
29429         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
29430 uintptr_t ret_ref = 0;
29431 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29432 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29433 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29434 ret_ref = (uintptr_t)ret_var.inner;
29435 if (ret_var.is_owned) {
29436         ret_ref |= 1;
29437 }
29438         return ret_ref;
29439 }
29440 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29441         LDKClosingSigned arg_conv;
29442         arg_conv.inner = (void*)(arg & (~1));
29443         arg_conv.is_owned = false;
29444         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29445         intptr_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
29446         return ret_val;
29447 }
29448
29449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29450         LDKClosingSigned orig_conv;
29451         orig_conv.inner = (void*)(orig & (~1));
29452         orig_conv.is_owned = false;
29453         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29454         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
29455         uintptr_t ret_ref = 0;
29456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29459         ret_ref = (uintptr_t)ret_var.inner;
29460         if (ret_var.is_owned) {
29461                 ret_ref |= 1;
29462         }
29463         return ret_ref;
29464 }
29465
29466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29467         LDKUpdateAddHTLC this_obj_conv;
29468         this_obj_conv.inner = (void*)(this_obj & (~1));
29469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29471         UpdateAddHTLC_free(this_obj_conv);
29472 }
29473
29474 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29475         LDKUpdateAddHTLC this_ptr_conv;
29476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29477         this_ptr_conv.is_owned = false;
29478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29479         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29480         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
29481         return ret_arr;
29482 }
29483
29484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29485         LDKUpdateAddHTLC this_ptr_conv;
29486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29487         this_ptr_conv.is_owned = false;
29488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29489         LDKThirtyTwoBytes val_ref;
29490         CHECK((*env)->GetArrayLength(env, val) == 32);
29491         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29492         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
29493 }
29494
29495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29496         LDKUpdateAddHTLC this_ptr_conv;
29497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29498         this_ptr_conv.is_owned = false;
29499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29500         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
29501         return ret_val;
29502 }
29503
29504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29505         LDKUpdateAddHTLC this_ptr_conv;
29506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29507         this_ptr_conv.is_owned = false;
29508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29509         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
29510 }
29511
29512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29513         LDKUpdateAddHTLC this_ptr_conv;
29514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29515         this_ptr_conv.is_owned = false;
29516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29517         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
29518         return ret_val;
29519 }
29520
29521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29522         LDKUpdateAddHTLC this_ptr_conv;
29523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29524         this_ptr_conv.is_owned = false;
29525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29526         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
29527 }
29528
29529 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29530         LDKUpdateAddHTLC this_ptr_conv;
29531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29532         this_ptr_conv.is_owned = false;
29533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29534         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29535         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
29536         return ret_arr;
29537 }
29538
29539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29540         LDKUpdateAddHTLC this_ptr_conv;
29541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29542         this_ptr_conv.is_owned = false;
29543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29544         LDKThirtyTwoBytes val_ref;
29545         CHECK((*env)->GetArrayLength(env, val) == 32);
29546         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29547         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
29548 }
29549
29550 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
29551         LDKUpdateAddHTLC this_ptr_conv;
29552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29553         this_ptr_conv.is_owned = false;
29554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29555         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
29556         return ret_val;
29557 }
29558
29559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29560         LDKUpdateAddHTLC this_ptr_conv;
29561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29562         this_ptr_conv.is_owned = false;
29563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29564         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
29565 }
29566
29567 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
29568         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
29569 uintptr_t ret_ref = 0;
29570 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29571 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29572 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29573 ret_ref = (uintptr_t)ret_var.inner;
29574 if (ret_var.is_owned) {
29575         ret_ref |= 1;
29576 }
29577         return ret_ref;
29578 }
29579 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29580         LDKUpdateAddHTLC arg_conv;
29581         arg_conv.inner = (void*)(arg & (~1));
29582         arg_conv.is_owned = false;
29583         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29584         intptr_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
29585         return ret_val;
29586 }
29587
29588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29589         LDKUpdateAddHTLC orig_conv;
29590         orig_conv.inner = (void*)(orig & (~1));
29591         orig_conv.is_owned = false;
29592         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29593         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
29594         uintptr_t ret_ref = 0;
29595         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29596         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29598         ret_ref = (uintptr_t)ret_var.inner;
29599         if (ret_var.is_owned) {
29600                 ret_ref |= 1;
29601         }
29602         return ret_ref;
29603 }
29604
29605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29606         LDKUpdateFulfillHTLC this_obj_conv;
29607         this_obj_conv.inner = (void*)(this_obj & (~1));
29608         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29610         UpdateFulfillHTLC_free(this_obj_conv);
29611 }
29612
29613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29614         LDKUpdateFulfillHTLC this_ptr_conv;
29615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29616         this_ptr_conv.is_owned = false;
29617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29618         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29619         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
29620         return ret_arr;
29621 }
29622
29623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29624         LDKUpdateFulfillHTLC this_ptr_conv;
29625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29626         this_ptr_conv.is_owned = false;
29627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29628         LDKThirtyTwoBytes val_ref;
29629         CHECK((*env)->GetArrayLength(env, val) == 32);
29630         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29631         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
29632 }
29633
29634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29635         LDKUpdateFulfillHTLC this_ptr_conv;
29636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29637         this_ptr_conv.is_owned = false;
29638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29639         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
29640         return ret_val;
29641 }
29642
29643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29644         LDKUpdateFulfillHTLC this_ptr_conv;
29645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29646         this_ptr_conv.is_owned = false;
29647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29648         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
29649 }
29650
29651 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
29652         LDKUpdateFulfillHTLC this_ptr_conv;
29653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29654         this_ptr_conv.is_owned = false;
29655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29656         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29657         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
29658         return ret_arr;
29659 }
29660
29661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29662         LDKUpdateFulfillHTLC this_ptr_conv;
29663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29664         this_ptr_conv.is_owned = false;
29665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29666         LDKThirtyTwoBytes val_ref;
29667         CHECK((*env)->GetArrayLength(env, val) == 32);
29668         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29669         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
29670 }
29671
29672 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) {
29673         LDKThirtyTwoBytes channel_id_arg_ref;
29674         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
29675         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
29676         LDKThirtyTwoBytes payment_preimage_arg_ref;
29677         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
29678         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
29679         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
29680         uintptr_t ret_ref = 0;
29681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29684         ret_ref = (uintptr_t)ret_var.inner;
29685         if (ret_var.is_owned) {
29686                 ret_ref |= 1;
29687         }
29688         return ret_ref;
29689 }
29690
29691 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
29692         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
29693 uintptr_t ret_ref = 0;
29694 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29695 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29696 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29697 ret_ref = (uintptr_t)ret_var.inner;
29698 if (ret_var.is_owned) {
29699         ret_ref |= 1;
29700 }
29701         return ret_ref;
29702 }
29703 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29704         LDKUpdateFulfillHTLC arg_conv;
29705         arg_conv.inner = (void*)(arg & (~1));
29706         arg_conv.is_owned = false;
29707         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29708         intptr_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
29709         return ret_val;
29710 }
29711
29712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29713         LDKUpdateFulfillHTLC orig_conv;
29714         orig_conv.inner = (void*)(orig & (~1));
29715         orig_conv.is_owned = false;
29716         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29717         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
29718         uintptr_t ret_ref = 0;
29719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29722         ret_ref = (uintptr_t)ret_var.inner;
29723         if (ret_var.is_owned) {
29724                 ret_ref |= 1;
29725         }
29726         return ret_ref;
29727 }
29728
29729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29730         LDKUpdateFailHTLC this_obj_conv;
29731         this_obj_conv.inner = (void*)(this_obj & (~1));
29732         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29734         UpdateFailHTLC_free(this_obj_conv);
29735 }
29736
29737 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29738         LDKUpdateFailHTLC this_ptr_conv;
29739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29740         this_ptr_conv.is_owned = false;
29741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29742         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29743         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
29744         return ret_arr;
29745 }
29746
29747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29748         LDKUpdateFailHTLC this_ptr_conv;
29749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29750         this_ptr_conv.is_owned = false;
29751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29752         LDKThirtyTwoBytes val_ref;
29753         CHECK((*env)->GetArrayLength(env, val) == 32);
29754         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29755         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
29756 }
29757
29758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29759         LDKUpdateFailHTLC this_ptr_conv;
29760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29761         this_ptr_conv.is_owned = false;
29762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29763         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
29764         return ret_val;
29765 }
29766
29767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29768         LDKUpdateFailHTLC this_ptr_conv;
29769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29770         this_ptr_conv.is_owned = false;
29771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29772         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
29773 }
29774
29775 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
29776         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
29777 uintptr_t ret_ref = 0;
29778 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29779 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29780 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29781 ret_ref = (uintptr_t)ret_var.inner;
29782 if (ret_var.is_owned) {
29783         ret_ref |= 1;
29784 }
29785         return ret_ref;
29786 }
29787 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29788         LDKUpdateFailHTLC arg_conv;
29789         arg_conv.inner = (void*)(arg & (~1));
29790         arg_conv.is_owned = false;
29791         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29792         intptr_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
29793         return ret_val;
29794 }
29795
29796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29797         LDKUpdateFailHTLC orig_conv;
29798         orig_conv.inner = (void*)(orig & (~1));
29799         orig_conv.is_owned = false;
29800         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29801         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
29802         uintptr_t ret_ref = 0;
29803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29806         ret_ref = (uintptr_t)ret_var.inner;
29807         if (ret_var.is_owned) {
29808                 ret_ref |= 1;
29809         }
29810         return ret_ref;
29811 }
29812
29813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29814         LDKUpdateFailMalformedHTLC this_obj_conv;
29815         this_obj_conv.inner = (void*)(this_obj & (~1));
29816         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29818         UpdateFailMalformedHTLC_free(this_obj_conv);
29819 }
29820
29821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29822         LDKUpdateFailMalformedHTLC this_ptr_conv;
29823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29824         this_ptr_conv.is_owned = false;
29825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29826         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29827         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
29828         return ret_arr;
29829 }
29830
29831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29832         LDKUpdateFailMalformedHTLC this_ptr_conv;
29833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29834         this_ptr_conv.is_owned = false;
29835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29836         LDKThirtyTwoBytes val_ref;
29837         CHECK((*env)->GetArrayLength(env, val) == 32);
29838         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29839         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
29840 }
29841
29842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29843         LDKUpdateFailMalformedHTLC this_ptr_conv;
29844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29845         this_ptr_conv.is_owned = false;
29846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29847         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
29848         return ret_val;
29849 }
29850
29851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29852         LDKUpdateFailMalformedHTLC this_ptr_conv;
29853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29854         this_ptr_conv.is_owned = false;
29855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29856         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
29857 }
29858
29859 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
29860         LDKUpdateFailMalformedHTLC this_ptr_conv;
29861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29862         this_ptr_conv.is_owned = false;
29863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29864         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
29865         return ret_val;
29866 }
29867
29868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29869         LDKUpdateFailMalformedHTLC this_ptr_conv;
29870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29871         this_ptr_conv.is_owned = false;
29872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29873         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
29874 }
29875
29876 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
29877         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
29878 uintptr_t ret_ref = 0;
29879 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29880 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29881 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29882 ret_ref = (uintptr_t)ret_var.inner;
29883 if (ret_var.is_owned) {
29884         ret_ref |= 1;
29885 }
29886         return ret_ref;
29887 }
29888 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29889         LDKUpdateFailMalformedHTLC arg_conv;
29890         arg_conv.inner = (void*)(arg & (~1));
29891         arg_conv.is_owned = false;
29892         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29893         intptr_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
29894         return ret_val;
29895 }
29896
29897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29898         LDKUpdateFailMalformedHTLC orig_conv;
29899         orig_conv.inner = (void*)(orig & (~1));
29900         orig_conv.is_owned = false;
29901         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29902         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
29903         uintptr_t ret_ref = 0;
29904         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29905         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29907         ret_ref = (uintptr_t)ret_var.inner;
29908         if (ret_var.is_owned) {
29909                 ret_ref |= 1;
29910         }
29911         return ret_ref;
29912 }
29913
29914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29915         LDKCommitmentSigned this_obj_conv;
29916         this_obj_conv.inner = (void*)(this_obj & (~1));
29917         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29919         CommitmentSigned_free(this_obj_conv);
29920 }
29921
29922 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29923         LDKCommitmentSigned this_ptr_conv;
29924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29925         this_ptr_conv.is_owned = false;
29926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29927         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29928         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
29929         return ret_arr;
29930 }
29931
29932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29933         LDKCommitmentSigned this_ptr_conv;
29934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29935         this_ptr_conv.is_owned = false;
29936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29937         LDKThirtyTwoBytes val_ref;
29938         CHECK((*env)->GetArrayLength(env, val) == 32);
29939         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29940         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
29941 }
29942
29943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
29944         LDKCommitmentSigned this_ptr_conv;
29945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29946         this_ptr_conv.is_owned = false;
29947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29948         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
29949         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
29950         return ret_arr;
29951 }
29952
29953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29954         LDKCommitmentSigned this_ptr_conv;
29955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29956         this_ptr_conv.is_owned = false;
29957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29958         LDKSignature val_ref;
29959         CHECK((*env)->GetArrayLength(env, val) == 64);
29960         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
29961         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
29962 }
29963
29964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
29965         LDKCommitmentSigned this_ptr_conv;
29966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29967         this_ptr_conv.is_owned = false;
29968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29969         LDKCVec_SignatureZ val_constr;
29970         val_constr.datalen = (*env)->GetArrayLength(env, val);
29971         if (val_constr.datalen > 0)
29972                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
29973         else
29974                 val_constr.data = NULL;
29975         for (size_t i = 0; i < val_constr.datalen; i++) {
29976                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
29977                 LDKSignature val_conv_8_ref;
29978                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
29979                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
29980                 val_constr.data[i] = val_conv_8_ref;
29981         }
29982         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
29983 }
29984
29985 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) {
29986         LDKThirtyTwoBytes channel_id_arg_ref;
29987         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
29988         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
29989         LDKSignature signature_arg_ref;
29990         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
29991         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
29992         LDKCVec_SignatureZ htlc_signatures_arg_constr;
29993         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
29994         if (htlc_signatures_arg_constr.datalen > 0)
29995                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
29996         else
29997                 htlc_signatures_arg_constr.data = NULL;
29998         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
29999                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
30000                 LDKSignature htlc_signatures_arg_conv_8_ref;
30001                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
30002                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
30003                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
30004         }
30005         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
30006         uintptr_t ret_ref = 0;
30007         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30008         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30010         ret_ref = (uintptr_t)ret_var.inner;
30011         if (ret_var.is_owned) {
30012                 ret_ref |= 1;
30013         }
30014         return ret_ref;
30015 }
30016
30017 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
30018         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
30019 uintptr_t ret_ref = 0;
30020 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30021 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30022 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30023 ret_ref = (uintptr_t)ret_var.inner;
30024 if (ret_var.is_owned) {
30025         ret_ref |= 1;
30026 }
30027         return ret_ref;
30028 }
30029 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30030         LDKCommitmentSigned arg_conv;
30031         arg_conv.inner = (void*)(arg & (~1));
30032         arg_conv.is_owned = false;
30033         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30034         intptr_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
30035         return ret_val;
30036 }
30037
30038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30039         LDKCommitmentSigned orig_conv;
30040         orig_conv.inner = (void*)(orig & (~1));
30041         orig_conv.is_owned = false;
30042         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30043         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
30044         uintptr_t ret_ref = 0;
30045         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30046         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30048         ret_ref = (uintptr_t)ret_var.inner;
30049         if (ret_var.is_owned) {
30050                 ret_ref |= 1;
30051         }
30052         return ret_ref;
30053 }
30054
30055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30056         LDKRevokeAndACK this_obj_conv;
30057         this_obj_conv.inner = (void*)(this_obj & (~1));
30058         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30060         RevokeAndACK_free(this_obj_conv);
30061 }
30062
30063 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30064         LDKRevokeAndACK this_ptr_conv;
30065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30066         this_ptr_conv.is_owned = false;
30067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30068         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30069         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
30070         return ret_arr;
30071 }
30072
30073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30074         LDKRevokeAndACK this_ptr_conv;
30075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30076         this_ptr_conv.is_owned = false;
30077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30078         LDKThirtyTwoBytes val_ref;
30079         CHECK((*env)->GetArrayLength(env, val) == 32);
30080         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30081         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
30082 }
30083
30084 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
30085         LDKRevokeAndACK this_ptr_conv;
30086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30087         this_ptr_conv.is_owned = false;
30088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30089         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30090         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
30091         return ret_arr;
30092 }
30093
30094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30095         LDKRevokeAndACK this_ptr_conv;
30096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30097         this_ptr_conv.is_owned = false;
30098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30099         LDKThirtyTwoBytes val_ref;
30100         CHECK((*env)->GetArrayLength(env, val) == 32);
30101         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30102         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
30103 }
30104
30105 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30106         LDKRevokeAndACK this_ptr_conv;
30107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30108         this_ptr_conv.is_owned = false;
30109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30110         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30111         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
30112         return ret_arr;
30113 }
30114
30115 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) {
30116         LDKRevokeAndACK this_ptr_conv;
30117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30118         this_ptr_conv.is_owned = false;
30119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30120         LDKPublicKey val_ref;
30121         CHECK((*env)->GetArrayLength(env, val) == 33);
30122         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30123         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
30124 }
30125
30126 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) {
30127         LDKThirtyTwoBytes channel_id_arg_ref;
30128         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30129         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30130         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
30131         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
30132         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
30133         LDKPublicKey next_per_commitment_point_arg_ref;
30134         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
30135         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
30136         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
30137         uintptr_t ret_ref = 0;
30138         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30139         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30141         ret_ref = (uintptr_t)ret_var.inner;
30142         if (ret_var.is_owned) {
30143                 ret_ref |= 1;
30144         }
30145         return ret_ref;
30146 }
30147
30148 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
30149         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
30150 uintptr_t ret_ref = 0;
30151 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30152 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30153 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30154 ret_ref = (uintptr_t)ret_var.inner;
30155 if (ret_var.is_owned) {
30156         ret_ref |= 1;
30157 }
30158         return ret_ref;
30159 }
30160 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30161         LDKRevokeAndACK arg_conv;
30162         arg_conv.inner = (void*)(arg & (~1));
30163         arg_conv.is_owned = false;
30164         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30165         intptr_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
30166         return ret_val;
30167 }
30168
30169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30170         LDKRevokeAndACK orig_conv;
30171         orig_conv.inner = (void*)(orig & (~1));
30172         orig_conv.is_owned = false;
30173         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30174         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
30175         uintptr_t ret_ref = 0;
30176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30179         ret_ref = (uintptr_t)ret_var.inner;
30180         if (ret_var.is_owned) {
30181                 ret_ref |= 1;
30182         }
30183         return ret_ref;
30184 }
30185
30186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30187         LDKUpdateFee this_obj_conv;
30188         this_obj_conv.inner = (void*)(this_obj & (~1));
30189         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30191         UpdateFee_free(this_obj_conv);
30192 }
30193
30194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30195         LDKUpdateFee this_ptr_conv;
30196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30197         this_ptr_conv.is_owned = false;
30198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30199         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30200         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
30201         return ret_arr;
30202 }
30203
30204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30205         LDKUpdateFee this_ptr_conv;
30206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30207         this_ptr_conv.is_owned = false;
30208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30209         LDKThirtyTwoBytes val_ref;
30210         CHECK((*env)->GetArrayLength(env, val) == 32);
30211         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30212         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
30213 }
30214
30215 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
30216         LDKUpdateFee this_ptr_conv;
30217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30218         this_ptr_conv.is_owned = false;
30219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30220         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
30221         return ret_val;
30222 }
30223
30224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30225         LDKUpdateFee this_ptr_conv;
30226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30227         this_ptr_conv.is_owned = false;
30228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30229         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
30230 }
30231
30232 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) {
30233         LDKThirtyTwoBytes channel_id_arg_ref;
30234         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30235         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30236         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
30237         uintptr_t ret_ref = 0;
30238         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30239         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30241         ret_ref = (uintptr_t)ret_var.inner;
30242         if (ret_var.is_owned) {
30243                 ret_ref |= 1;
30244         }
30245         return ret_ref;
30246 }
30247
30248 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
30249         LDKUpdateFee ret_var = UpdateFee_clone(arg);
30250 uintptr_t ret_ref = 0;
30251 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30252 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30253 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30254 ret_ref = (uintptr_t)ret_var.inner;
30255 if (ret_var.is_owned) {
30256         ret_ref |= 1;
30257 }
30258         return ret_ref;
30259 }
30260 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30261         LDKUpdateFee arg_conv;
30262         arg_conv.inner = (void*)(arg & (~1));
30263         arg_conv.is_owned = false;
30264         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30265         intptr_t ret_val = UpdateFee_clone_ptr(&arg_conv);
30266         return ret_val;
30267 }
30268
30269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30270         LDKUpdateFee orig_conv;
30271         orig_conv.inner = (void*)(orig & (~1));
30272         orig_conv.is_owned = false;
30273         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30274         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
30275         uintptr_t ret_ref = 0;
30276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30279         ret_ref = (uintptr_t)ret_var.inner;
30280         if (ret_var.is_owned) {
30281                 ret_ref |= 1;
30282         }
30283         return ret_ref;
30284 }
30285
30286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30287         LDKDataLossProtect this_obj_conv;
30288         this_obj_conv.inner = (void*)(this_obj & (~1));
30289         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30291         DataLossProtect_free(this_obj_conv);
30292 }
30293
30294 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
30295         LDKDataLossProtect this_ptr_conv;
30296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30297         this_ptr_conv.is_owned = false;
30298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30299         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30300         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
30301         return ret_arr;
30302 }
30303
30304 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) {
30305         LDKDataLossProtect this_ptr_conv;
30306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30307         this_ptr_conv.is_owned = false;
30308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30309         LDKThirtyTwoBytes val_ref;
30310         CHECK((*env)->GetArrayLength(env, val) == 32);
30311         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30312         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
30313 }
30314
30315 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30316         LDKDataLossProtect this_ptr_conv;
30317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30318         this_ptr_conv.is_owned = false;
30319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30320         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30321         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
30322         return ret_arr;
30323 }
30324
30325 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) {
30326         LDKDataLossProtect this_ptr_conv;
30327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30328         this_ptr_conv.is_owned = false;
30329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30330         LDKPublicKey val_ref;
30331         CHECK((*env)->GetArrayLength(env, val) == 33);
30332         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30333         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
30334 }
30335
30336 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) {
30337         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
30338         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
30339         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
30340         LDKPublicKey my_current_per_commitment_point_arg_ref;
30341         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
30342         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
30343         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
30344         uintptr_t ret_ref = 0;
30345         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30346         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30348         ret_ref = (uintptr_t)ret_var.inner;
30349         if (ret_var.is_owned) {
30350                 ret_ref |= 1;
30351         }
30352         return ret_ref;
30353 }
30354
30355 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
30356         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
30357 uintptr_t ret_ref = 0;
30358 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30359 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30360 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30361 ret_ref = (uintptr_t)ret_var.inner;
30362 if (ret_var.is_owned) {
30363         ret_ref |= 1;
30364 }
30365         return ret_ref;
30366 }
30367 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30368         LDKDataLossProtect arg_conv;
30369         arg_conv.inner = (void*)(arg & (~1));
30370         arg_conv.is_owned = false;
30371         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30372         intptr_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
30373         return ret_val;
30374 }
30375
30376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30377         LDKDataLossProtect orig_conv;
30378         orig_conv.inner = (void*)(orig & (~1));
30379         orig_conv.is_owned = false;
30380         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30381         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
30382         uintptr_t ret_ref = 0;
30383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30386         ret_ref = (uintptr_t)ret_var.inner;
30387         if (ret_var.is_owned) {
30388                 ret_ref |= 1;
30389         }
30390         return ret_ref;
30391 }
30392
30393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30394         LDKChannelReestablish this_obj_conv;
30395         this_obj_conv.inner = (void*)(this_obj & (~1));
30396         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30398         ChannelReestablish_free(this_obj_conv);
30399 }
30400
30401 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30402         LDKChannelReestablish this_ptr_conv;
30403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30404         this_ptr_conv.is_owned = false;
30405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30406         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30407         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
30408         return ret_arr;
30409 }
30410
30411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30412         LDKChannelReestablish this_ptr_conv;
30413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30414         this_ptr_conv.is_owned = false;
30415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30416         LDKThirtyTwoBytes val_ref;
30417         CHECK((*env)->GetArrayLength(env, val) == 32);
30418         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30419         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
30420 }
30421
30422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
30423         LDKChannelReestablish this_ptr_conv;
30424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30425         this_ptr_conv.is_owned = false;
30426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30427         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
30428         return ret_val;
30429 }
30430
30431 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) {
30432         LDKChannelReestablish this_ptr_conv;
30433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30434         this_ptr_conv.is_owned = false;
30435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30436         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
30437 }
30438
30439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
30440         LDKChannelReestablish this_ptr_conv;
30441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30442         this_ptr_conv.is_owned = false;
30443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30444         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
30445         return ret_val;
30446 }
30447
30448 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) {
30449         LDKChannelReestablish this_ptr_conv;
30450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30451         this_ptr_conv.is_owned = false;
30452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30453         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
30454 }
30455
30456 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
30457         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
30458 uintptr_t ret_ref = 0;
30459 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30460 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30461 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30462 ret_ref = (uintptr_t)ret_var.inner;
30463 if (ret_var.is_owned) {
30464         ret_ref |= 1;
30465 }
30466         return ret_ref;
30467 }
30468 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30469         LDKChannelReestablish arg_conv;
30470         arg_conv.inner = (void*)(arg & (~1));
30471         arg_conv.is_owned = false;
30472         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30473         intptr_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
30474         return ret_val;
30475 }
30476
30477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30478         LDKChannelReestablish orig_conv;
30479         orig_conv.inner = (void*)(orig & (~1));
30480         orig_conv.is_owned = false;
30481         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30482         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
30483         uintptr_t ret_ref = 0;
30484         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30485         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30487         ret_ref = (uintptr_t)ret_var.inner;
30488         if (ret_var.is_owned) {
30489                 ret_ref |= 1;
30490         }
30491         return ret_ref;
30492 }
30493
30494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30495         LDKAnnouncementSignatures this_obj_conv;
30496         this_obj_conv.inner = (void*)(this_obj & (~1));
30497         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30499         AnnouncementSignatures_free(this_obj_conv);
30500 }
30501
30502 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30503         LDKAnnouncementSignatures this_ptr_conv;
30504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30505         this_ptr_conv.is_owned = false;
30506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30507         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30508         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
30509         return ret_arr;
30510 }
30511
30512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30513         LDKAnnouncementSignatures this_ptr_conv;
30514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30515         this_ptr_conv.is_owned = false;
30516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30517         LDKThirtyTwoBytes val_ref;
30518         CHECK((*env)->GetArrayLength(env, val) == 32);
30519         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30520         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
30521 }
30522
30523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30524         LDKAnnouncementSignatures this_ptr_conv;
30525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30526         this_ptr_conv.is_owned = false;
30527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30528         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
30529         return ret_val;
30530 }
30531
30532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30533         LDKAnnouncementSignatures this_ptr_conv;
30534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30535         this_ptr_conv.is_owned = false;
30536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30537         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
30538 }
30539
30540 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
30541         LDKAnnouncementSignatures this_ptr_conv;
30542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30543         this_ptr_conv.is_owned = false;
30544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30545         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
30546         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
30547         return ret_arr;
30548 }
30549
30550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30551         LDKAnnouncementSignatures this_ptr_conv;
30552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30553         this_ptr_conv.is_owned = false;
30554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30555         LDKSignature val_ref;
30556         CHECK((*env)->GetArrayLength(env, val) == 64);
30557         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
30558         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
30559 }
30560
30561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
30562         LDKAnnouncementSignatures this_ptr_conv;
30563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30564         this_ptr_conv.is_owned = false;
30565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30566         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
30567         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
30568         return ret_arr;
30569 }
30570
30571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30572         LDKAnnouncementSignatures this_ptr_conv;
30573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30574         this_ptr_conv.is_owned = false;
30575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30576         LDKSignature val_ref;
30577         CHECK((*env)->GetArrayLength(env, val) == 64);
30578         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
30579         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
30580 }
30581
30582 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) {
30583         LDKThirtyTwoBytes channel_id_arg_ref;
30584         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30585         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30586         LDKSignature node_signature_arg_ref;
30587         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
30588         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
30589         LDKSignature bitcoin_signature_arg_ref;
30590         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
30591         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
30592         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
30593         uintptr_t ret_ref = 0;
30594         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30595         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30597         ret_ref = (uintptr_t)ret_var.inner;
30598         if (ret_var.is_owned) {
30599                 ret_ref |= 1;
30600         }
30601         return ret_ref;
30602 }
30603
30604 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
30605         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
30606 uintptr_t ret_ref = 0;
30607 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30608 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30609 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30610 ret_ref = (uintptr_t)ret_var.inner;
30611 if (ret_var.is_owned) {
30612         ret_ref |= 1;
30613 }
30614         return ret_ref;
30615 }
30616 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30617         LDKAnnouncementSignatures arg_conv;
30618         arg_conv.inner = (void*)(arg & (~1));
30619         arg_conv.is_owned = false;
30620         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30621         intptr_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
30622         return ret_val;
30623 }
30624
30625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30626         LDKAnnouncementSignatures orig_conv;
30627         orig_conv.inner = (void*)(orig & (~1));
30628         orig_conv.is_owned = false;
30629         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30630         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
30631         uintptr_t ret_ref = 0;
30632         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30633         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30635         ret_ref = (uintptr_t)ret_var.inner;
30636         if (ret_var.is_owned) {
30637                 ret_ref |= 1;
30638         }
30639         return ret_ref;
30640 }
30641
30642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30643         if ((this_ptr & 1) != 0) return;
30644         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
30645         CHECK_ACCESS(this_ptr_ptr);
30646         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
30647         FREE((void*)this_ptr);
30648         NetAddress_free(this_ptr_conv);
30649 }
30650
30651 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
30652         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30653         *ret_copy = NetAddress_clone(arg);
30654 uintptr_t ret_ref = (uintptr_t)ret_copy;
30655         return ret_ref;
30656 }
30657 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30658         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
30659         intptr_t ret_val = NetAddress_clone_ptr(arg_conv);
30660         return ret_val;
30661 }
30662
30663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30664         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
30665         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30666         *ret_copy = NetAddress_clone(orig_conv);
30667         uintptr_t ret_ref = (uintptr_t)ret_copy;
30668         return ret_ref;
30669 }
30670
30671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
30672         LDKFourBytes addr_ref;
30673         CHECK((*env)->GetArrayLength(env, addr) == 4);
30674         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
30675         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30676         *ret_copy = NetAddress_ipv4(addr_ref, port);
30677         uintptr_t ret_ref = (uintptr_t)ret_copy;
30678         return ret_ref;
30679 }
30680
30681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
30682         LDKSixteenBytes addr_ref;
30683         CHECK((*env)->GetArrayLength(env, addr) == 16);
30684         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
30685         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30686         *ret_copy = NetAddress_ipv6(addr_ref, port);
30687         uintptr_t ret_ref = (uintptr_t)ret_copy;
30688         return ret_ref;
30689 }
30690
30691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
30692         LDKTwelveBytes a_ref;
30693         CHECK((*env)->GetArrayLength(env, a) == 12);
30694         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
30695         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30696         *ret_copy = NetAddress_onion_v2(a_ref);
30697         uintptr_t ret_ref = (uintptr_t)ret_copy;
30698         return ret_ref;
30699 }
30700
30701 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) {
30702         LDKThirtyTwoBytes ed25519_pubkey_ref;
30703         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
30704         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
30705         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30706         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
30707         uintptr_t ret_ref = (uintptr_t)ret_copy;
30708         return ret_ref;
30709 }
30710
30711 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
30712         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
30713         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
30714         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30715         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30716         CVec_u8Z_free(ret_var);
30717         return ret_arr;
30718 }
30719
30720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30721         LDKu8slice ser_ref;
30722         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30723         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30724         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
30725         *ret_conv = NetAddress_read(ser_ref);
30726         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30727         return (uintptr_t)ret_conv;
30728 }
30729
30730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30731         LDKUnsignedNodeAnnouncement this_obj_conv;
30732         this_obj_conv.inner = (void*)(this_obj & (~1));
30733         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30735         UnsignedNodeAnnouncement_free(this_obj_conv);
30736 }
30737
30738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
30739         LDKUnsignedNodeAnnouncement this_ptr_conv;
30740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30741         this_ptr_conv.is_owned = false;
30742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30743         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
30744         uintptr_t ret_ref = 0;
30745         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30746         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30748         ret_ref = (uintptr_t)ret_var.inner;
30749         if (ret_var.is_owned) {
30750                 ret_ref |= 1;
30751         }
30752         return ret_ref;
30753 }
30754
30755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30756         LDKUnsignedNodeAnnouncement this_ptr_conv;
30757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30758         this_ptr_conv.is_owned = false;
30759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30760         LDKNodeFeatures val_conv;
30761         val_conv.inner = (void*)(val & (~1));
30762         val_conv.is_owned = (val & 1) || (val == 0);
30763         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30764         val_conv = NodeFeatures_clone(&val_conv);
30765         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
30766 }
30767
30768 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
30769         LDKUnsignedNodeAnnouncement this_ptr_conv;
30770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30771         this_ptr_conv.is_owned = false;
30772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30773         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
30774         return ret_val;
30775 }
30776
30777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30778         LDKUnsignedNodeAnnouncement this_ptr_conv;
30779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30780         this_ptr_conv.is_owned = false;
30781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30782         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
30783 }
30784
30785 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30786         LDKUnsignedNodeAnnouncement this_ptr_conv;
30787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30788         this_ptr_conv.is_owned = false;
30789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30790         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30791         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
30792         return ret_arr;
30793 }
30794
30795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30796         LDKUnsignedNodeAnnouncement this_ptr_conv;
30797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30798         this_ptr_conv.is_owned = false;
30799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30800         LDKPublicKey val_ref;
30801         CHECK((*env)->GetArrayLength(env, val) == 33);
30802         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30803         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
30804 }
30805
30806 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
30807         LDKUnsignedNodeAnnouncement this_ptr_conv;
30808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30809         this_ptr_conv.is_owned = false;
30810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30811         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
30812         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
30813         return ret_arr;
30814 }
30815
30816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30817         LDKUnsignedNodeAnnouncement this_ptr_conv;
30818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30819         this_ptr_conv.is_owned = false;
30820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30821         LDKThreeBytes val_ref;
30822         CHECK((*env)->GetArrayLength(env, val) == 3);
30823         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
30824         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
30825 }
30826
30827 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
30828         LDKUnsignedNodeAnnouncement this_ptr_conv;
30829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30830         this_ptr_conv.is_owned = false;
30831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30832         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30833         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
30834         return ret_arr;
30835 }
30836
30837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30838         LDKUnsignedNodeAnnouncement this_ptr_conv;
30839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30840         this_ptr_conv.is_owned = false;
30841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30842         LDKThirtyTwoBytes val_ref;
30843         CHECK((*env)->GetArrayLength(env, val) == 32);
30844         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30845         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
30846 }
30847
30848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30849         LDKUnsignedNodeAnnouncement this_ptr_conv;
30850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30851         this_ptr_conv.is_owned = false;
30852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30853         LDKCVec_NetAddressZ val_constr;
30854         val_constr.datalen = (*env)->GetArrayLength(env, val);
30855         if (val_constr.datalen > 0)
30856                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
30857         else
30858                 val_constr.data = NULL;
30859         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30860         for (size_t m = 0; m < val_constr.datalen; m++) {
30861                 int64_t val_conv_12 = val_vals[m];
30862                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
30863                 CHECK_ACCESS(val_conv_12_ptr);
30864                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
30865                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
30866                 val_constr.data[m] = val_conv_12_conv;
30867         }
30868         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30869         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
30870 }
30871
30872 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
30873         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
30874 uintptr_t ret_ref = 0;
30875 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30876 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30877 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30878 ret_ref = (uintptr_t)ret_var.inner;
30879 if (ret_var.is_owned) {
30880         ret_ref |= 1;
30881 }
30882         return ret_ref;
30883 }
30884 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30885         LDKUnsignedNodeAnnouncement arg_conv;
30886         arg_conv.inner = (void*)(arg & (~1));
30887         arg_conv.is_owned = false;
30888         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30889         intptr_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
30890         return ret_val;
30891 }
30892
30893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30894         LDKUnsignedNodeAnnouncement orig_conv;
30895         orig_conv.inner = (void*)(orig & (~1));
30896         orig_conv.is_owned = false;
30897         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30898         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
30899         uintptr_t ret_ref = 0;
30900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30903         ret_ref = (uintptr_t)ret_var.inner;
30904         if (ret_var.is_owned) {
30905                 ret_ref |= 1;
30906         }
30907         return ret_ref;
30908 }
30909
30910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30911         LDKNodeAnnouncement this_obj_conv;
30912         this_obj_conv.inner = (void*)(this_obj & (~1));
30913         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30915         NodeAnnouncement_free(this_obj_conv);
30916 }
30917
30918 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
30919         LDKNodeAnnouncement this_ptr_conv;
30920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30921         this_ptr_conv.is_owned = false;
30922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30923         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
30924         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
30925         return ret_arr;
30926 }
30927
30928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30929         LDKNodeAnnouncement this_ptr_conv;
30930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30931         this_ptr_conv.is_owned = false;
30932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30933         LDKSignature val_ref;
30934         CHECK((*env)->GetArrayLength(env, val) == 64);
30935         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
30936         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
30937 }
30938
30939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
30940         LDKNodeAnnouncement this_ptr_conv;
30941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30942         this_ptr_conv.is_owned = false;
30943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30944         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
30945         uintptr_t ret_ref = 0;
30946         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30947         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30949         ret_ref = (uintptr_t)ret_var.inner;
30950         if (ret_var.is_owned) {
30951                 ret_ref |= 1;
30952         }
30953         return ret_ref;
30954 }
30955
30956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30957         LDKNodeAnnouncement this_ptr_conv;
30958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30959         this_ptr_conv.is_owned = false;
30960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30961         LDKUnsignedNodeAnnouncement val_conv;
30962         val_conv.inner = (void*)(val & (~1));
30963         val_conv.is_owned = (val & 1) || (val == 0);
30964         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30965         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
30966         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
30967 }
30968
30969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
30970         LDKSignature signature_arg_ref;
30971         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
30972         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
30973         LDKUnsignedNodeAnnouncement contents_arg_conv;
30974         contents_arg_conv.inner = (void*)(contents_arg & (~1));
30975         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
30976         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
30977         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
30978         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
30979         uintptr_t ret_ref = 0;
30980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30983         ret_ref = (uintptr_t)ret_var.inner;
30984         if (ret_var.is_owned) {
30985                 ret_ref |= 1;
30986         }
30987         return ret_ref;
30988 }
30989
30990 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
30991         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
30992 uintptr_t ret_ref = 0;
30993 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30994 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30995 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30996 ret_ref = (uintptr_t)ret_var.inner;
30997 if (ret_var.is_owned) {
30998         ret_ref |= 1;
30999 }
31000         return ret_ref;
31001 }
31002 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31003         LDKNodeAnnouncement arg_conv;
31004         arg_conv.inner = (void*)(arg & (~1));
31005         arg_conv.is_owned = false;
31006         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31007         intptr_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
31008         return ret_val;
31009 }
31010
31011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31012         LDKNodeAnnouncement orig_conv;
31013         orig_conv.inner = (void*)(orig & (~1));
31014         orig_conv.is_owned = false;
31015         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31016         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
31017         uintptr_t ret_ref = 0;
31018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31021         ret_ref = (uintptr_t)ret_var.inner;
31022         if (ret_var.is_owned) {
31023                 ret_ref |= 1;
31024         }
31025         return ret_ref;
31026 }
31027
31028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31029         LDKUnsignedChannelAnnouncement this_obj_conv;
31030         this_obj_conv.inner = (void*)(this_obj & (~1));
31031         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31033         UnsignedChannelAnnouncement_free(this_obj_conv);
31034 }
31035
31036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
31037         LDKUnsignedChannelAnnouncement this_ptr_conv;
31038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31039         this_ptr_conv.is_owned = false;
31040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31041         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
31042         uintptr_t ret_ref = 0;
31043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31046         ret_ref = (uintptr_t)ret_var.inner;
31047         if (ret_var.is_owned) {
31048                 ret_ref |= 1;
31049         }
31050         return ret_ref;
31051 }
31052
31053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31054         LDKUnsignedChannelAnnouncement this_ptr_conv;
31055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31056         this_ptr_conv.is_owned = false;
31057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31058         LDKChannelFeatures val_conv;
31059         val_conv.inner = (void*)(val & (~1));
31060         val_conv.is_owned = (val & 1) || (val == 0);
31061         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31062         val_conv = ChannelFeatures_clone(&val_conv);
31063         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
31064 }
31065
31066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
31067         LDKUnsignedChannelAnnouncement this_ptr_conv;
31068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31069         this_ptr_conv.is_owned = false;
31070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31071         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31072         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
31073         return ret_arr;
31074 }
31075
31076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31077         LDKUnsignedChannelAnnouncement this_ptr_conv;
31078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31079         this_ptr_conv.is_owned = false;
31080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31081         LDKThirtyTwoBytes val_ref;
31082         CHECK((*env)->GetArrayLength(env, val) == 32);
31083         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31084         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
31085 }
31086
31087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31088         LDKUnsignedChannelAnnouncement this_ptr_conv;
31089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31090         this_ptr_conv.is_owned = false;
31091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31092         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
31093         return ret_val;
31094 }
31095
31096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31097         LDKUnsignedChannelAnnouncement this_ptr_conv;
31098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31099         this_ptr_conv.is_owned = false;
31100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31101         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
31102 }
31103
31104 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
31105         LDKUnsignedChannelAnnouncement this_ptr_conv;
31106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31107         this_ptr_conv.is_owned = false;
31108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31109         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31110         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
31111         return ret_arr;
31112 }
31113
31114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31115         LDKUnsignedChannelAnnouncement this_ptr_conv;
31116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31117         this_ptr_conv.is_owned = false;
31118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31119         LDKPublicKey val_ref;
31120         CHECK((*env)->GetArrayLength(env, val) == 33);
31121         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31122         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
31123 }
31124
31125 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
31126         LDKUnsignedChannelAnnouncement this_ptr_conv;
31127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31128         this_ptr_conv.is_owned = false;
31129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31130         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31131         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
31132         return ret_arr;
31133 }
31134
31135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31136         LDKUnsignedChannelAnnouncement this_ptr_conv;
31137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31138         this_ptr_conv.is_owned = false;
31139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31140         LDKPublicKey val_ref;
31141         CHECK((*env)->GetArrayLength(env, val) == 33);
31142         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31143         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
31144 }
31145
31146 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
31147         LDKUnsignedChannelAnnouncement this_ptr_conv;
31148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31149         this_ptr_conv.is_owned = false;
31150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31151         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31152         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
31153         return ret_arr;
31154 }
31155
31156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31157         LDKUnsignedChannelAnnouncement this_ptr_conv;
31158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31159         this_ptr_conv.is_owned = false;
31160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31161         LDKPublicKey val_ref;
31162         CHECK((*env)->GetArrayLength(env, val) == 33);
31163         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31164         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
31165 }
31166
31167 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
31168         LDKUnsignedChannelAnnouncement this_ptr_conv;
31169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31170         this_ptr_conv.is_owned = false;
31171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31172         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31173         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
31174         return ret_arr;
31175 }
31176
31177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31178         LDKUnsignedChannelAnnouncement this_ptr_conv;
31179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31180         this_ptr_conv.is_owned = false;
31181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31182         LDKPublicKey val_ref;
31183         CHECK((*env)->GetArrayLength(env, val) == 33);
31184         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31185         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
31186 }
31187
31188 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
31189         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
31190 uintptr_t ret_ref = 0;
31191 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31192 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31193 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31194 ret_ref = (uintptr_t)ret_var.inner;
31195 if (ret_var.is_owned) {
31196         ret_ref |= 1;
31197 }
31198         return ret_ref;
31199 }
31200 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31201         LDKUnsignedChannelAnnouncement arg_conv;
31202         arg_conv.inner = (void*)(arg & (~1));
31203         arg_conv.is_owned = false;
31204         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31205         intptr_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
31206         return ret_val;
31207 }
31208
31209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31210         LDKUnsignedChannelAnnouncement orig_conv;
31211         orig_conv.inner = (void*)(orig & (~1));
31212         orig_conv.is_owned = false;
31213         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31214         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
31215         uintptr_t ret_ref = 0;
31216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31219         ret_ref = (uintptr_t)ret_var.inner;
31220         if (ret_var.is_owned) {
31221                 ret_ref |= 1;
31222         }
31223         return ret_ref;
31224 }
31225
31226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31227         LDKChannelAnnouncement this_obj_conv;
31228         this_obj_conv.inner = (void*)(this_obj & (~1));
31229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31231         ChannelAnnouncement_free(this_obj_conv);
31232 }
31233
31234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
31235         LDKChannelAnnouncement this_ptr_conv;
31236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31237         this_ptr_conv.is_owned = false;
31238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31239         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31240         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
31241         return ret_arr;
31242 }
31243
31244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31245         LDKChannelAnnouncement this_ptr_conv;
31246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31247         this_ptr_conv.is_owned = false;
31248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31249         LDKSignature val_ref;
31250         CHECK((*env)->GetArrayLength(env, val) == 64);
31251         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31252         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
31253 }
31254
31255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
31256         LDKChannelAnnouncement this_ptr_conv;
31257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31258         this_ptr_conv.is_owned = false;
31259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31260         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31261         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
31262         return ret_arr;
31263 }
31264
31265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31266         LDKChannelAnnouncement this_ptr_conv;
31267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31268         this_ptr_conv.is_owned = false;
31269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31270         LDKSignature val_ref;
31271         CHECK((*env)->GetArrayLength(env, val) == 64);
31272         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31273         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
31274 }
31275
31276 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
31277         LDKChannelAnnouncement this_ptr_conv;
31278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31279         this_ptr_conv.is_owned = false;
31280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31281         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31282         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
31283         return ret_arr;
31284 }
31285
31286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31287         LDKChannelAnnouncement this_ptr_conv;
31288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31289         this_ptr_conv.is_owned = false;
31290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31291         LDKSignature val_ref;
31292         CHECK((*env)->GetArrayLength(env, val) == 64);
31293         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31294         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
31295 }
31296
31297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
31298         LDKChannelAnnouncement this_ptr_conv;
31299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31300         this_ptr_conv.is_owned = false;
31301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31302         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31303         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
31304         return ret_arr;
31305 }
31306
31307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31308         LDKChannelAnnouncement this_ptr_conv;
31309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31310         this_ptr_conv.is_owned = false;
31311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31312         LDKSignature val_ref;
31313         CHECK((*env)->GetArrayLength(env, val) == 64);
31314         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31315         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
31316 }
31317
31318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
31319         LDKChannelAnnouncement this_ptr_conv;
31320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31321         this_ptr_conv.is_owned = false;
31322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31323         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
31324         uintptr_t ret_ref = 0;
31325         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31326         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31328         ret_ref = (uintptr_t)ret_var.inner;
31329         if (ret_var.is_owned) {
31330                 ret_ref |= 1;
31331         }
31332         return ret_ref;
31333 }
31334
31335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31336         LDKChannelAnnouncement this_ptr_conv;
31337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31338         this_ptr_conv.is_owned = false;
31339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31340         LDKUnsignedChannelAnnouncement val_conv;
31341         val_conv.inner = (void*)(val & (~1));
31342         val_conv.is_owned = (val & 1) || (val == 0);
31343         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31344         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
31345         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
31346 }
31347
31348 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) {
31349         LDKSignature node_signature_1_arg_ref;
31350         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
31351         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
31352         LDKSignature node_signature_2_arg_ref;
31353         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
31354         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
31355         LDKSignature bitcoin_signature_1_arg_ref;
31356         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
31357         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
31358         LDKSignature bitcoin_signature_2_arg_ref;
31359         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
31360         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
31361         LDKUnsignedChannelAnnouncement contents_arg_conv;
31362         contents_arg_conv.inner = (void*)(contents_arg & (~1));
31363         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
31364         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
31365         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
31366         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);
31367         uintptr_t ret_ref = 0;
31368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31371         ret_ref = (uintptr_t)ret_var.inner;
31372         if (ret_var.is_owned) {
31373                 ret_ref |= 1;
31374         }
31375         return ret_ref;
31376 }
31377
31378 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
31379         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
31380 uintptr_t ret_ref = 0;
31381 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31382 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31383 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31384 ret_ref = (uintptr_t)ret_var.inner;
31385 if (ret_var.is_owned) {
31386         ret_ref |= 1;
31387 }
31388         return ret_ref;
31389 }
31390 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31391         LDKChannelAnnouncement arg_conv;
31392         arg_conv.inner = (void*)(arg & (~1));
31393         arg_conv.is_owned = false;
31394         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31395         intptr_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
31396         return ret_val;
31397 }
31398
31399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31400         LDKChannelAnnouncement orig_conv;
31401         orig_conv.inner = (void*)(orig & (~1));
31402         orig_conv.is_owned = false;
31403         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31404         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
31405         uintptr_t ret_ref = 0;
31406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31409         ret_ref = (uintptr_t)ret_var.inner;
31410         if (ret_var.is_owned) {
31411                 ret_ref |= 1;
31412         }
31413         return ret_ref;
31414 }
31415
31416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31417         LDKUnsignedChannelUpdate this_obj_conv;
31418         this_obj_conv.inner = (void*)(this_obj & (~1));
31419         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31421         UnsignedChannelUpdate_free(this_obj_conv);
31422 }
31423
31424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
31425         LDKUnsignedChannelUpdate this_ptr_conv;
31426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31427         this_ptr_conv.is_owned = false;
31428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31429         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31430         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
31431         return ret_arr;
31432 }
31433
31434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31435         LDKUnsignedChannelUpdate this_ptr_conv;
31436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31437         this_ptr_conv.is_owned = false;
31438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31439         LDKThirtyTwoBytes val_ref;
31440         CHECK((*env)->GetArrayLength(env, val) == 32);
31441         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31442         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
31443 }
31444
31445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31446         LDKUnsignedChannelUpdate this_ptr_conv;
31447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31448         this_ptr_conv.is_owned = false;
31449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31450         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
31451         return ret_val;
31452 }
31453
31454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31455         LDKUnsignedChannelUpdate this_ptr_conv;
31456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31457         this_ptr_conv.is_owned = false;
31458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31459         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
31460 }
31461
31462 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
31463         LDKUnsignedChannelUpdate this_ptr_conv;
31464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31465         this_ptr_conv.is_owned = false;
31466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31467         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
31468         return ret_val;
31469 }
31470
31471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31472         LDKUnsignedChannelUpdate this_ptr_conv;
31473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31474         this_ptr_conv.is_owned = false;
31475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31476         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
31477 }
31478
31479 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
31480         LDKUnsignedChannelUpdate this_ptr_conv;
31481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31482         this_ptr_conv.is_owned = false;
31483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31484         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
31485         return ret_val;
31486 }
31487
31488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
31489         LDKUnsignedChannelUpdate this_ptr_conv;
31490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31491         this_ptr_conv.is_owned = false;
31492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31493         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
31494 }
31495
31496 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
31497         LDKUnsignedChannelUpdate this_ptr_conv;
31498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31499         this_ptr_conv.is_owned = false;
31500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31501         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
31502         return ret_val;
31503 }
31504
31505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31506         LDKUnsignedChannelUpdate this_ptr_conv;
31507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31508         this_ptr_conv.is_owned = false;
31509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31510         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
31511 }
31512
31513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31514         LDKUnsignedChannelUpdate this_ptr_conv;
31515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31516         this_ptr_conv.is_owned = false;
31517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31518         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
31519         return ret_val;
31520 }
31521
31522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31523         LDKUnsignedChannelUpdate this_ptr_conv;
31524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31525         this_ptr_conv.is_owned = false;
31526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31527         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
31528 }
31529
31530 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31531         LDKUnsignedChannelUpdate this_ptr_conv;
31532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31533         this_ptr_conv.is_owned = false;
31534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31535         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
31536         return ret_val;
31537 }
31538
31539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31540         LDKUnsignedChannelUpdate this_ptr_conv;
31541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31542         this_ptr_conv.is_owned = false;
31543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31544         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
31545 }
31546
31547 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
31548         LDKUnsignedChannelUpdate this_ptr_conv;
31549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31550         this_ptr_conv.is_owned = false;
31551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31552         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
31553         return ret_val;
31554 }
31555
31556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31557         LDKUnsignedChannelUpdate this_ptr_conv;
31558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31559         this_ptr_conv.is_owned = false;
31560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31561         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
31562 }
31563
31564 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
31565         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
31566 uintptr_t ret_ref = 0;
31567 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31568 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31569 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31570 ret_ref = (uintptr_t)ret_var.inner;
31571 if (ret_var.is_owned) {
31572         ret_ref |= 1;
31573 }
31574         return ret_ref;
31575 }
31576 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31577         LDKUnsignedChannelUpdate arg_conv;
31578         arg_conv.inner = (void*)(arg & (~1));
31579         arg_conv.is_owned = false;
31580         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31581         intptr_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
31582         return ret_val;
31583 }
31584
31585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31586         LDKUnsignedChannelUpdate orig_conv;
31587         orig_conv.inner = (void*)(orig & (~1));
31588         orig_conv.is_owned = false;
31589         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31590         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
31591         uintptr_t ret_ref = 0;
31592         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31593         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31595         ret_ref = (uintptr_t)ret_var.inner;
31596         if (ret_var.is_owned) {
31597                 ret_ref |= 1;
31598         }
31599         return ret_ref;
31600 }
31601
31602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31603         LDKChannelUpdate this_obj_conv;
31604         this_obj_conv.inner = (void*)(this_obj & (~1));
31605         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31607         ChannelUpdate_free(this_obj_conv);
31608 }
31609
31610 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31611         LDKChannelUpdate this_ptr_conv;
31612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31613         this_ptr_conv.is_owned = false;
31614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31615         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31616         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
31617         return ret_arr;
31618 }
31619
31620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31621         LDKChannelUpdate this_ptr_conv;
31622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31623         this_ptr_conv.is_owned = false;
31624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31625         LDKSignature val_ref;
31626         CHECK((*env)->GetArrayLength(env, val) == 64);
31627         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31628         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
31629 }
31630
31631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
31632         LDKChannelUpdate this_ptr_conv;
31633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31634         this_ptr_conv.is_owned = false;
31635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31636         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
31637         uintptr_t ret_ref = 0;
31638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31641         ret_ref = (uintptr_t)ret_var.inner;
31642         if (ret_var.is_owned) {
31643                 ret_ref |= 1;
31644         }
31645         return ret_ref;
31646 }
31647
31648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31649         LDKChannelUpdate this_ptr_conv;
31650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31651         this_ptr_conv.is_owned = false;
31652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31653         LDKUnsignedChannelUpdate val_conv;
31654         val_conv.inner = (void*)(val & (~1));
31655         val_conv.is_owned = (val & 1) || (val == 0);
31656         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31657         val_conv = UnsignedChannelUpdate_clone(&val_conv);
31658         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
31659 }
31660
31661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
31662         LDKSignature signature_arg_ref;
31663         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31664         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31665         LDKUnsignedChannelUpdate contents_arg_conv;
31666         contents_arg_conv.inner = (void*)(contents_arg & (~1));
31667         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
31668         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
31669         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
31670         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
31671         uintptr_t ret_ref = 0;
31672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31675         ret_ref = (uintptr_t)ret_var.inner;
31676         if (ret_var.is_owned) {
31677                 ret_ref |= 1;
31678         }
31679         return ret_ref;
31680 }
31681
31682 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
31683         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
31684 uintptr_t ret_ref = 0;
31685 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31686 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31687 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31688 ret_ref = (uintptr_t)ret_var.inner;
31689 if (ret_var.is_owned) {
31690         ret_ref |= 1;
31691 }
31692         return ret_ref;
31693 }
31694 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31695         LDKChannelUpdate arg_conv;
31696         arg_conv.inner = (void*)(arg & (~1));
31697         arg_conv.is_owned = false;
31698         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31699         intptr_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
31700         return ret_val;
31701 }
31702
31703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31704         LDKChannelUpdate orig_conv;
31705         orig_conv.inner = (void*)(orig & (~1));
31706         orig_conv.is_owned = false;
31707         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31708         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
31709         uintptr_t ret_ref = 0;
31710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31713         ret_ref = (uintptr_t)ret_var.inner;
31714         if (ret_var.is_owned) {
31715                 ret_ref |= 1;
31716         }
31717         return ret_ref;
31718 }
31719
31720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31721         LDKQueryChannelRange this_obj_conv;
31722         this_obj_conv.inner = (void*)(this_obj & (~1));
31723         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31725         QueryChannelRange_free(this_obj_conv);
31726 }
31727
31728 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
31729         LDKQueryChannelRange this_ptr_conv;
31730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31731         this_ptr_conv.is_owned = false;
31732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31733         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31734         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
31735         return ret_arr;
31736 }
31737
31738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31739         LDKQueryChannelRange this_ptr_conv;
31740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31741         this_ptr_conv.is_owned = false;
31742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31743         LDKThirtyTwoBytes val_ref;
31744         CHECK((*env)->GetArrayLength(env, val) == 32);
31745         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31746         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
31747 }
31748
31749 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
31750         LDKQueryChannelRange this_ptr_conv;
31751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31752         this_ptr_conv.is_owned = false;
31753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31754         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
31755         return ret_val;
31756 }
31757
31758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31759         LDKQueryChannelRange this_ptr_conv;
31760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31761         this_ptr_conv.is_owned = false;
31762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31763         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
31764 }
31765
31766 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
31767         LDKQueryChannelRange this_ptr_conv;
31768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31769         this_ptr_conv.is_owned = false;
31770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31771         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
31772         return ret_val;
31773 }
31774
31775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31776         LDKQueryChannelRange this_ptr_conv;
31777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31778         this_ptr_conv.is_owned = false;
31779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31780         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
31781 }
31782
31783 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) {
31784         LDKThirtyTwoBytes chain_hash_arg_ref;
31785         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
31786         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
31787         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
31788         uintptr_t ret_ref = 0;
31789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31792         ret_ref = (uintptr_t)ret_var.inner;
31793         if (ret_var.is_owned) {
31794                 ret_ref |= 1;
31795         }
31796         return ret_ref;
31797 }
31798
31799 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
31800         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
31801 uintptr_t ret_ref = 0;
31802 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31803 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31804 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31805 ret_ref = (uintptr_t)ret_var.inner;
31806 if (ret_var.is_owned) {
31807         ret_ref |= 1;
31808 }
31809         return ret_ref;
31810 }
31811 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31812         LDKQueryChannelRange arg_conv;
31813         arg_conv.inner = (void*)(arg & (~1));
31814         arg_conv.is_owned = false;
31815         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31816         intptr_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
31817         return ret_val;
31818 }
31819
31820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31821         LDKQueryChannelRange orig_conv;
31822         orig_conv.inner = (void*)(orig & (~1));
31823         orig_conv.is_owned = false;
31824         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31825         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
31826         uintptr_t ret_ref = 0;
31827         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31828         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31830         ret_ref = (uintptr_t)ret_var.inner;
31831         if (ret_var.is_owned) {
31832                 ret_ref |= 1;
31833         }
31834         return ret_ref;
31835 }
31836
31837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31838         LDKReplyChannelRange this_obj_conv;
31839         this_obj_conv.inner = (void*)(this_obj & (~1));
31840         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31842         ReplyChannelRange_free(this_obj_conv);
31843 }
31844
31845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
31846         LDKReplyChannelRange this_ptr_conv;
31847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31848         this_ptr_conv.is_owned = false;
31849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31850         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31851         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
31852         return ret_arr;
31853 }
31854
31855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31856         LDKReplyChannelRange this_ptr_conv;
31857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31858         this_ptr_conv.is_owned = false;
31859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31860         LDKThirtyTwoBytes val_ref;
31861         CHECK((*env)->GetArrayLength(env, val) == 32);
31862         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31863         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
31864 }
31865
31866 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
31867         LDKReplyChannelRange this_ptr_conv;
31868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31869         this_ptr_conv.is_owned = false;
31870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31871         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
31872         return ret_val;
31873 }
31874
31875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31876         LDKReplyChannelRange this_ptr_conv;
31877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31878         this_ptr_conv.is_owned = false;
31879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31880         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
31881 }
31882
31883 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
31884         LDKReplyChannelRange this_ptr_conv;
31885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31886         this_ptr_conv.is_owned = false;
31887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31888         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
31889         return ret_val;
31890 }
31891
31892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31893         LDKReplyChannelRange this_ptr_conv;
31894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31895         this_ptr_conv.is_owned = false;
31896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31897         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
31898 }
31899
31900 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
31901         LDKReplyChannelRange this_ptr_conv;
31902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31903         this_ptr_conv.is_owned = false;
31904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31905         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
31906         return ret_val;
31907 }
31908
31909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
31910         LDKReplyChannelRange this_ptr_conv;
31911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31912         this_ptr_conv.is_owned = false;
31913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31914         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
31915 }
31916
31917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
31918         LDKReplyChannelRange this_ptr_conv;
31919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31920         this_ptr_conv.is_owned = false;
31921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31922         LDKCVec_u64Z val_constr;
31923         val_constr.datalen = (*env)->GetArrayLength(env, val);
31924         if (val_constr.datalen > 0)
31925                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
31926         else
31927                 val_constr.data = NULL;
31928         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
31929         for (size_t g = 0; g < val_constr.datalen; g++) {
31930                 int64_t val_conv_6 = val_vals[g];
31931                 val_constr.data[g] = val_conv_6;
31932         }
31933         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
31934         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
31935 }
31936
31937 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) {
31938         LDKThirtyTwoBytes chain_hash_arg_ref;
31939         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
31940         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
31941         LDKCVec_u64Z short_channel_ids_arg_constr;
31942         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
31943         if (short_channel_ids_arg_constr.datalen > 0)
31944                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
31945         else
31946                 short_channel_ids_arg_constr.data = NULL;
31947         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
31948         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
31949                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
31950                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
31951         }
31952         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
31953         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
31954         uintptr_t ret_ref = 0;
31955         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31956         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31958         ret_ref = (uintptr_t)ret_var.inner;
31959         if (ret_var.is_owned) {
31960                 ret_ref |= 1;
31961         }
31962         return ret_ref;
31963 }
31964
31965 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
31966         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
31967 uintptr_t ret_ref = 0;
31968 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31969 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31970 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31971 ret_ref = (uintptr_t)ret_var.inner;
31972 if (ret_var.is_owned) {
31973         ret_ref |= 1;
31974 }
31975         return ret_ref;
31976 }
31977 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31978         LDKReplyChannelRange arg_conv;
31979         arg_conv.inner = (void*)(arg & (~1));
31980         arg_conv.is_owned = false;
31981         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31982         intptr_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
31983         return ret_val;
31984 }
31985
31986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31987         LDKReplyChannelRange orig_conv;
31988         orig_conv.inner = (void*)(orig & (~1));
31989         orig_conv.is_owned = false;
31990         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31991         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
31992         uintptr_t ret_ref = 0;
31993         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31994         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31996         ret_ref = (uintptr_t)ret_var.inner;
31997         if (ret_var.is_owned) {
31998                 ret_ref |= 1;
31999         }
32000         return ret_ref;
32001 }
32002
32003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32004         LDKQueryShortChannelIds this_obj_conv;
32005         this_obj_conv.inner = (void*)(this_obj & (~1));
32006         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32008         QueryShortChannelIds_free(this_obj_conv);
32009 }
32010
32011 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32012         LDKQueryShortChannelIds this_ptr_conv;
32013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32014         this_ptr_conv.is_owned = false;
32015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32016         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32017         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
32018         return ret_arr;
32019 }
32020
32021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32022         LDKQueryShortChannelIds this_ptr_conv;
32023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32024         this_ptr_conv.is_owned = false;
32025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32026         LDKThirtyTwoBytes val_ref;
32027         CHECK((*env)->GetArrayLength(env, val) == 32);
32028         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32029         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
32030 }
32031
32032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
32033         LDKQueryShortChannelIds this_ptr_conv;
32034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32035         this_ptr_conv.is_owned = false;
32036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32037         LDKCVec_u64Z val_constr;
32038         val_constr.datalen = (*env)->GetArrayLength(env, val);
32039         if (val_constr.datalen > 0)
32040                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32041         else
32042                 val_constr.data = NULL;
32043         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
32044         for (size_t g = 0; g < val_constr.datalen; g++) {
32045                 int64_t val_conv_6 = val_vals[g];
32046                 val_constr.data[g] = val_conv_6;
32047         }
32048         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
32049         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
32050 }
32051
32052 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) {
32053         LDKThirtyTwoBytes chain_hash_arg_ref;
32054         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
32055         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
32056         LDKCVec_u64Z short_channel_ids_arg_constr;
32057         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
32058         if (short_channel_ids_arg_constr.datalen > 0)
32059                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32060         else
32061                 short_channel_ids_arg_constr.data = NULL;
32062         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
32063         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
32064                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
32065                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
32066         }
32067         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
32068         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
32069         uintptr_t ret_ref = 0;
32070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32073         ret_ref = (uintptr_t)ret_var.inner;
32074         if (ret_var.is_owned) {
32075                 ret_ref |= 1;
32076         }
32077         return ret_ref;
32078 }
32079
32080 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
32081         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
32082 uintptr_t ret_ref = 0;
32083 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32084 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32085 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32086 ret_ref = (uintptr_t)ret_var.inner;
32087 if (ret_var.is_owned) {
32088         ret_ref |= 1;
32089 }
32090         return ret_ref;
32091 }
32092 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32093         LDKQueryShortChannelIds arg_conv;
32094         arg_conv.inner = (void*)(arg & (~1));
32095         arg_conv.is_owned = false;
32096         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32097         intptr_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
32098         return ret_val;
32099 }
32100
32101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32102         LDKQueryShortChannelIds orig_conv;
32103         orig_conv.inner = (void*)(orig & (~1));
32104         orig_conv.is_owned = false;
32105         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32106         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
32107         uintptr_t ret_ref = 0;
32108         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32109         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32111         ret_ref = (uintptr_t)ret_var.inner;
32112         if (ret_var.is_owned) {
32113                 ret_ref |= 1;
32114         }
32115         return ret_ref;
32116 }
32117
32118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32119         LDKReplyShortChannelIdsEnd this_obj_conv;
32120         this_obj_conv.inner = (void*)(this_obj & (~1));
32121         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32123         ReplyShortChannelIdsEnd_free(this_obj_conv);
32124 }
32125
32126 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32127         LDKReplyShortChannelIdsEnd this_ptr_conv;
32128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32129         this_ptr_conv.is_owned = false;
32130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32131         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32132         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
32133         return ret_arr;
32134 }
32135
32136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32137         LDKReplyShortChannelIdsEnd this_ptr_conv;
32138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32139         this_ptr_conv.is_owned = false;
32140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32141         LDKThirtyTwoBytes val_ref;
32142         CHECK((*env)->GetArrayLength(env, val) == 32);
32143         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32144         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
32145 }
32146
32147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
32148         LDKReplyShortChannelIdsEnd this_ptr_conv;
32149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32150         this_ptr_conv.is_owned = false;
32151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32152         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
32153         return ret_val;
32154 }
32155
32156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32157         LDKReplyShortChannelIdsEnd this_ptr_conv;
32158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32159         this_ptr_conv.is_owned = false;
32160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32161         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
32162 }
32163
32164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
32165         LDKThirtyTwoBytes chain_hash_arg_ref;
32166         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
32167         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
32168         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
32169         uintptr_t ret_ref = 0;
32170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32173         ret_ref = (uintptr_t)ret_var.inner;
32174         if (ret_var.is_owned) {
32175                 ret_ref |= 1;
32176         }
32177         return ret_ref;
32178 }
32179
32180 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
32181         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
32182 uintptr_t ret_ref = 0;
32183 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32184 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32185 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32186 ret_ref = (uintptr_t)ret_var.inner;
32187 if (ret_var.is_owned) {
32188         ret_ref |= 1;
32189 }
32190         return ret_ref;
32191 }
32192 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32193         LDKReplyShortChannelIdsEnd arg_conv;
32194         arg_conv.inner = (void*)(arg & (~1));
32195         arg_conv.is_owned = false;
32196         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32197         intptr_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
32198         return ret_val;
32199 }
32200
32201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32202         LDKReplyShortChannelIdsEnd orig_conv;
32203         orig_conv.inner = (void*)(orig & (~1));
32204         orig_conv.is_owned = false;
32205         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32206         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
32207         uintptr_t ret_ref = 0;
32208         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32209         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32211         ret_ref = (uintptr_t)ret_var.inner;
32212         if (ret_var.is_owned) {
32213                 ret_ref |= 1;
32214         }
32215         return ret_ref;
32216 }
32217
32218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32219         LDKGossipTimestampFilter this_obj_conv;
32220         this_obj_conv.inner = (void*)(this_obj & (~1));
32221         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32223         GossipTimestampFilter_free(this_obj_conv);
32224 }
32225
32226 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32227         LDKGossipTimestampFilter this_ptr_conv;
32228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32229         this_ptr_conv.is_owned = false;
32230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32231         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32232         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
32233         return ret_arr;
32234 }
32235
32236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32237         LDKGossipTimestampFilter this_ptr_conv;
32238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32239         this_ptr_conv.is_owned = false;
32240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32241         LDKThirtyTwoBytes val_ref;
32242         CHECK((*env)->GetArrayLength(env, val) == 32);
32243         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32244         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
32245 }
32246
32247 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
32248         LDKGossipTimestampFilter this_ptr_conv;
32249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32250         this_ptr_conv.is_owned = false;
32251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32252         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
32253         return ret_val;
32254 }
32255
32256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32257         LDKGossipTimestampFilter this_ptr_conv;
32258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32259         this_ptr_conv.is_owned = false;
32260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32261         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
32262 }
32263
32264 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
32265         LDKGossipTimestampFilter this_ptr_conv;
32266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32267         this_ptr_conv.is_owned = false;
32268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32269         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
32270         return ret_val;
32271 }
32272
32273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32274         LDKGossipTimestampFilter this_ptr_conv;
32275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32276         this_ptr_conv.is_owned = false;
32277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32278         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
32279 }
32280
32281 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) {
32282         LDKThirtyTwoBytes chain_hash_arg_ref;
32283         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
32284         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
32285         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
32286         uintptr_t ret_ref = 0;
32287         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32288         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32290         ret_ref = (uintptr_t)ret_var.inner;
32291         if (ret_var.is_owned) {
32292                 ret_ref |= 1;
32293         }
32294         return ret_ref;
32295 }
32296
32297 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
32298         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
32299 uintptr_t ret_ref = 0;
32300 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32301 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32302 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32303 ret_ref = (uintptr_t)ret_var.inner;
32304 if (ret_var.is_owned) {
32305         ret_ref |= 1;
32306 }
32307         return ret_ref;
32308 }
32309 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32310         LDKGossipTimestampFilter arg_conv;
32311         arg_conv.inner = (void*)(arg & (~1));
32312         arg_conv.is_owned = false;
32313         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32314         intptr_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
32315         return ret_val;
32316 }
32317
32318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32319         LDKGossipTimestampFilter orig_conv;
32320         orig_conv.inner = (void*)(orig & (~1));
32321         orig_conv.is_owned = false;
32322         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32323         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
32324         uintptr_t ret_ref = 0;
32325         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32326         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32328         ret_ref = (uintptr_t)ret_var.inner;
32329         if (ret_var.is_owned) {
32330                 ret_ref |= 1;
32331         }
32332         return ret_ref;
32333 }
32334
32335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32336         if ((this_ptr & 1) != 0) return;
32337         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32338         CHECK_ACCESS(this_ptr_ptr);
32339         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
32340         FREE((void*)this_ptr);
32341         ErrorAction_free(this_ptr_conv);
32342 }
32343
32344 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
32345         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32346         *ret_copy = ErrorAction_clone(arg);
32347 uintptr_t ret_ref = (uintptr_t)ret_copy;
32348         return ret_ref;
32349 }
32350 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32351         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
32352         intptr_t ret_val = ErrorAction_clone_ptr(arg_conv);
32353         return ret_val;
32354 }
32355
32356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32357         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
32358         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32359         *ret_copy = ErrorAction_clone(orig_conv);
32360         uintptr_t ret_ref = (uintptr_t)ret_copy;
32361         return ret_ref;
32362 }
32363
32364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
32365         LDKErrorMessage msg_conv;
32366         msg_conv.inner = (void*)(msg & (~1));
32367         msg_conv.is_owned = (msg & 1) || (msg == 0);
32368         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32369         msg_conv = ErrorMessage_clone(&msg_conv);
32370         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32371         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
32372         uintptr_t ret_ref = (uintptr_t)ret_copy;
32373         return ret_ref;
32374 }
32375
32376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
32377         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32378         *ret_copy = ErrorAction_ignore_error();
32379         uintptr_t ret_ref = (uintptr_t)ret_copy;
32380         return ret_ref;
32381 }
32382
32383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
32384         LDKLevel a_conv = LDKLevel_from_java(env, a);
32385         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32386         *ret_copy = ErrorAction_ignore_and_log(a_conv);
32387         uintptr_t ret_ref = (uintptr_t)ret_copy;
32388         return ret_ref;
32389 }
32390
32391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
32392         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32393         *ret_copy = ErrorAction_ignore_duplicate_gossip();
32394         uintptr_t ret_ref = (uintptr_t)ret_copy;
32395         return ret_ref;
32396 }
32397
32398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
32399         LDKErrorMessage msg_conv;
32400         msg_conv.inner = (void*)(msg & (~1));
32401         msg_conv.is_owned = (msg & 1) || (msg == 0);
32402         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32403         msg_conv = ErrorMessage_clone(&msg_conv);
32404         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32405         *ret_copy = ErrorAction_send_error_message(msg_conv);
32406         uintptr_t ret_ref = (uintptr_t)ret_copy;
32407         return ret_ref;
32408 }
32409
32410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32411         LDKLightningError this_obj_conv;
32412         this_obj_conv.inner = (void*)(this_obj & (~1));
32413         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32415         LightningError_free(this_obj_conv);
32416 }
32417
32418 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
32419         LDKLightningError this_ptr_conv;
32420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32421         this_ptr_conv.is_owned = false;
32422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32423         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
32424         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
32425         Str_free(ret_str);
32426         return ret_conv;
32427 }
32428
32429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
32430         LDKLightningError this_ptr_conv;
32431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32432         this_ptr_conv.is_owned = false;
32433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32434         LDKStr val_conv = java_to_owned_str(env, val);
32435         LightningError_set_err(&this_ptr_conv, val_conv);
32436 }
32437
32438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
32439         LDKLightningError this_ptr_conv;
32440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32441         this_ptr_conv.is_owned = false;
32442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32443         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32444         *ret_copy = LightningError_get_action(&this_ptr_conv);
32445         uintptr_t ret_ref = (uintptr_t)ret_copy;
32446         return ret_ref;
32447 }
32448
32449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32450         LDKLightningError this_ptr_conv;
32451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32452         this_ptr_conv.is_owned = false;
32453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32454         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32455         CHECK_ACCESS(val_ptr);
32456         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
32457         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
32458         LightningError_set_action(&this_ptr_conv, val_conv);
32459 }
32460
32461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
32462         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
32463         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
32464         CHECK_ACCESS(action_arg_ptr);
32465         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
32466         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
32467         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
32468         uintptr_t ret_ref = 0;
32469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32472         ret_ref = (uintptr_t)ret_var.inner;
32473         if (ret_var.is_owned) {
32474                 ret_ref |= 1;
32475         }
32476         return ret_ref;
32477 }
32478
32479 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
32480         LDKLightningError ret_var = LightningError_clone(arg);
32481 uintptr_t ret_ref = 0;
32482 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32483 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32484 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32485 ret_ref = (uintptr_t)ret_var.inner;
32486 if (ret_var.is_owned) {
32487         ret_ref |= 1;
32488 }
32489         return ret_ref;
32490 }
32491 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32492         LDKLightningError arg_conv;
32493         arg_conv.inner = (void*)(arg & (~1));
32494         arg_conv.is_owned = false;
32495         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32496         intptr_t ret_val = LightningError_clone_ptr(&arg_conv);
32497         return ret_val;
32498 }
32499
32500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32501         LDKLightningError orig_conv;
32502         orig_conv.inner = (void*)(orig & (~1));
32503         orig_conv.is_owned = false;
32504         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32505         LDKLightningError ret_var = LightningError_clone(&orig_conv);
32506         uintptr_t ret_ref = 0;
32507         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32508         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32510         ret_ref = (uintptr_t)ret_var.inner;
32511         if (ret_var.is_owned) {
32512                 ret_ref |= 1;
32513         }
32514         return ret_ref;
32515 }
32516
32517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32518         LDKCommitmentUpdate this_obj_conv;
32519         this_obj_conv.inner = (void*)(this_obj & (~1));
32520         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32522         CommitmentUpdate_free(this_obj_conv);
32523 }
32524
32525 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32526         LDKCommitmentUpdate this_ptr_conv;
32527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32528         this_ptr_conv.is_owned = false;
32529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32530         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
32531         int64_tArray ret_arr = NULL;
32532         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
32533         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
32534         for (size_t p = 0; p < ret_var.datalen; p++) {
32535                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
32536                 uintptr_t ret_conv_15_ref = 0;
32537                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32538                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32539                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
32540                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
32541                 if (ret_conv_15_var.is_owned) {
32542                         ret_conv_15_ref |= 1;
32543                 }
32544                 ret_arr_ptr[p] = ret_conv_15_ref;
32545         }
32546         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
32547         FREE(ret_var.data);
32548         return ret_arr;
32549 }
32550
32551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
32552         LDKCommitmentUpdate this_ptr_conv;
32553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32554         this_ptr_conv.is_owned = false;
32555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32556         LDKCVec_UpdateAddHTLCZ val_constr;
32557         val_constr.datalen = (*env)->GetArrayLength(env, val);
32558         if (val_constr.datalen > 0)
32559                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
32560         else
32561                 val_constr.data = NULL;
32562         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
32563         for (size_t p = 0; p < val_constr.datalen; p++) {
32564                 int64_t val_conv_15 = val_vals[p];
32565                 LDKUpdateAddHTLC val_conv_15_conv;
32566                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
32567                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
32568                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
32569                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
32570                 val_constr.data[p] = val_conv_15_conv;
32571         }
32572         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
32573         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
32574 }
32575
32576 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32577         LDKCommitmentUpdate this_ptr_conv;
32578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32579         this_ptr_conv.is_owned = false;
32580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32581         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
32582         int64_tArray ret_arr = NULL;
32583         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
32584         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
32585         for (size_t t = 0; t < ret_var.datalen; t++) {
32586                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
32587                 uintptr_t ret_conv_19_ref = 0;
32588                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32589                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32590                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
32591                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
32592                 if (ret_conv_19_var.is_owned) {
32593                         ret_conv_19_ref |= 1;
32594                 }
32595                 ret_arr_ptr[t] = ret_conv_19_ref;
32596         }
32597         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
32598         FREE(ret_var.data);
32599         return ret_arr;
32600 }
32601
32602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
32603         LDKCommitmentUpdate this_ptr_conv;
32604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32605         this_ptr_conv.is_owned = false;
32606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32607         LDKCVec_UpdateFulfillHTLCZ val_constr;
32608         val_constr.datalen = (*env)->GetArrayLength(env, val);
32609         if (val_constr.datalen > 0)
32610                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
32611         else
32612                 val_constr.data = NULL;
32613         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
32614         for (size_t t = 0; t < val_constr.datalen; t++) {
32615                 int64_t val_conv_19 = val_vals[t];
32616                 LDKUpdateFulfillHTLC val_conv_19_conv;
32617                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
32618                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
32619                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
32620                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
32621                 val_constr.data[t] = val_conv_19_conv;
32622         }
32623         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
32624         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
32625 }
32626
32627 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32628         LDKCommitmentUpdate this_ptr_conv;
32629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32630         this_ptr_conv.is_owned = false;
32631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32632         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
32633         int64_tArray ret_arr = NULL;
32634         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
32635         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
32636         for (size_t q = 0; q < ret_var.datalen; q++) {
32637                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
32638                 uintptr_t ret_conv_16_ref = 0;
32639                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32640                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32641                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
32642                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
32643                 if (ret_conv_16_var.is_owned) {
32644                         ret_conv_16_ref |= 1;
32645                 }
32646                 ret_arr_ptr[q] = ret_conv_16_ref;
32647         }
32648         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
32649         FREE(ret_var.data);
32650         return ret_arr;
32651 }
32652
32653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
32654         LDKCommitmentUpdate this_ptr_conv;
32655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32656         this_ptr_conv.is_owned = false;
32657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32658         LDKCVec_UpdateFailHTLCZ val_constr;
32659         val_constr.datalen = (*env)->GetArrayLength(env, val);
32660         if (val_constr.datalen > 0)
32661                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
32662         else
32663                 val_constr.data = NULL;
32664         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
32665         for (size_t q = 0; q < val_constr.datalen; q++) {
32666                 int64_t val_conv_16 = val_vals[q];
32667                 LDKUpdateFailHTLC val_conv_16_conv;
32668                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
32669                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
32670                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
32671                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
32672                 val_constr.data[q] = val_conv_16_conv;
32673         }
32674         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
32675         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
32676 }
32677
32678 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32679         LDKCommitmentUpdate this_ptr_conv;
32680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32681         this_ptr_conv.is_owned = false;
32682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32683         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
32684         int64_tArray ret_arr = NULL;
32685         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
32686         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
32687         for (size_t z = 0; z < ret_var.datalen; z++) {
32688                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
32689                 uintptr_t ret_conv_25_ref = 0;
32690                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32691                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32692                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
32693                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
32694                 if (ret_conv_25_var.is_owned) {
32695                         ret_conv_25_ref |= 1;
32696                 }
32697                 ret_arr_ptr[z] = ret_conv_25_ref;
32698         }
32699         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
32700         FREE(ret_var.data);
32701         return ret_arr;
32702 }
32703
32704 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) {
32705         LDKCommitmentUpdate this_ptr_conv;
32706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32707         this_ptr_conv.is_owned = false;
32708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32709         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
32710         val_constr.datalen = (*env)->GetArrayLength(env, val);
32711         if (val_constr.datalen > 0)
32712                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
32713         else
32714                 val_constr.data = NULL;
32715         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
32716         for (size_t z = 0; z < val_constr.datalen; z++) {
32717                 int64_t val_conv_25 = val_vals[z];
32718                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
32719                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
32720                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
32721                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
32722                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
32723                 val_constr.data[z] = val_conv_25_conv;
32724         }
32725         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
32726         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
32727 }
32728
32729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
32730         LDKCommitmentUpdate this_ptr_conv;
32731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32732         this_ptr_conv.is_owned = false;
32733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32734         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
32735         uintptr_t ret_ref = 0;
32736         if ((uintptr_t)ret_var.inner > 4096) {
32737                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32738                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32740                 ret_ref = (uintptr_t)ret_var.inner;
32741                 if (ret_var.is_owned) {
32742                         ret_ref |= 1;
32743                 }
32744         }
32745         return ret_ref;
32746 }
32747
32748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32749         LDKCommitmentUpdate this_ptr_conv;
32750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32751         this_ptr_conv.is_owned = false;
32752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32753         LDKUpdateFee val_conv;
32754         val_conv.inner = (void*)(val & (~1));
32755         val_conv.is_owned = (val & 1) || (val == 0);
32756         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32757         val_conv = UpdateFee_clone(&val_conv);
32758         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
32759 }
32760
32761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
32762         LDKCommitmentUpdate this_ptr_conv;
32763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32764         this_ptr_conv.is_owned = false;
32765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32766         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
32767         uintptr_t ret_ref = 0;
32768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32771         ret_ref = (uintptr_t)ret_var.inner;
32772         if (ret_var.is_owned) {
32773                 ret_ref |= 1;
32774         }
32775         return ret_ref;
32776 }
32777
32778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32779         LDKCommitmentUpdate this_ptr_conv;
32780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32781         this_ptr_conv.is_owned = false;
32782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32783         LDKCommitmentSigned val_conv;
32784         val_conv.inner = (void*)(val & (~1));
32785         val_conv.is_owned = (val & 1) || (val == 0);
32786         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32787         val_conv = CommitmentSigned_clone(&val_conv);
32788         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
32789 }
32790
32791 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) {
32792         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
32793         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
32794         if (update_add_htlcs_arg_constr.datalen > 0)
32795                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
32796         else
32797                 update_add_htlcs_arg_constr.data = NULL;
32798         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
32799         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
32800                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
32801                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
32802                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
32803                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
32804                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
32805                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
32806                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
32807         }
32808         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
32809         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
32810         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
32811         if (update_fulfill_htlcs_arg_constr.datalen > 0)
32812                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
32813         else
32814                 update_fulfill_htlcs_arg_constr.data = NULL;
32815         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
32816         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
32817                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
32818                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
32819                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
32820                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
32821                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
32822                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
32823                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
32824         }
32825         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
32826         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
32827         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
32828         if (update_fail_htlcs_arg_constr.datalen > 0)
32829                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
32830         else
32831                 update_fail_htlcs_arg_constr.data = NULL;
32832         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
32833         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
32834                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
32835                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
32836                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
32837                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
32838                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
32839                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
32840                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
32841         }
32842         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
32843         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
32844         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
32845         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
32846                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
32847         else
32848                 update_fail_malformed_htlcs_arg_constr.data = NULL;
32849         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
32850         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
32851                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
32852                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
32853                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
32854                 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);
32855                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
32856                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
32857                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
32858         }
32859         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
32860         LDKUpdateFee update_fee_arg_conv;
32861         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
32862         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
32863         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
32864         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
32865         LDKCommitmentSigned commitment_signed_arg_conv;
32866         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
32867         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
32868         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
32869         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
32870         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);
32871         uintptr_t ret_ref = 0;
32872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32875         ret_ref = (uintptr_t)ret_var.inner;
32876         if (ret_var.is_owned) {
32877                 ret_ref |= 1;
32878         }
32879         return ret_ref;
32880 }
32881
32882 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
32883         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
32884 uintptr_t ret_ref = 0;
32885 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32886 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32887 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32888 ret_ref = (uintptr_t)ret_var.inner;
32889 if (ret_var.is_owned) {
32890         ret_ref |= 1;
32891 }
32892         return ret_ref;
32893 }
32894 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32895         LDKCommitmentUpdate arg_conv;
32896         arg_conv.inner = (void*)(arg & (~1));
32897         arg_conv.is_owned = false;
32898         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32899         intptr_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
32900         return ret_val;
32901 }
32902
32903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32904         LDKCommitmentUpdate orig_conv;
32905         orig_conv.inner = (void*)(orig & (~1));
32906         orig_conv.is_owned = false;
32907         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32908         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
32909         uintptr_t ret_ref = 0;
32910         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32911         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32913         ret_ref = (uintptr_t)ret_var.inner;
32914         if (ret_var.is_owned) {
32915                 ret_ref |= 1;
32916         }
32917         return ret_ref;
32918 }
32919
32920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32921         if ((this_ptr & 1) != 0) return;
32922         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32923         CHECK_ACCESS(this_ptr_ptr);
32924         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
32925         FREE((void*)this_ptr);
32926         ChannelMessageHandler_free(this_ptr_conv);
32927 }
32928
32929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32930         if ((this_ptr & 1) != 0) return;
32931         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32932         CHECK_ACCESS(this_ptr_ptr);
32933         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
32934         FREE((void*)this_ptr);
32935         RoutingMessageHandler_free(this_ptr_conv);
32936 }
32937
32938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
32939         LDKAcceptChannel obj_conv;
32940         obj_conv.inner = (void*)(obj & (~1));
32941         obj_conv.is_owned = false;
32942         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32943         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
32944         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32945         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32946         CVec_u8Z_free(ret_var);
32947         return ret_arr;
32948 }
32949
32950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32951         LDKu8slice ser_ref;
32952         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32953         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32954         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
32955         *ret_conv = AcceptChannel_read(ser_ref);
32956         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32957         return (uintptr_t)ret_conv;
32958 }
32959
32960 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
32961         LDKAnnouncementSignatures obj_conv;
32962         obj_conv.inner = (void*)(obj & (~1));
32963         obj_conv.is_owned = false;
32964         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32965         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
32966         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32967         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32968         CVec_u8Z_free(ret_var);
32969         return ret_arr;
32970 }
32971
32972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32973         LDKu8slice ser_ref;
32974         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32975         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32976         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
32977         *ret_conv = AnnouncementSignatures_read(ser_ref);
32978         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32979         return (uintptr_t)ret_conv;
32980 }
32981
32982 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
32983         LDKChannelReestablish obj_conv;
32984         obj_conv.inner = (void*)(obj & (~1));
32985         obj_conv.is_owned = false;
32986         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32987         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
32988         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32989         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32990         CVec_u8Z_free(ret_var);
32991         return ret_arr;
32992 }
32993
32994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32995         LDKu8slice ser_ref;
32996         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32997         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32998         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
32999         *ret_conv = ChannelReestablish_read(ser_ref);
33000         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33001         return (uintptr_t)ret_conv;
33002 }
33003
33004 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
33005         LDKClosingSigned obj_conv;
33006         obj_conv.inner = (void*)(obj & (~1));
33007         obj_conv.is_owned = false;
33008         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33009         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
33010         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33011         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33012         CVec_u8Z_free(ret_var);
33013         return ret_arr;
33014 }
33015
33016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33017         LDKu8slice ser_ref;
33018         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33019         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33020         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
33021         *ret_conv = ClosingSigned_read(ser_ref);
33022         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33023         return (uintptr_t)ret_conv;
33024 }
33025
33026 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
33027         LDKClosingSignedFeeRange obj_conv;
33028         obj_conv.inner = (void*)(obj & (~1));
33029         obj_conv.is_owned = false;
33030         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33031         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
33032         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33033         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33034         CVec_u8Z_free(ret_var);
33035         return ret_arr;
33036 }
33037
33038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33039         LDKu8slice ser_ref;
33040         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33041         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33042         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
33043         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
33044         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33045         return (uintptr_t)ret_conv;
33046 }
33047
33048 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
33049         LDKCommitmentSigned obj_conv;
33050         obj_conv.inner = (void*)(obj & (~1));
33051         obj_conv.is_owned = false;
33052         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33053         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
33054         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33055         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33056         CVec_u8Z_free(ret_var);
33057         return ret_arr;
33058 }
33059
33060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33061         LDKu8slice ser_ref;
33062         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33063         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33064         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
33065         *ret_conv = CommitmentSigned_read(ser_ref);
33066         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33067         return (uintptr_t)ret_conv;
33068 }
33069
33070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
33071         LDKFundingCreated obj_conv;
33072         obj_conv.inner = (void*)(obj & (~1));
33073         obj_conv.is_owned = false;
33074         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33075         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
33076         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33077         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33078         CVec_u8Z_free(ret_var);
33079         return ret_arr;
33080 }
33081
33082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33083         LDKu8slice ser_ref;
33084         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33085         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33086         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
33087         *ret_conv = FundingCreated_read(ser_ref);
33088         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33089         return (uintptr_t)ret_conv;
33090 }
33091
33092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
33093         LDKFundingSigned obj_conv;
33094         obj_conv.inner = (void*)(obj & (~1));
33095         obj_conv.is_owned = false;
33096         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33097         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
33098         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33099         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33100         CVec_u8Z_free(ret_var);
33101         return ret_arr;
33102 }
33103
33104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33105         LDKu8slice ser_ref;
33106         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33107         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33108         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
33109         *ret_conv = FundingSigned_read(ser_ref);
33110         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33111         return (uintptr_t)ret_conv;
33112 }
33113
33114 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
33115         LDKFundingLocked obj_conv;
33116         obj_conv.inner = (void*)(obj & (~1));
33117         obj_conv.is_owned = false;
33118         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33119         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
33120         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33121         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33122         CVec_u8Z_free(ret_var);
33123         return ret_arr;
33124 }
33125
33126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33127         LDKu8slice ser_ref;
33128         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33129         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33130         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
33131         *ret_conv = FundingLocked_read(ser_ref);
33132         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33133         return (uintptr_t)ret_conv;
33134 }
33135
33136 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
33137         LDKInit obj_conv;
33138         obj_conv.inner = (void*)(obj & (~1));
33139         obj_conv.is_owned = false;
33140         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33141         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
33142         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33143         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33144         CVec_u8Z_free(ret_var);
33145         return ret_arr;
33146 }
33147
33148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33149         LDKu8slice ser_ref;
33150         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33151         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33152         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
33153         *ret_conv = Init_read(ser_ref);
33154         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33155         return (uintptr_t)ret_conv;
33156 }
33157
33158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
33159         LDKOpenChannel obj_conv;
33160         obj_conv.inner = (void*)(obj & (~1));
33161         obj_conv.is_owned = false;
33162         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33163         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
33164         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33165         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33166         CVec_u8Z_free(ret_var);
33167         return ret_arr;
33168 }
33169
33170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33171         LDKu8slice ser_ref;
33172         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33173         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33174         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
33175         *ret_conv = OpenChannel_read(ser_ref);
33176         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33177         return (uintptr_t)ret_conv;
33178 }
33179
33180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
33181         LDKRevokeAndACK obj_conv;
33182         obj_conv.inner = (void*)(obj & (~1));
33183         obj_conv.is_owned = false;
33184         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33185         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
33186         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33187         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33188         CVec_u8Z_free(ret_var);
33189         return ret_arr;
33190 }
33191
33192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33193         LDKu8slice ser_ref;
33194         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33195         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33196         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
33197         *ret_conv = RevokeAndACK_read(ser_ref);
33198         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33199         return (uintptr_t)ret_conv;
33200 }
33201
33202 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
33203         LDKShutdown obj_conv;
33204         obj_conv.inner = (void*)(obj & (~1));
33205         obj_conv.is_owned = false;
33206         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33207         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
33208         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33209         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33210         CVec_u8Z_free(ret_var);
33211         return ret_arr;
33212 }
33213
33214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33215         LDKu8slice ser_ref;
33216         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33217         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33218         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
33219         *ret_conv = Shutdown_read(ser_ref);
33220         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33221         return (uintptr_t)ret_conv;
33222 }
33223
33224 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
33225         LDKUpdateFailHTLC obj_conv;
33226         obj_conv.inner = (void*)(obj & (~1));
33227         obj_conv.is_owned = false;
33228         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33229         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
33230         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33231         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33232         CVec_u8Z_free(ret_var);
33233         return ret_arr;
33234 }
33235
33236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33237         LDKu8slice ser_ref;
33238         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33239         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33240         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
33241         *ret_conv = UpdateFailHTLC_read(ser_ref);
33242         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33243         return (uintptr_t)ret_conv;
33244 }
33245
33246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
33247         LDKUpdateFailMalformedHTLC obj_conv;
33248         obj_conv.inner = (void*)(obj & (~1));
33249         obj_conv.is_owned = false;
33250         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33251         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
33252         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33253         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33254         CVec_u8Z_free(ret_var);
33255         return ret_arr;
33256 }
33257
33258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33259         LDKu8slice ser_ref;
33260         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33261         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33262         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
33263         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
33264         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33265         return (uintptr_t)ret_conv;
33266 }
33267
33268 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
33269         LDKUpdateFee obj_conv;
33270         obj_conv.inner = (void*)(obj & (~1));
33271         obj_conv.is_owned = false;
33272         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33273         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
33274         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33275         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33276         CVec_u8Z_free(ret_var);
33277         return ret_arr;
33278 }
33279
33280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33281         LDKu8slice ser_ref;
33282         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33283         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33284         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
33285         *ret_conv = UpdateFee_read(ser_ref);
33286         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33287         return (uintptr_t)ret_conv;
33288 }
33289
33290 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
33291         LDKUpdateFulfillHTLC obj_conv;
33292         obj_conv.inner = (void*)(obj & (~1));
33293         obj_conv.is_owned = false;
33294         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33295         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
33296         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33297         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33298         CVec_u8Z_free(ret_var);
33299         return ret_arr;
33300 }
33301
33302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33303         LDKu8slice ser_ref;
33304         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33305         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33306         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
33307         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
33308         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33309         return (uintptr_t)ret_conv;
33310 }
33311
33312 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
33313         LDKUpdateAddHTLC obj_conv;
33314         obj_conv.inner = (void*)(obj & (~1));
33315         obj_conv.is_owned = false;
33316         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33317         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
33318         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33319         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33320         CVec_u8Z_free(ret_var);
33321         return ret_arr;
33322 }
33323
33324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33325         LDKu8slice ser_ref;
33326         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33327         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33328         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
33329         *ret_conv = UpdateAddHTLC_read(ser_ref);
33330         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33331         return (uintptr_t)ret_conv;
33332 }
33333
33334 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
33335         LDKPing obj_conv;
33336         obj_conv.inner = (void*)(obj & (~1));
33337         obj_conv.is_owned = false;
33338         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33339         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
33340         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33341         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33342         CVec_u8Z_free(ret_var);
33343         return ret_arr;
33344 }
33345
33346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33347         LDKu8slice ser_ref;
33348         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33349         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33350         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
33351         *ret_conv = Ping_read(ser_ref);
33352         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33353         return (uintptr_t)ret_conv;
33354 }
33355
33356 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
33357         LDKPong obj_conv;
33358         obj_conv.inner = (void*)(obj & (~1));
33359         obj_conv.is_owned = false;
33360         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33361         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
33362         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33363         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33364         CVec_u8Z_free(ret_var);
33365         return ret_arr;
33366 }
33367
33368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33369         LDKu8slice ser_ref;
33370         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33371         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33372         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
33373         *ret_conv = Pong_read(ser_ref);
33374         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33375         return (uintptr_t)ret_conv;
33376 }
33377
33378 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
33379         LDKUnsignedChannelAnnouncement obj_conv;
33380         obj_conv.inner = (void*)(obj & (~1));
33381         obj_conv.is_owned = false;
33382         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33383         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
33384         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33385         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33386         CVec_u8Z_free(ret_var);
33387         return ret_arr;
33388 }
33389
33390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33391         LDKu8slice ser_ref;
33392         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33393         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33394         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
33395         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
33396         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33397         return (uintptr_t)ret_conv;
33398 }
33399
33400 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
33401         LDKChannelAnnouncement obj_conv;
33402         obj_conv.inner = (void*)(obj & (~1));
33403         obj_conv.is_owned = false;
33404         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33405         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
33406         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33407         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33408         CVec_u8Z_free(ret_var);
33409         return ret_arr;
33410 }
33411
33412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33413         LDKu8slice ser_ref;
33414         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33415         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33416         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
33417         *ret_conv = ChannelAnnouncement_read(ser_ref);
33418         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33419         return (uintptr_t)ret_conv;
33420 }
33421
33422 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
33423         LDKUnsignedChannelUpdate obj_conv;
33424         obj_conv.inner = (void*)(obj & (~1));
33425         obj_conv.is_owned = false;
33426         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33427         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
33428         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33429         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33430         CVec_u8Z_free(ret_var);
33431         return ret_arr;
33432 }
33433
33434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33435         LDKu8slice ser_ref;
33436         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33437         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33438         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
33439         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
33440         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33441         return (uintptr_t)ret_conv;
33442 }
33443
33444 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
33445         LDKChannelUpdate obj_conv;
33446         obj_conv.inner = (void*)(obj & (~1));
33447         obj_conv.is_owned = false;
33448         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33449         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
33450         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33451         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33452         CVec_u8Z_free(ret_var);
33453         return ret_arr;
33454 }
33455
33456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33457         LDKu8slice ser_ref;
33458         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33459         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33460         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
33461         *ret_conv = ChannelUpdate_read(ser_ref);
33462         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33463         return (uintptr_t)ret_conv;
33464 }
33465
33466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
33467         LDKErrorMessage obj_conv;
33468         obj_conv.inner = (void*)(obj & (~1));
33469         obj_conv.is_owned = false;
33470         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33471         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
33472         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33473         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33474         CVec_u8Z_free(ret_var);
33475         return ret_arr;
33476 }
33477
33478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33479         LDKu8slice ser_ref;
33480         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33481         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33482         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
33483         *ret_conv = ErrorMessage_read(ser_ref);
33484         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33485         return (uintptr_t)ret_conv;
33486 }
33487
33488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
33489         LDKUnsignedNodeAnnouncement obj_conv;
33490         obj_conv.inner = (void*)(obj & (~1));
33491         obj_conv.is_owned = false;
33492         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33493         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
33494         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33495         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33496         CVec_u8Z_free(ret_var);
33497         return ret_arr;
33498 }
33499
33500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33501         LDKu8slice ser_ref;
33502         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33503         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33504         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
33505         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
33506         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33507         return (uintptr_t)ret_conv;
33508 }
33509
33510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
33511         LDKNodeAnnouncement obj_conv;
33512         obj_conv.inner = (void*)(obj & (~1));
33513         obj_conv.is_owned = false;
33514         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33515         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
33516         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33517         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33518         CVec_u8Z_free(ret_var);
33519         return ret_arr;
33520 }
33521
33522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33523         LDKu8slice ser_ref;
33524         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33525         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33526         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
33527         *ret_conv = NodeAnnouncement_read(ser_ref);
33528         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33529         return (uintptr_t)ret_conv;
33530 }
33531
33532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33533         LDKu8slice ser_ref;
33534         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33535         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33536         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
33537         *ret_conv = QueryShortChannelIds_read(ser_ref);
33538         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33539         return (uintptr_t)ret_conv;
33540 }
33541
33542 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
33543         LDKQueryShortChannelIds obj_conv;
33544         obj_conv.inner = (void*)(obj & (~1));
33545         obj_conv.is_owned = false;
33546         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33547         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
33548         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33549         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33550         CVec_u8Z_free(ret_var);
33551         return ret_arr;
33552 }
33553
33554 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
33555         LDKReplyShortChannelIdsEnd obj_conv;
33556         obj_conv.inner = (void*)(obj & (~1));
33557         obj_conv.is_owned = false;
33558         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33559         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
33560         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33561         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33562         CVec_u8Z_free(ret_var);
33563         return ret_arr;
33564 }
33565
33566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33567         LDKu8slice ser_ref;
33568         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33569         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33570         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
33571         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
33572         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33573         return (uintptr_t)ret_conv;
33574 }
33575
33576 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
33577         LDKQueryChannelRange this_arg_conv;
33578         this_arg_conv.inner = (void*)(this_arg & (~1));
33579         this_arg_conv.is_owned = false;
33580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33581         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
33582         return ret_val;
33583 }
33584
33585 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
33586         LDKQueryChannelRange obj_conv;
33587         obj_conv.inner = (void*)(obj & (~1));
33588         obj_conv.is_owned = false;
33589         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33590         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
33591         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33592         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33593         CVec_u8Z_free(ret_var);
33594         return ret_arr;
33595 }
33596
33597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33598         LDKu8slice ser_ref;
33599         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33600         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33601         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
33602         *ret_conv = QueryChannelRange_read(ser_ref);
33603         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33604         return (uintptr_t)ret_conv;
33605 }
33606
33607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33608         LDKu8slice ser_ref;
33609         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33610         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33611         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
33612         *ret_conv = ReplyChannelRange_read(ser_ref);
33613         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33614         return (uintptr_t)ret_conv;
33615 }
33616
33617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
33618         LDKReplyChannelRange obj_conv;
33619         obj_conv.inner = (void*)(obj & (~1));
33620         obj_conv.is_owned = false;
33621         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33622         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
33623         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33624         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33625         CVec_u8Z_free(ret_var);
33626         return ret_arr;
33627 }
33628
33629 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
33630         LDKGossipTimestampFilter obj_conv;
33631         obj_conv.inner = (void*)(obj & (~1));
33632         obj_conv.is_owned = false;
33633         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33634         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
33635         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33636         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33637         CVec_u8Z_free(ret_var);
33638         return ret_arr;
33639 }
33640
33641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33642         LDKu8slice ser_ref;
33643         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33644         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33645         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
33646         *ret_conv = GossipTimestampFilter_read(ser_ref);
33647         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33648         return (uintptr_t)ret_conv;
33649 }
33650
33651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
33652         if ((this_ptr & 1) != 0) return;
33653         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33654         CHECK_ACCESS(this_ptr_ptr);
33655         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
33656         FREE((void*)this_ptr);
33657         CustomMessageHandler_free(this_ptr_conv);
33658 }
33659
33660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33661         LDKIgnoringMessageHandler this_obj_conv;
33662         this_obj_conv.inner = (void*)(this_obj & (~1));
33663         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33665         IgnoringMessageHandler_free(this_obj_conv);
33666 }
33667
33668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
33669         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
33670         uintptr_t ret_ref = 0;
33671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33674         ret_ref = (uintptr_t)ret_var.inner;
33675         if (ret_var.is_owned) {
33676                 ret_ref |= 1;
33677         }
33678         return ret_ref;
33679 }
33680
33681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33682         LDKIgnoringMessageHandler this_arg_conv;
33683         this_arg_conv.inner = (void*)(this_arg & (~1));
33684         this_arg_conv.is_owned = false;
33685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33686         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33687         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
33688         return (uintptr_t)ret_ret;
33689 }
33690
33691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
33692         LDKIgnoringMessageHandler this_arg_conv;
33693         this_arg_conv.inner = (void*)(this_arg & (~1));
33694         this_arg_conv.is_owned = false;
33695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33696         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
33697         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
33698         return (uintptr_t)ret_ret;
33699 }
33700
33701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
33702         LDKIgnoringMessageHandler this_arg_conv;
33703         this_arg_conv.inner = (void*)(this_arg & (~1));
33704         this_arg_conv.is_owned = false;
33705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33706         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
33707         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
33708         return (uintptr_t)ret_ret;
33709 }
33710
33711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
33712         LDKIgnoringMessageHandler this_arg_conv;
33713         this_arg_conv.inner = (void*)(this_arg & (~1));
33714         this_arg_conv.is_owned = false;
33715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33716         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
33717         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
33718         return (uintptr_t)ret_ret;
33719 }
33720
33721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33722         LDKErroringMessageHandler this_obj_conv;
33723         this_obj_conv.inner = (void*)(this_obj & (~1));
33724         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33726         ErroringMessageHandler_free(this_obj_conv);
33727 }
33728
33729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
33730         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
33731         uintptr_t ret_ref = 0;
33732         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33733         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33735         ret_ref = (uintptr_t)ret_var.inner;
33736         if (ret_var.is_owned) {
33737                 ret_ref |= 1;
33738         }
33739         return ret_ref;
33740 }
33741
33742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33743         LDKErroringMessageHandler this_arg_conv;
33744         this_arg_conv.inner = (void*)(this_arg & (~1));
33745         this_arg_conv.is_owned = false;
33746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33747         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33748         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
33749         return (uintptr_t)ret_ret;
33750 }
33751
33752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
33753         LDKErroringMessageHandler this_arg_conv;
33754         this_arg_conv.inner = (void*)(this_arg & (~1));
33755         this_arg_conv.is_owned = false;
33756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33757         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
33758         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
33759         return (uintptr_t)ret_ret;
33760 }
33761
33762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33763         LDKMessageHandler this_obj_conv;
33764         this_obj_conv.inner = (void*)(this_obj & (~1));
33765         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33767         MessageHandler_free(this_obj_conv);
33768 }
33769
33770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
33771         LDKMessageHandler this_ptr_conv;
33772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33773         this_ptr_conv.is_owned = false;
33774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33775         // WARNING: This object doesn't live past this scope, needs clone!
33776         uintptr_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
33777         return ret_ret;
33778 }
33779
33780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33781         LDKMessageHandler this_ptr_conv;
33782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33783         this_ptr_conv.is_owned = false;
33784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33785         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33786         CHECK_ACCESS(val_ptr);
33787         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
33788         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
33789                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33790                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
33791         }
33792         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
33793 }
33794
33795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
33796         LDKMessageHandler this_ptr_conv;
33797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33798         this_ptr_conv.is_owned = false;
33799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33800         // WARNING: This object doesn't live past this scope, needs clone!
33801         uintptr_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
33802         return ret_ret;
33803 }
33804
33805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33806         LDKMessageHandler this_ptr_conv;
33807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33808         this_ptr_conv.is_owned = false;
33809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33810         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33811         CHECK_ACCESS(val_ptr);
33812         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
33813         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
33814                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33815                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
33816         }
33817         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
33818 }
33819
33820 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) {
33821         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
33822         CHECK_ACCESS(chan_handler_arg_ptr);
33823         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
33824         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
33825                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33826                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
33827         }
33828         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
33829         CHECK_ACCESS(route_handler_arg_ptr);
33830         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
33831         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
33832                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33833                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
33834         }
33835         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
33836         uintptr_t ret_ref = 0;
33837         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33838         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33840         ret_ref = (uintptr_t)ret_var.inner;
33841         if (ret_var.is_owned) {
33842                 ret_ref |= 1;
33843         }
33844         return ret_ref;
33845 }
33846
33847 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
33848         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
33849         *ret_ret = SocketDescriptor_clone(arg);
33850         return (uintptr_t)ret_ret;
33851 }
33852 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33853         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
33854         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
33855         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
33856         intptr_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
33857         return ret_val;
33858 }
33859
33860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33861         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
33862         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
33863         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
33864         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
33865         *ret_ret = SocketDescriptor_clone(orig_conv);
33866         return (uintptr_t)ret_ret;
33867 }
33868
33869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
33870         if ((this_ptr & 1) != 0) return;
33871         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33872         CHECK_ACCESS(this_ptr_ptr);
33873         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
33874         FREE((void*)this_ptr);
33875         SocketDescriptor_free(this_ptr_conv);
33876 }
33877
33878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33879         LDKPeerHandleError this_obj_conv;
33880         this_obj_conv.inner = (void*)(this_obj & (~1));
33881         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33883         PeerHandleError_free(this_obj_conv);
33884 }
33885
33886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
33887         LDKPeerHandleError this_ptr_conv;
33888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33889         this_ptr_conv.is_owned = false;
33890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33891         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
33892         return ret_val;
33893 }
33894
33895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
33896         LDKPeerHandleError this_ptr_conv;
33897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33898         this_ptr_conv.is_owned = false;
33899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33900         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
33901 }
33902
33903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
33904         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
33905         uintptr_t ret_ref = 0;
33906         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33907         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33909         ret_ref = (uintptr_t)ret_var.inner;
33910         if (ret_var.is_owned) {
33911                 ret_ref |= 1;
33912         }
33913         return ret_ref;
33914 }
33915
33916 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
33917         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
33918 uintptr_t ret_ref = 0;
33919 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33920 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33921 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33922 ret_ref = (uintptr_t)ret_var.inner;
33923 if (ret_var.is_owned) {
33924         ret_ref |= 1;
33925 }
33926         return ret_ref;
33927 }
33928 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33929         LDKPeerHandleError arg_conv;
33930         arg_conv.inner = (void*)(arg & (~1));
33931         arg_conv.is_owned = false;
33932         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33933         intptr_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
33934         return ret_val;
33935 }
33936
33937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33938         LDKPeerHandleError orig_conv;
33939         orig_conv.inner = (void*)(orig & (~1));
33940         orig_conv.is_owned = false;
33941         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33942         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
33943         uintptr_t ret_ref = 0;
33944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33947         ret_ref = (uintptr_t)ret_var.inner;
33948         if (ret_var.is_owned) {
33949                 ret_ref |= 1;
33950         }
33951         return ret_ref;
33952 }
33953
33954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33955         LDKPeerManager this_obj_conv;
33956         this_obj_conv.inner = (void*)(this_obj & (~1));
33957         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33959         PeerManager_free(this_obj_conv);
33960 }
33961
33962 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, int64_t custom_message_handler) {
33963         LDKMessageHandler message_handler_conv;
33964         message_handler_conv.inner = (void*)(message_handler & (~1));
33965         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
33966         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
33967         // Warning: we need a move here but no clone is available for LDKMessageHandler
33968         LDKSecretKey our_node_secret_ref;
33969         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
33970         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
33971         unsigned char ephemeral_random_data_arr[32];
33972         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
33973         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
33974         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
33975         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
33976         CHECK_ACCESS(logger_ptr);
33977         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33978         if (logger_conv.free == LDKLogger_JCalls_free) {
33979                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33980                 LDKLogger_JCalls_cloned(&logger_conv);
33981         }
33982         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
33983         CHECK_ACCESS(custom_message_handler_ptr);
33984         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
33985         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
33986                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33987                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
33988         }
33989         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
33990         uintptr_t ret_ref = 0;
33991         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33992         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33994         ret_ref = (uintptr_t)ret_var.inner;
33995         if (ret_var.is_owned) {
33996                 ret_ref |= 1;
33997         }
33998         return ret_ref;
33999 }
34000
34001 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
34002         LDKPeerManager this_arg_conv;
34003         this_arg_conv.inner = (void*)(this_arg & (~1));
34004         this_arg_conv.is_owned = false;
34005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34006         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
34007         jobjectArray ret_arr = NULL;
34008         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
34009         ;
34010         for (size_t i = 0; i < ret_var.datalen; i++) {
34011                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
34012                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
34013                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
34014         }
34015         
34016         FREE(ret_var.data);
34017         return ret_arr;
34018 }
34019
34020 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) {
34021         LDKPeerManager this_arg_conv;
34022         this_arg_conv.inner = (void*)(this_arg & (~1));
34023         this_arg_conv.is_owned = false;
34024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34025         LDKPublicKey their_node_id_ref;
34026         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
34027         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
34028         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34029         CHECK_ACCESS(descriptor_ptr);
34030         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34031         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34032                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34033                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34034         }
34035         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
34036         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
34037         return (uintptr_t)ret_conv;
34038 }
34039
34040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
34041         LDKPeerManager this_arg_conv;
34042         this_arg_conv.inner = (void*)(this_arg & (~1));
34043         this_arg_conv.is_owned = false;
34044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34045         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34046         CHECK_ACCESS(descriptor_ptr);
34047         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34048         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34049                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34050                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34051         }
34052         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
34053         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
34054         return (uintptr_t)ret_conv;
34055 }
34056
34057 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) {
34058         LDKPeerManager this_arg_conv;
34059         this_arg_conv.inner = (void*)(this_arg & (~1));
34060         this_arg_conv.is_owned = false;
34061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34062         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34063         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
34064         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
34065         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
34066         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
34067         return (uintptr_t)ret_conv;
34068 }
34069
34070 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) {
34071         LDKPeerManager this_arg_conv;
34072         this_arg_conv.inner = (void*)(this_arg & (~1));
34073         this_arg_conv.is_owned = false;
34074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34075         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
34076         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
34077         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
34078         LDKu8slice data_ref;
34079         data_ref.datalen = (*env)->GetArrayLength(env, data);
34080         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
34081         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
34082         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
34083         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
34084         return (uintptr_t)ret_conv;
34085 }
34086
34087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
34088         LDKPeerManager this_arg_conv;
34089         this_arg_conv.inner = (void*)(this_arg & (~1));
34090         this_arg_conv.is_owned = false;
34091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34092         PeerManager_process_events(&this_arg_conv);
34093 }
34094
34095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
34096         LDKPeerManager this_arg_conv;
34097         this_arg_conv.inner = (void*)(this_arg & (~1));
34098         this_arg_conv.is_owned = false;
34099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34100         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34101         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
34102         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
34103         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
34104 }
34105
34106 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) {
34107         LDKPeerManager this_arg_conv;
34108         this_arg_conv.inner = (void*)(this_arg & (~1));
34109         this_arg_conv.is_owned = false;
34110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34111         LDKPublicKey node_id_ref;
34112         CHECK((*env)->GetArrayLength(env, node_id) == 33);
34113         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
34114         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
34115 }
34116
34117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
34118         LDKPeerManager this_arg_conv;
34119         this_arg_conv.inner = (void*)(this_arg & (~1));
34120         this_arg_conv.is_owned = false;
34121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34122         PeerManager_disconnect_all_peers(&this_arg_conv);
34123 }
34124
34125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
34126         LDKPeerManager this_arg_conv;
34127         this_arg_conv.inner = (void*)(this_arg & (~1));
34128         this_arg_conv.is_owned = false;
34129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34130         PeerManager_timer_tick_occurred(&this_arg_conv);
34131 }
34132
34133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
34134         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
34135         return ret_val;
34136 }
34137
34138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
34139         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
34140         return ret_val;
34141 }
34142
34143 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
34144         unsigned char commitment_seed_arr[32];
34145         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
34146         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
34147         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
34148         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34149         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
34150         return ret_arr;
34151 }
34152
34153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1closing_1transaction(JNIEnv *env, jclass clz, int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, int64_t funding_outpoint) {
34154         LDKCVec_u8Z to_holder_script_ref;
34155         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
34156         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
34157         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
34158         LDKCVec_u8Z to_counterparty_script_ref;
34159         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
34160         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
34161         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
34162         LDKOutPoint funding_outpoint_conv;
34163         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34164         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34166         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34167         LDKTransaction ret_var = build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
34168         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34169         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34170         Transaction_free(ret_var);
34171         return ret_arr;
34172 }
34173
34174 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) {
34175         LDKPublicKey per_commitment_point_ref;
34176         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
34177         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
34178         unsigned char base_secret_arr[32];
34179         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
34180         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
34181         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
34182         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
34183         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
34184         return (uintptr_t)ret_conv;
34185 }
34186
34187 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) {
34188         LDKPublicKey per_commitment_point_ref;
34189         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
34190         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
34191         LDKPublicKey base_point_ref;
34192         CHECK((*env)->GetArrayLength(env, base_point) == 33);
34193         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
34194         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
34195         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
34196         return (uintptr_t)ret_conv;
34197 }
34198
34199 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) {
34200         unsigned char per_commitment_secret_arr[32];
34201         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
34202         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
34203         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
34204         unsigned char countersignatory_revocation_base_secret_arr[32];
34205         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
34206         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
34207         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
34208         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
34209         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
34210         return (uintptr_t)ret_conv;
34211 }
34212
34213 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) {
34214         LDKPublicKey per_commitment_point_ref;
34215         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
34216         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
34217         LDKPublicKey countersignatory_revocation_base_point_ref;
34218         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
34219         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
34220         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
34221         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
34222         return (uintptr_t)ret_conv;
34223 }
34224
34225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34226         LDKTxCreationKeys this_obj_conv;
34227         this_obj_conv.inner = (void*)(this_obj & (~1));
34228         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34230         TxCreationKeys_free(this_obj_conv);
34231 }
34232
34233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34234         LDKTxCreationKeys this_ptr_conv;
34235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34236         this_ptr_conv.is_owned = false;
34237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34238         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34239         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
34240         return ret_arr;
34241 }
34242
34243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34244         LDKTxCreationKeys this_ptr_conv;
34245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34246         this_ptr_conv.is_owned = false;
34247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34248         LDKPublicKey val_ref;
34249         CHECK((*env)->GetArrayLength(env, val) == 33);
34250         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34251         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
34252 }
34253
34254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
34255         LDKTxCreationKeys this_ptr_conv;
34256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34257         this_ptr_conv.is_owned = false;
34258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34259         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34260         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
34261         return ret_arr;
34262 }
34263
34264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34265         LDKTxCreationKeys this_ptr_conv;
34266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34267         this_ptr_conv.is_owned = false;
34268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34269         LDKPublicKey val_ref;
34270         CHECK((*env)->GetArrayLength(env, val) == 33);
34271         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34272         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
34273 }
34274
34275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
34276         LDKTxCreationKeys this_ptr_conv;
34277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34278         this_ptr_conv.is_owned = false;
34279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34280         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34281         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
34282         return ret_arr;
34283 }
34284
34285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34286         LDKTxCreationKeys this_ptr_conv;
34287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34288         this_ptr_conv.is_owned = false;
34289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34290         LDKPublicKey val_ref;
34291         CHECK((*env)->GetArrayLength(env, val) == 33);
34292         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34293         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
34294 }
34295
34296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
34297         LDKTxCreationKeys this_ptr_conv;
34298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34299         this_ptr_conv.is_owned = false;
34300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34301         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34302         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
34303         return ret_arr;
34304 }
34305
34306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34307         LDKTxCreationKeys this_ptr_conv;
34308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34309         this_ptr_conv.is_owned = false;
34310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34311         LDKPublicKey val_ref;
34312         CHECK((*env)->GetArrayLength(env, val) == 33);
34313         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34314         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
34315 }
34316
34317 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
34318         LDKTxCreationKeys this_ptr_conv;
34319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34320         this_ptr_conv.is_owned = false;
34321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34322         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34323         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
34324         return ret_arr;
34325 }
34326
34327 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) {
34328         LDKTxCreationKeys this_ptr_conv;
34329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34330         this_ptr_conv.is_owned = false;
34331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34332         LDKPublicKey val_ref;
34333         CHECK((*env)->GetArrayLength(env, val) == 33);
34334         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34335         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
34336 }
34337
34338 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) {
34339         LDKPublicKey per_commitment_point_arg_ref;
34340         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
34341         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
34342         LDKPublicKey revocation_key_arg_ref;
34343         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
34344         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
34345         LDKPublicKey broadcaster_htlc_key_arg_ref;
34346         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
34347         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
34348         LDKPublicKey countersignatory_htlc_key_arg_ref;
34349         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
34350         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
34351         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
34352         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
34353         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
34354         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);
34355         uintptr_t ret_ref = 0;
34356         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34357         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34359         ret_ref = (uintptr_t)ret_var.inner;
34360         if (ret_var.is_owned) {
34361                 ret_ref |= 1;
34362         }
34363         return ret_ref;
34364 }
34365
34366 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
34367         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
34368 uintptr_t ret_ref = 0;
34369 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34370 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34371 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34372 ret_ref = (uintptr_t)ret_var.inner;
34373 if (ret_var.is_owned) {
34374         ret_ref |= 1;
34375 }
34376         return ret_ref;
34377 }
34378 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34379         LDKTxCreationKeys arg_conv;
34380         arg_conv.inner = (void*)(arg & (~1));
34381         arg_conv.is_owned = false;
34382         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34383         intptr_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
34384         return ret_val;
34385 }
34386
34387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34388         LDKTxCreationKeys orig_conv;
34389         orig_conv.inner = (void*)(orig & (~1));
34390         orig_conv.is_owned = false;
34391         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34392         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
34393         uintptr_t ret_ref = 0;
34394         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34395         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34396         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34397         ret_ref = (uintptr_t)ret_var.inner;
34398         if (ret_var.is_owned) {
34399                 ret_ref |= 1;
34400         }
34401         return ret_ref;
34402 }
34403
34404 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
34405         LDKTxCreationKeys obj_conv;
34406         obj_conv.inner = (void*)(obj & (~1));
34407         obj_conv.is_owned = false;
34408         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34409         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
34410         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34411         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34412         CVec_u8Z_free(ret_var);
34413         return ret_arr;
34414 }
34415
34416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34417         LDKu8slice ser_ref;
34418         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34419         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34420         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
34421         *ret_conv = TxCreationKeys_read(ser_ref);
34422         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34423         return (uintptr_t)ret_conv;
34424 }
34425
34426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34427         LDKChannelPublicKeys this_obj_conv;
34428         this_obj_conv.inner = (void*)(this_obj & (~1));
34429         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34431         ChannelPublicKeys_free(this_obj_conv);
34432 }
34433
34434 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
34435         LDKChannelPublicKeys this_ptr_conv;
34436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34437         this_ptr_conv.is_owned = false;
34438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34439         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34440         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
34441         return ret_arr;
34442 }
34443
34444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34445         LDKChannelPublicKeys this_ptr_conv;
34446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34447         this_ptr_conv.is_owned = false;
34448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34449         LDKPublicKey val_ref;
34450         CHECK((*env)->GetArrayLength(env, val) == 33);
34451         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34452         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
34453 }
34454
34455 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34456         LDKChannelPublicKeys this_ptr_conv;
34457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34458         this_ptr_conv.is_owned = false;
34459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34460         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34461         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
34462         return ret_arr;
34463 }
34464
34465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34466         LDKChannelPublicKeys this_ptr_conv;
34467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34468         this_ptr_conv.is_owned = false;
34469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34470         LDKPublicKey val_ref;
34471         CHECK((*env)->GetArrayLength(env, val) == 33);
34472         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34473         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
34474 }
34475
34476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34477         LDKChannelPublicKeys this_ptr_conv;
34478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34479         this_ptr_conv.is_owned = false;
34480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34481         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34482         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
34483         return ret_arr;
34484 }
34485
34486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34487         LDKChannelPublicKeys this_ptr_conv;
34488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34489         this_ptr_conv.is_owned = false;
34490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34491         LDKPublicKey val_ref;
34492         CHECK((*env)->GetArrayLength(env, val) == 33);
34493         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34494         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
34495 }
34496
34497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34498         LDKChannelPublicKeys this_ptr_conv;
34499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34500         this_ptr_conv.is_owned = false;
34501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34502         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34503         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
34504         return ret_arr;
34505 }
34506
34507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34508         LDKChannelPublicKeys this_ptr_conv;
34509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34510         this_ptr_conv.is_owned = false;
34511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34512         LDKPublicKey val_ref;
34513         CHECK((*env)->GetArrayLength(env, val) == 33);
34514         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34515         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
34516 }
34517
34518 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34519         LDKChannelPublicKeys this_ptr_conv;
34520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34521         this_ptr_conv.is_owned = false;
34522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34523         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34524         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
34525         return ret_arr;
34526 }
34527
34528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34529         LDKChannelPublicKeys this_ptr_conv;
34530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34531         this_ptr_conv.is_owned = false;
34532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34533         LDKPublicKey val_ref;
34534         CHECK((*env)->GetArrayLength(env, val) == 33);
34535         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34536         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
34537 }
34538
34539 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) {
34540         LDKPublicKey funding_pubkey_arg_ref;
34541         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
34542         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
34543         LDKPublicKey revocation_basepoint_arg_ref;
34544         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
34545         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
34546         LDKPublicKey payment_point_arg_ref;
34547         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
34548         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
34549         LDKPublicKey delayed_payment_basepoint_arg_ref;
34550         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
34551         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
34552         LDKPublicKey htlc_basepoint_arg_ref;
34553         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
34554         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
34555         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);
34556         uintptr_t ret_ref = 0;
34557         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34558         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34560         ret_ref = (uintptr_t)ret_var.inner;
34561         if (ret_var.is_owned) {
34562                 ret_ref |= 1;
34563         }
34564         return ret_ref;
34565 }
34566
34567 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
34568         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
34569 uintptr_t ret_ref = 0;
34570 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34571 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34572 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34573 ret_ref = (uintptr_t)ret_var.inner;
34574 if (ret_var.is_owned) {
34575         ret_ref |= 1;
34576 }
34577         return ret_ref;
34578 }
34579 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34580         LDKChannelPublicKeys arg_conv;
34581         arg_conv.inner = (void*)(arg & (~1));
34582         arg_conv.is_owned = false;
34583         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34584         intptr_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
34585         return ret_val;
34586 }
34587
34588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34589         LDKChannelPublicKeys orig_conv;
34590         orig_conv.inner = (void*)(orig & (~1));
34591         orig_conv.is_owned = false;
34592         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34593         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
34594         uintptr_t ret_ref = 0;
34595         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34596         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34598         ret_ref = (uintptr_t)ret_var.inner;
34599         if (ret_var.is_owned) {
34600                 ret_ref |= 1;
34601         }
34602         return ret_ref;
34603 }
34604
34605 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
34606         LDKChannelPublicKeys obj_conv;
34607         obj_conv.inner = (void*)(obj & (~1));
34608         obj_conv.is_owned = false;
34609         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34610         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
34611         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34612         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34613         CVec_u8Z_free(ret_var);
34614         return ret_arr;
34615 }
34616
34617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34618         LDKu8slice ser_ref;
34619         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34620         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34621         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
34622         *ret_conv = ChannelPublicKeys_read(ser_ref);
34623         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34624         return (uintptr_t)ret_conv;
34625 }
34626
34627 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) {
34628         LDKPublicKey per_commitment_point_ref;
34629         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
34630         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
34631         LDKPublicKey broadcaster_delayed_payment_base_ref;
34632         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
34633         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
34634         LDKPublicKey broadcaster_htlc_base_ref;
34635         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
34636         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
34637         LDKPublicKey countersignatory_revocation_base_ref;
34638         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
34639         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
34640         LDKPublicKey countersignatory_htlc_base_ref;
34641         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
34642         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
34643         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
34644         *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);
34645         return (uintptr_t)ret_conv;
34646 }
34647
34648 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) {
34649         LDKPublicKey per_commitment_point_ref;
34650         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
34651         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
34652         LDKChannelPublicKeys broadcaster_keys_conv;
34653         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
34654         broadcaster_keys_conv.is_owned = false;
34655         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
34656         LDKChannelPublicKeys countersignatory_keys_conv;
34657         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
34658         countersignatory_keys_conv.is_owned = false;
34659         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
34660         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
34661         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
34662         return (uintptr_t)ret_conv;
34663 }
34664
34665 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) {
34666         LDKPublicKey revocation_key_ref;
34667         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
34668         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
34669         LDKPublicKey broadcaster_delayed_payment_key_ref;
34670         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
34671         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
34672         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
34673         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34674         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34675         CVec_u8Z_free(ret_var);
34676         return ret_arr;
34677 }
34678
34679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34680         LDKHTLCOutputInCommitment this_obj_conv;
34681         this_obj_conv.inner = (void*)(this_obj & (~1));
34682         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34684         HTLCOutputInCommitment_free(this_obj_conv);
34685 }
34686
34687 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
34688         LDKHTLCOutputInCommitment this_ptr_conv;
34689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34690         this_ptr_conv.is_owned = false;
34691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34692         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
34693         return ret_val;
34694 }
34695
34696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
34697         LDKHTLCOutputInCommitment this_ptr_conv;
34698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34699         this_ptr_conv.is_owned = false;
34700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34701         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
34702 }
34703
34704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34705         LDKHTLCOutputInCommitment this_ptr_conv;
34706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34707         this_ptr_conv.is_owned = false;
34708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34709         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
34710         return ret_val;
34711 }
34712
34713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34714         LDKHTLCOutputInCommitment this_ptr_conv;
34715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34716         this_ptr_conv.is_owned = false;
34717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34718         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
34719 }
34720
34721 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
34722         LDKHTLCOutputInCommitment this_ptr_conv;
34723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34724         this_ptr_conv.is_owned = false;
34725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34726         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
34727         return ret_val;
34728 }
34729
34730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34731         LDKHTLCOutputInCommitment this_ptr_conv;
34732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34733         this_ptr_conv.is_owned = false;
34734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34735         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
34736 }
34737
34738 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34739         LDKHTLCOutputInCommitment this_ptr_conv;
34740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34741         this_ptr_conv.is_owned = false;
34742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34743         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34744         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
34745         return ret_arr;
34746 }
34747
34748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34749         LDKHTLCOutputInCommitment this_ptr_conv;
34750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34751         this_ptr_conv.is_owned = false;
34752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34753         LDKThirtyTwoBytes val_ref;
34754         CHECK((*env)->GetArrayLength(env, val) == 32);
34755         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34756         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
34757 }
34758
34759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
34760         LDKHTLCOutputInCommitment this_ptr_conv;
34761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34762         this_ptr_conv.is_owned = false;
34763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34764         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
34765         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
34766         uintptr_t ret_ref = (uintptr_t)ret_copy;
34767         return ret_ref;
34768 }
34769
34770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34771         LDKHTLCOutputInCommitment this_ptr_conv;
34772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34773         this_ptr_conv.is_owned = false;
34774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34775         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34776         CHECK_ACCESS(val_ptr);
34777         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
34778         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
34779         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
34780 }
34781
34782 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) {
34783         LDKThirtyTwoBytes payment_hash_arg_ref;
34784         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
34785         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
34786         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
34787         CHECK_ACCESS(transaction_output_index_arg_ptr);
34788         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
34789         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
34790         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
34791         uintptr_t ret_ref = 0;
34792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34795         ret_ref = (uintptr_t)ret_var.inner;
34796         if (ret_var.is_owned) {
34797                 ret_ref |= 1;
34798         }
34799         return ret_ref;
34800 }
34801
34802 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
34803         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
34804 uintptr_t ret_ref = 0;
34805 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34806 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34807 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34808 ret_ref = (uintptr_t)ret_var.inner;
34809 if (ret_var.is_owned) {
34810         ret_ref |= 1;
34811 }
34812         return ret_ref;
34813 }
34814 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34815         LDKHTLCOutputInCommitment arg_conv;
34816         arg_conv.inner = (void*)(arg & (~1));
34817         arg_conv.is_owned = false;
34818         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34819         intptr_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
34820         return ret_val;
34821 }
34822
34823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34824         LDKHTLCOutputInCommitment orig_conv;
34825         orig_conv.inner = (void*)(orig & (~1));
34826         orig_conv.is_owned = false;
34827         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34828         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
34829         uintptr_t ret_ref = 0;
34830         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34831         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34833         ret_ref = (uintptr_t)ret_var.inner;
34834         if (ret_var.is_owned) {
34835                 ret_ref |= 1;
34836         }
34837         return ret_ref;
34838 }
34839
34840 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
34841         LDKHTLCOutputInCommitment obj_conv;
34842         obj_conv.inner = (void*)(obj & (~1));
34843         obj_conv.is_owned = false;
34844         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34845         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
34846         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34847         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34848         CVec_u8Z_free(ret_var);
34849         return ret_arr;
34850 }
34851
34852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34853         LDKu8slice ser_ref;
34854         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34855         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34856         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
34857         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
34858         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34859         return (uintptr_t)ret_conv;
34860 }
34861
34862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, jboolean opt_anchors, int64_t keys) {
34863         LDKHTLCOutputInCommitment htlc_conv;
34864         htlc_conv.inner = (void*)(htlc & (~1));
34865         htlc_conv.is_owned = false;
34866         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
34867         LDKTxCreationKeys keys_conv;
34868         keys_conv.inner = (void*)(keys & (~1));
34869         keys_conv.is_owned = false;
34870         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
34871         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
34872         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34873         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34874         CVec_u8Z_free(ret_var);
34875         return ret_arr;
34876 }
34877
34878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
34879         LDKPublicKey broadcaster_ref;
34880         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
34881         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
34882         LDKPublicKey countersignatory_ref;
34883         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
34884         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
34885         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
34886         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34887         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34888         CVec_u8Z_free(ret_var);
34889         return ret_arr;
34890 }
34891
34892 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, jboolean opt_anchors, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
34893         unsigned char commitment_txid_arr[32];
34894         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
34895         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
34896         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
34897         LDKHTLCOutputInCommitment htlc_conv;
34898         htlc_conv.inner = (void*)(htlc & (~1));
34899         htlc_conv.is_owned = false;
34900         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
34901         LDKPublicKey broadcaster_delayed_payment_key_ref;
34902         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
34903         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
34904         LDKPublicKey revocation_key_ref;
34905         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
34906         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
34907         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, opt_anchors, broadcaster_delayed_payment_key_ref, revocation_key_ref);
34908         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34909         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34910         Transaction_free(ret_var);
34911         return ret_arr;
34912 }
34913
34914 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
34915         LDKPublicKey funding_pubkey_ref;
34916         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
34917         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
34918         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
34919         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34920         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34921         CVec_u8Z_free(ret_var);
34922         return ret_arr;
34923 }
34924
34925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34926         LDKChannelTransactionParameters this_obj_conv;
34927         this_obj_conv.inner = (void*)(this_obj & (~1));
34928         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34930         ChannelTransactionParameters_free(this_obj_conv);
34931 }
34932
34933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
34934         LDKChannelTransactionParameters this_ptr_conv;
34935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34936         this_ptr_conv.is_owned = false;
34937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34938         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
34939         uintptr_t ret_ref = 0;
34940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34943         ret_ref = (uintptr_t)ret_var.inner;
34944         if (ret_var.is_owned) {
34945                 ret_ref |= 1;
34946         }
34947         return ret_ref;
34948 }
34949
34950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34951         LDKChannelTransactionParameters this_ptr_conv;
34952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34953         this_ptr_conv.is_owned = false;
34954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34955         LDKChannelPublicKeys val_conv;
34956         val_conv.inner = (void*)(val & (~1));
34957         val_conv.is_owned = (val & 1) || (val == 0);
34958         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34959         val_conv = ChannelPublicKeys_clone(&val_conv);
34960         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
34961 }
34962
34963 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
34964         LDKChannelTransactionParameters this_ptr_conv;
34965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34966         this_ptr_conv.is_owned = false;
34967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34968         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
34969         return ret_val;
34970 }
34971
34972 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) {
34973         LDKChannelTransactionParameters this_ptr_conv;
34974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34975         this_ptr_conv.is_owned = false;
34976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34977         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
34978 }
34979
34980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
34981         LDKChannelTransactionParameters this_ptr_conv;
34982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34983         this_ptr_conv.is_owned = false;
34984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34985         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
34986         return ret_val;
34987 }
34988
34989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
34990         LDKChannelTransactionParameters this_ptr_conv;
34991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34992         this_ptr_conv.is_owned = false;
34993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34994         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
34995 }
34996
34997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
34998         LDKChannelTransactionParameters this_ptr_conv;
34999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35000         this_ptr_conv.is_owned = false;
35001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35002         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
35003         uintptr_t ret_ref = 0;
35004         if ((uintptr_t)ret_var.inner > 4096) {
35005                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35006                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35008                 ret_ref = (uintptr_t)ret_var.inner;
35009                 if (ret_var.is_owned) {
35010                         ret_ref |= 1;
35011                 }
35012         }
35013         return ret_ref;
35014 }
35015
35016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35017         LDKChannelTransactionParameters this_ptr_conv;
35018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35019         this_ptr_conv.is_owned = false;
35020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35021         LDKCounterpartyChannelTransactionParameters val_conv;
35022         val_conv.inner = (void*)(val & (~1));
35023         val_conv.is_owned = (val & 1) || (val == 0);
35024         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35025         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
35026         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
35027 }
35028
35029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35030         LDKChannelTransactionParameters this_ptr_conv;
35031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35032         this_ptr_conv.is_owned = false;
35033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35034         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
35035         uintptr_t ret_ref = 0;
35036         if ((uintptr_t)ret_var.inner > 4096) {
35037                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35038                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35040                 ret_ref = (uintptr_t)ret_var.inner;
35041                 if (ret_var.is_owned) {
35042                         ret_ref |= 1;
35043                 }
35044         }
35045         return ret_ref;
35046 }
35047
35048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35049         LDKChannelTransactionParameters this_ptr_conv;
35050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35051         this_ptr_conv.is_owned = false;
35052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35053         LDKOutPoint val_conv;
35054         val_conv.inner = (void*)(val & (~1));
35055         val_conv.is_owned = (val & 1) || (val == 0);
35056         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35057         val_conv = OutPoint_clone(&val_conv);
35058         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
35059 }
35060
35061 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
35062         LDKChannelTransactionParameters this_ptr_conv;
35063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35064         this_ptr_conv.is_owned = false;
35065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35066         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
35067         return ret_conv;
35068 }
35069
35070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
35071         LDKChannelTransactionParameters this_ptr_conv;
35072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35073         this_ptr_conv.is_owned = false;
35074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35075         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
35076         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
35077 }
35078
35079 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, jclass opt_anchors_arg) {
35080         LDKChannelPublicKeys holder_pubkeys_arg_conv;
35081         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
35082         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
35083         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
35084         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
35085         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
35086         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
35087         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
35088         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
35089         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
35090         LDKOutPoint funding_outpoint_arg_conv;
35091         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
35092         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
35093         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
35094         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
35095         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
35096         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, opt_anchors_arg_conv);
35097         uintptr_t ret_ref = 0;
35098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35101         ret_ref = (uintptr_t)ret_var.inner;
35102         if (ret_var.is_owned) {
35103                 ret_ref |= 1;
35104         }
35105         return ret_ref;
35106 }
35107
35108 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
35109         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
35110 uintptr_t ret_ref = 0;
35111 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35112 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35113 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35114 ret_ref = (uintptr_t)ret_var.inner;
35115 if (ret_var.is_owned) {
35116         ret_ref |= 1;
35117 }
35118         return ret_ref;
35119 }
35120 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35121         LDKChannelTransactionParameters arg_conv;
35122         arg_conv.inner = (void*)(arg & (~1));
35123         arg_conv.is_owned = false;
35124         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35125         intptr_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
35126         return ret_val;
35127 }
35128
35129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35130         LDKChannelTransactionParameters orig_conv;
35131         orig_conv.inner = (void*)(orig & (~1));
35132         orig_conv.is_owned = false;
35133         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35134         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
35135         uintptr_t ret_ref = 0;
35136         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35137         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35139         ret_ref = (uintptr_t)ret_var.inner;
35140         if (ret_var.is_owned) {
35141                 ret_ref |= 1;
35142         }
35143         return ret_ref;
35144 }
35145
35146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35147         LDKCounterpartyChannelTransactionParameters this_obj_conv;
35148         this_obj_conv.inner = (void*)(this_obj & (~1));
35149         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35151         CounterpartyChannelTransactionParameters_free(this_obj_conv);
35152 }
35153
35154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
35155         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
35156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35157         this_ptr_conv.is_owned = false;
35158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35159         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
35160         uintptr_t ret_ref = 0;
35161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35164         ret_ref = (uintptr_t)ret_var.inner;
35165         if (ret_var.is_owned) {
35166                 ret_ref |= 1;
35167         }
35168         return ret_ref;
35169 }
35170
35171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35172         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
35173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35174         this_ptr_conv.is_owned = false;
35175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35176         LDKChannelPublicKeys val_conv;
35177         val_conv.inner = (void*)(val & (~1));
35178         val_conv.is_owned = (val & 1) || (val == 0);
35179         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35180         val_conv = ChannelPublicKeys_clone(&val_conv);
35181         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
35182 }
35183
35184 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
35185         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
35186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35187         this_ptr_conv.is_owned = false;
35188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35189         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
35190         return ret_val;
35191 }
35192
35193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35194         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
35195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35196         this_ptr_conv.is_owned = false;
35197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35198         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
35199 }
35200
35201 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) {
35202         LDKChannelPublicKeys pubkeys_arg_conv;
35203         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
35204         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
35205         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
35206         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
35207         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
35208         uintptr_t ret_ref = 0;
35209         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35210         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35212         ret_ref = (uintptr_t)ret_var.inner;
35213         if (ret_var.is_owned) {
35214                 ret_ref |= 1;
35215         }
35216         return ret_ref;
35217 }
35218
35219 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
35220         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
35221 uintptr_t ret_ref = 0;
35222 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35223 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35224 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35225 ret_ref = (uintptr_t)ret_var.inner;
35226 if (ret_var.is_owned) {
35227         ret_ref |= 1;
35228 }
35229         return ret_ref;
35230 }
35231 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35232         LDKCounterpartyChannelTransactionParameters arg_conv;
35233         arg_conv.inner = (void*)(arg & (~1));
35234         arg_conv.is_owned = false;
35235         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35236         intptr_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
35237         return ret_val;
35238 }
35239
35240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35241         LDKCounterpartyChannelTransactionParameters orig_conv;
35242         orig_conv.inner = (void*)(orig & (~1));
35243         orig_conv.is_owned = false;
35244         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35245         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
35246         uintptr_t ret_ref = 0;
35247         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35248         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35250         ret_ref = (uintptr_t)ret_var.inner;
35251         if (ret_var.is_owned) {
35252                 ret_ref |= 1;
35253         }
35254         return ret_ref;
35255 }
35256
35257 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
35258         LDKChannelTransactionParameters this_arg_conv;
35259         this_arg_conv.inner = (void*)(this_arg & (~1));
35260         this_arg_conv.is_owned = false;
35261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35262         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
35263         return ret_val;
35264 }
35265
35266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
35267         LDKChannelTransactionParameters this_arg_conv;
35268         this_arg_conv.inner = (void*)(this_arg & (~1));
35269         this_arg_conv.is_owned = false;
35270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35271         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
35272         uintptr_t ret_ref = 0;
35273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35276         ret_ref = (uintptr_t)ret_var.inner;
35277         if (ret_var.is_owned) {
35278                 ret_ref |= 1;
35279         }
35280         return ret_ref;
35281 }
35282
35283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
35284         LDKChannelTransactionParameters this_arg_conv;
35285         this_arg_conv.inner = (void*)(this_arg & (~1));
35286         this_arg_conv.is_owned = false;
35287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35288         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
35289         uintptr_t ret_ref = 0;
35290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35293         ret_ref = (uintptr_t)ret_var.inner;
35294         if (ret_var.is_owned) {
35295                 ret_ref |= 1;
35296         }
35297         return ret_ref;
35298 }
35299
35300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
35301         LDKCounterpartyChannelTransactionParameters obj_conv;
35302         obj_conv.inner = (void*)(obj & (~1));
35303         obj_conv.is_owned = false;
35304         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35305         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
35306         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35307         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35308         CVec_u8Z_free(ret_var);
35309         return ret_arr;
35310 }
35311
35312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35313         LDKu8slice ser_ref;
35314         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35315         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35316         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
35317         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
35318         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35319         return (uintptr_t)ret_conv;
35320 }
35321
35322 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
35323         LDKChannelTransactionParameters obj_conv;
35324         obj_conv.inner = (void*)(obj & (~1));
35325         obj_conv.is_owned = false;
35326         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35327         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
35328         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35329         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35330         CVec_u8Z_free(ret_var);
35331         return ret_arr;
35332 }
35333
35334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35335         LDKu8slice ser_ref;
35336         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35337         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35338         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
35339         *ret_conv = ChannelTransactionParameters_read(ser_ref);
35340         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35341         return (uintptr_t)ret_conv;
35342 }
35343
35344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35345         LDKDirectedChannelTransactionParameters this_obj_conv;
35346         this_obj_conv.inner = (void*)(this_obj & (~1));
35347         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35349         DirectedChannelTransactionParameters_free(this_obj_conv);
35350 }
35351
35352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
35353         LDKDirectedChannelTransactionParameters this_arg_conv;
35354         this_arg_conv.inner = (void*)(this_arg & (~1));
35355         this_arg_conv.is_owned = false;
35356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35357         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
35358         uintptr_t ret_ref = 0;
35359         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35360         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35362         ret_ref = (uintptr_t)ret_var.inner;
35363         if (ret_var.is_owned) {
35364                 ret_ref |= 1;
35365         }
35366         return ret_ref;
35367 }
35368
35369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
35370         LDKDirectedChannelTransactionParameters this_arg_conv;
35371         this_arg_conv.inner = (void*)(this_arg & (~1));
35372         this_arg_conv.is_owned = false;
35373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35374         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
35375         uintptr_t ret_ref = 0;
35376         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35377         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35379         ret_ref = (uintptr_t)ret_var.inner;
35380         if (ret_var.is_owned) {
35381                 ret_ref |= 1;
35382         }
35383         return ret_ref;
35384 }
35385
35386 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
35387         LDKDirectedChannelTransactionParameters this_arg_conv;
35388         this_arg_conv.inner = (void*)(this_arg & (~1));
35389         this_arg_conv.is_owned = false;
35390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35391         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
35392         return ret_val;
35393 }
35394
35395 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
35396         LDKDirectedChannelTransactionParameters this_arg_conv;
35397         this_arg_conv.inner = (void*)(this_arg & (~1));
35398         this_arg_conv.is_owned = false;
35399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35400         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
35401         return ret_val;
35402 }
35403
35404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
35405         LDKDirectedChannelTransactionParameters this_arg_conv;
35406         this_arg_conv.inner = (void*)(this_arg & (~1));
35407         this_arg_conv.is_owned = false;
35408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35409         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
35410         uintptr_t ret_ref = 0;
35411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35414         ret_ref = (uintptr_t)ret_var.inner;
35415         if (ret_var.is_owned) {
35416                 ret_ref |= 1;
35417         }
35418         return ret_ref;
35419 }
35420
35421 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
35422         LDKDirectedChannelTransactionParameters this_arg_conv;
35423         this_arg_conv.inner = (void*)(this_arg & (~1));
35424         this_arg_conv.is_owned = false;
35425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35426         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
35427         return ret_val;
35428 }
35429
35430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35431         LDKHolderCommitmentTransaction this_obj_conv;
35432         this_obj_conv.inner = (void*)(this_obj & (~1));
35433         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35435         HolderCommitmentTransaction_free(this_obj_conv);
35436 }
35437
35438 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
35439         LDKHolderCommitmentTransaction this_ptr_conv;
35440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35441         this_ptr_conv.is_owned = false;
35442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35443         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35444         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
35445         return ret_arr;
35446 }
35447
35448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35449         LDKHolderCommitmentTransaction this_ptr_conv;
35450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35451         this_ptr_conv.is_owned = false;
35452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35453         LDKSignature val_ref;
35454         CHECK((*env)->GetArrayLength(env, val) == 64);
35455         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35456         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
35457 }
35458
35459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
35460         LDKHolderCommitmentTransaction this_ptr_conv;
35461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35462         this_ptr_conv.is_owned = false;
35463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35464         LDKCVec_SignatureZ val_constr;
35465         val_constr.datalen = (*env)->GetArrayLength(env, val);
35466         if (val_constr.datalen > 0)
35467                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
35468         else
35469                 val_constr.data = NULL;
35470         for (size_t i = 0; i < val_constr.datalen; i++) {
35471                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
35472                 LDKSignature val_conv_8_ref;
35473                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
35474                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
35475                 val_constr.data[i] = val_conv_8_ref;
35476         }
35477         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
35478 }
35479
35480 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
35481         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
35482 uintptr_t ret_ref = 0;
35483 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35484 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35485 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35486 ret_ref = (uintptr_t)ret_var.inner;
35487 if (ret_var.is_owned) {
35488         ret_ref |= 1;
35489 }
35490         return ret_ref;
35491 }
35492 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35493         LDKHolderCommitmentTransaction arg_conv;
35494         arg_conv.inner = (void*)(arg & (~1));
35495         arg_conv.is_owned = false;
35496         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35497         intptr_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
35498         return ret_val;
35499 }
35500
35501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35502         LDKHolderCommitmentTransaction orig_conv;
35503         orig_conv.inner = (void*)(orig & (~1));
35504         orig_conv.is_owned = false;
35505         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35506         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
35507         uintptr_t ret_ref = 0;
35508         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35509         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35511         ret_ref = (uintptr_t)ret_var.inner;
35512         if (ret_var.is_owned) {
35513                 ret_ref |= 1;
35514         }
35515         return ret_ref;
35516 }
35517
35518 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
35519         LDKHolderCommitmentTransaction obj_conv;
35520         obj_conv.inner = (void*)(obj & (~1));
35521         obj_conv.is_owned = false;
35522         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35523         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
35524         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35525         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35526         CVec_u8Z_free(ret_var);
35527         return ret_arr;
35528 }
35529
35530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35531         LDKu8slice ser_ref;
35532         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35533         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35534         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
35535         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
35536         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35537         return (uintptr_t)ret_conv;
35538 }
35539
35540 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) {
35541         LDKCommitmentTransaction commitment_tx_conv;
35542         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
35543         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
35544         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
35545         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
35546         LDKSignature counterparty_sig_ref;
35547         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
35548         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
35549         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
35550         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
35551         if (counterparty_htlc_sigs_constr.datalen > 0)
35552                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
35553         else
35554                 counterparty_htlc_sigs_constr.data = NULL;
35555         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
35556                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
35557                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
35558                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
35559                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
35560                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
35561         }
35562         LDKPublicKey holder_funding_key_ref;
35563         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
35564         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
35565         LDKPublicKey counterparty_funding_key_ref;
35566         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
35567         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
35568         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
35569         uintptr_t ret_ref = 0;
35570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35573         ret_ref = (uintptr_t)ret_var.inner;
35574         if (ret_var.is_owned) {
35575                 ret_ref |= 1;
35576         }
35577         return ret_ref;
35578 }
35579
35580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35581         LDKBuiltCommitmentTransaction this_obj_conv;
35582         this_obj_conv.inner = (void*)(this_obj & (~1));
35583         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35585         BuiltCommitmentTransaction_free(this_obj_conv);
35586 }
35587
35588 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
35589         LDKBuiltCommitmentTransaction this_ptr_conv;
35590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35591         this_ptr_conv.is_owned = false;
35592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35593         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
35594         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35595         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35596         Transaction_free(ret_var);
35597         return ret_arr;
35598 }
35599
35600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35601         LDKBuiltCommitmentTransaction this_ptr_conv;
35602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35603         this_ptr_conv.is_owned = false;
35604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35605         LDKTransaction val_ref;
35606         val_ref.datalen = (*env)->GetArrayLength(env, val);
35607         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
35608         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
35609         val_ref.data_is_owned = true;
35610         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
35611 }
35612
35613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
35614         LDKBuiltCommitmentTransaction this_ptr_conv;
35615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35616         this_ptr_conv.is_owned = false;
35617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35618         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35619         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
35620         return ret_arr;
35621 }
35622
35623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35624         LDKBuiltCommitmentTransaction this_ptr_conv;
35625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35626         this_ptr_conv.is_owned = false;
35627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35628         LDKThirtyTwoBytes val_ref;
35629         CHECK((*env)->GetArrayLength(env, val) == 32);
35630         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35631         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
35632 }
35633
35634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
35635         LDKTransaction transaction_arg_ref;
35636         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
35637         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
35638         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
35639         transaction_arg_ref.data_is_owned = true;
35640         LDKThirtyTwoBytes txid_arg_ref;
35641         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
35642         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
35643         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
35644         uintptr_t ret_ref = 0;
35645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35648         ret_ref = (uintptr_t)ret_var.inner;
35649         if (ret_var.is_owned) {
35650                 ret_ref |= 1;
35651         }
35652         return ret_ref;
35653 }
35654
35655 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
35656         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
35657 uintptr_t ret_ref = 0;
35658 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35659 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35660 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35661 ret_ref = (uintptr_t)ret_var.inner;
35662 if (ret_var.is_owned) {
35663         ret_ref |= 1;
35664 }
35665         return ret_ref;
35666 }
35667 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35668         LDKBuiltCommitmentTransaction arg_conv;
35669         arg_conv.inner = (void*)(arg & (~1));
35670         arg_conv.is_owned = false;
35671         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35672         intptr_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
35673         return ret_val;
35674 }
35675
35676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35677         LDKBuiltCommitmentTransaction orig_conv;
35678         orig_conv.inner = (void*)(orig & (~1));
35679         orig_conv.is_owned = false;
35680         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35681         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
35682         uintptr_t ret_ref = 0;
35683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35686         ret_ref = (uintptr_t)ret_var.inner;
35687         if (ret_var.is_owned) {
35688                 ret_ref |= 1;
35689         }
35690         return ret_ref;
35691 }
35692
35693 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
35694         LDKBuiltCommitmentTransaction obj_conv;
35695         obj_conv.inner = (void*)(obj & (~1));
35696         obj_conv.is_owned = false;
35697         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35698         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
35699         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35700         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35701         CVec_u8Z_free(ret_var);
35702         return ret_arr;
35703 }
35704
35705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35706         LDKu8slice ser_ref;
35707         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35708         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35709         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
35710         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
35711         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35712         return (uintptr_t)ret_conv;
35713 }
35714
35715 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) {
35716         LDKBuiltCommitmentTransaction this_arg_conv;
35717         this_arg_conv.inner = (void*)(this_arg & (~1));
35718         this_arg_conv.is_owned = false;
35719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35720         LDKu8slice funding_redeemscript_ref;
35721         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
35722         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
35723         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35724         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
35725         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
35726         return ret_arr;
35727 }
35728
35729 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) {
35730         LDKBuiltCommitmentTransaction this_arg_conv;
35731         this_arg_conv.inner = (void*)(this_arg & (~1));
35732         this_arg_conv.is_owned = false;
35733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35734         unsigned char funding_key_arr[32];
35735         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
35736         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
35737         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
35738         LDKu8slice funding_redeemscript_ref;
35739         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
35740         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
35741         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35742         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
35743         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
35744         return ret_arr;
35745 }
35746
35747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35748         LDKClosingTransaction this_obj_conv;
35749         this_obj_conv.inner = (void*)(this_obj & (~1));
35750         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35752         ClosingTransaction_free(this_obj_conv);
35753 }
35754
35755 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
35756         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
35757 uintptr_t ret_ref = 0;
35758 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35759 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35760 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35761 ret_ref = (uintptr_t)ret_var.inner;
35762 if (ret_var.is_owned) {
35763         ret_ref |= 1;
35764 }
35765         return ret_ref;
35766 }
35767 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35768         LDKClosingTransaction arg_conv;
35769         arg_conv.inner = (void*)(arg & (~1));
35770         arg_conv.is_owned = false;
35771         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35772         intptr_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
35773         return ret_val;
35774 }
35775
35776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35777         LDKClosingTransaction orig_conv;
35778         orig_conv.inner = (void*)(orig & (~1));
35779         orig_conv.is_owned = false;
35780         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35781         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
35782         uintptr_t ret_ref = 0;
35783         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35784         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35786         ret_ref = (uintptr_t)ret_var.inner;
35787         if (ret_var.is_owned) {
35788                 ret_ref |= 1;
35789         }
35790         return ret_ref;
35791 }
35792
35793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
35794         LDKClosingTransaction o_conv;
35795         o_conv.inner = (void*)(o & (~1));
35796         o_conv.is_owned = false;
35797         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35798         int64_t ret_val = ClosingTransaction_hash(&o_conv);
35799         return ret_val;
35800 }
35801
35802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1new(JNIEnv *env, jclass clz, int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, int64_t funding_outpoint) {
35803         LDKCVec_u8Z to_holder_script_ref;
35804         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
35805         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
35806         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
35807         LDKCVec_u8Z to_counterparty_script_ref;
35808         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
35809         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
35810         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
35811         LDKOutPoint funding_outpoint_conv;
35812         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
35813         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
35814         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
35815         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
35816         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
35817         uintptr_t ret_ref = 0;
35818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35821         ret_ref = (uintptr_t)ret_var.inner;
35822         if (ret_var.is_owned) {
35823                 ret_ref |= 1;
35824         }
35825         return ret_ref;
35826 }
35827
35828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
35829         LDKClosingTransaction this_arg_conv;
35830         this_arg_conv.inner = (void*)(this_arg & (~1));
35831         this_arg_conv.is_owned = false;
35832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35833         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
35834         uintptr_t ret_ref = 0;
35835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35838         ret_ref = (uintptr_t)ret_var.inner;
35839         if (ret_var.is_owned) {
35840                 ret_ref |= 1;
35841         }
35842         return ret_ref;
35843 }
35844
35845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
35846         LDKClosingTransaction this_arg_conv;
35847         this_arg_conv.inner = (void*)(this_arg & (~1));
35848         this_arg_conv.is_owned = false;
35849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35850         LDKOutPoint funding_outpoint_conv;
35851         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
35852         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
35853         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
35854         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
35855         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
35856         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
35857         return (uintptr_t)ret_conv;
35858 }
35859
35860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
35861         LDKClosingTransaction this_arg_conv;
35862         this_arg_conv.inner = (void*)(this_arg & (~1));
35863         this_arg_conv.is_owned = false;
35864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35865         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
35866         return ret_val;
35867 }
35868
35869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
35870         LDKClosingTransaction this_arg_conv;
35871         this_arg_conv.inner = (void*)(this_arg & (~1));
35872         this_arg_conv.is_owned = false;
35873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35874         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
35875         return ret_val;
35876 }
35877
35878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
35879         LDKClosingTransaction this_arg_conv;
35880         this_arg_conv.inner = (void*)(this_arg & (~1));
35881         this_arg_conv.is_owned = false;
35882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35883         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
35884         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35885         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35886         return ret_arr;
35887 }
35888
35889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
35890         LDKClosingTransaction this_arg_conv;
35891         this_arg_conv.inner = (void*)(this_arg & (~1));
35892         this_arg_conv.is_owned = false;
35893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35894         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
35895         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35896         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35897         return ret_arr;
35898 }
35899
35900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35901         LDKTrustedClosingTransaction this_obj_conv;
35902         this_obj_conv.inner = (void*)(this_obj & (~1));
35903         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35905         TrustedClosingTransaction_free(this_obj_conv);
35906 }
35907
35908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
35909         LDKTrustedClosingTransaction this_arg_conv;
35910         this_arg_conv.inner = (void*)(this_arg & (~1));
35911         this_arg_conv.is_owned = false;
35912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35913         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
35914         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35915         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35916         Transaction_free(ret_var);
35917         return ret_arr;
35918 }
35919
35920 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1get_1sighash_1all(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
35921         LDKTrustedClosingTransaction this_arg_conv;
35922         this_arg_conv.inner = (void*)(this_arg & (~1));
35923         this_arg_conv.is_owned = false;
35924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35925         LDKu8slice funding_redeemscript_ref;
35926         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
35927         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
35928         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35929         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
35930         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
35931         return ret_arr;
35932 }
35933
35934 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
35935         LDKTrustedClosingTransaction this_arg_conv;
35936         this_arg_conv.inner = (void*)(this_arg & (~1));
35937         this_arg_conv.is_owned = false;
35938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35939         unsigned char funding_key_arr[32];
35940         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
35941         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
35942         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
35943         LDKu8slice funding_redeemscript_ref;
35944         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
35945         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
35946         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35947         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
35948         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
35949         return ret_arr;
35950 }
35951
35952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35953         LDKCommitmentTransaction this_obj_conv;
35954         this_obj_conv.inner = (void*)(this_obj & (~1));
35955         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35957         CommitmentTransaction_free(this_obj_conv);
35958 }
35959
35960 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
35961         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
35962 uintptr_t ret_ref = 0;
35963 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35964 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35965 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35966 ret_ref = (uintptr_t)ret_var.inner;
35967 if (ret_var.is_owned) {
35968         ret_ref |= 1;
35969 }
35970         return ret_ref;
35971 }
35972 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35973         LDKCommitmentTransaction arg_conv;
35974         arg_conv.inner = (void*)(arg & (~1));
35975         arg_conv.is_owned = false;
35976         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35977         intptr_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
35978         return ret_val;
35979 }
35980
35981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35982         LDKCommitmentTransaction orig_conv;
35983         orig_conv.inner = (void*)(orig & (~1));
35984         orig_conv.is_owned = false;
35985         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35986         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
35987         uintptr_t ret_ref = 0;
35988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35991         ret_ref = (uintptr_t)ret_var.inner;
35992         if (ret_var.is_owned) {
35993                 ret_ref |= 1;
35994         }
35995         return ret_ref;
35996 }
35997
35998 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
35999         LDKCommitmentTransaction obj_conv;
36000         obj_conv.inner = (void*)(obj & (~1));
36001         obj_conv.is_owned = false;
36002         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36003         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
36004         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36005         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36006         CVec_u8Z_free(ret_var);
36007         return ret_arr;
36008 }
36009
36010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36011         LDKu8slice ser_ref;
36012         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36013         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36014         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
36015         *ret_conv = CommitmentTransaction_read(ser_ref);
36016         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36017         return (uintptr_t)ret_conv;
36018 }
36019
36020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
36021         LDKCommitmentTransaction this_arg_conv;
36022         this_arg_conv.inner = (void*)(this_arg & (~1));
36023         this_arg_conv.is_owned = false;
36024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36025         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
36026         return ret_val;
36027 }
36028
36029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
36030         LDKCommitmentTransaction this_arg_conv;
36031         this_arg_conv.inner = (void*)(this_arg & (~1));
36032         this_arg_conv.is_owned = false;
36033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36034         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
36035         return ret_val;
36036 }
36037
36038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
36039         LDKCommitmentTransaction this_arg_conv;
36040         this_arg_conv.inner = (void*)(this_arg & (~1));
36041         this_arg_conv.is_owned = false;
36042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36043         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
36044         return ret_val;
36045 }
36046
36047 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
36048         LDKCommitmentTransaction this_arg_conv;
36049         this_arg_conv.inner = (void*)(this_arg & (~1));
36050         this_arg_conv.is_owned = false;
36051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36052         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
36053         return ret_val;
36054 }
36055
36056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
36057         LDKCommitmentTransaction this_arg_conv;
36058         this_arg_conv.inner = (void*)(this_arg & (~1));
36059         this_arg_conv.is_owned = false;
36060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36061         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
36062         uintptr_t ret_ref = 0;
36063         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36064         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36066         ret_ref = (uintptr_t)ret_var.inner;
36067         if (ret_var.is_owned) {
36068                 ret_ref |= 1;
36069         }
36070         return ret_ref;
36071 }
36072
36073 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) {
36074         LDKCommitmentTransaction this_arg_conv;
36075         this_arg_conv.inner = (void*)(this_arg & (~1));
36076         this_arg_conv.is_owned = false;
36077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36078         LDKDirectedChannelTransactionParameters channel_parameters_conv;
36079         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
36080         channel_parameters_conv.is_owned = false;
36081         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
36082         LDKChannelPublicKeys broadcaster_keys_conv;
36083         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
36084         broadcaster_keys_conv.is_owned = false;
36085         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
36086         LDKChannelPublicKeys countersignatory_keys_conv;
36087         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
36088         countersignatory_keys_conv.is_owned = false;
36089         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
36090         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
36091         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
36092         return (uintptr_t)ret_conv;
36093 }
36094
36095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36096         LDKTrustedCommitmentTransaction this_obj_conv;
36097         this_obj_conv.inner = (void*)(this_obj & (~1));
36098         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36100         TrustedCommitmentTransaction_free(this_obj_conv);
36101 }
36102
36103 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
36104         LDKTrustedCommitmentTransaction this_arg_conv;
36105         this_arg_conv.inner = (void*)(this_arg & (~1));
36106         this_arg_conv.is_owned = false;
36107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36108         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36109         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
36110         return ret_arr;
36111 }
36112
36113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
36114         LDKTrustedCommitmentTransaction this_arg_conv;
36115         this_arg_conv.inner = (void*)(this_arg & (~1));
36116         this_arg_conv.is_owned = false;
36117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36118         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
36119         uintptr_t ret_ref = 0;
36120         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36121         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36123         ret_ref = (uintptr_t)ret_var.inner;
36124         if (ret_var.is_owned) {
36125                 ret_ref |= 1;
36126         }
36127         return ret_ref;
36128 }
36129
36130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
36131         LDKTrustedCommitmentTransaction this_arg_conv;
36132         this_arg_conv.inner = (void*)(this_arg & (~1));
36133         this_arg_conv.is_owned = false;
36134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36135         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
36136         uintptr_t ret_ref = 0;
36137         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36138         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36140         ret_ref = (uintptr_t)ret_var.inner;
36141         if (ret_var.is_owned) {
36142                 ret_ref |= 1;
36143         }
36144         return ret_ref;
36145 }
36146
36147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
36148         LDKTrustedCommitmentTransaction this_arg_conv;
36149         this_arg_conv.inner = (void*)(this_arg & (~1));
36150         this_arg_conv.is_owned = false;
36151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36152         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
36153         return ret_val;
36154 }
36155
36156 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) {
36157         LDKTrustedCommitmentTransaction this_arg_conv;
36158         this_arg_conv.inner = (void*)(this_arg & (~1));
36159         this_arg_conv.is_owned = false;
36160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36161         unsigned char htlc_base_key_arr[32];
36162         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
36163         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
36164         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
36165         LDKDirectedChannelTransactionParameters channel_parameters_conv;
36166         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
36167         channel_parameters_conv.is_owned = false;
36168         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
36169         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
36170         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
36171         return (uintptr_t)ret_conv;
36172 }
36173
36174 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) {
36175         LDKPublicKey broadcaster_payment_basepoint_ref;
36176         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
36177         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
36178         LDKPublicKey countersignatory_payment_basepoint_ref;
36179         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
36180         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
36181         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
36182         return ret_val;
36183 }
36184
36185 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36186         LDKInitFeatures a_conv;
36187         a_conv.inner = (void*)(a & (~1));
36188         a_conv.is_owned = false;
36189         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36190         LDKInitFeatures b_conv;
36191         b_conv.inner = (void*)(b & (~1));
36192         b_conv.is_owned = false;
36193         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36194         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
36195         return ret_val;
36196 }
36197
36198 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36199         LDKNodeFeatures a_conv;
36200         a_conv.inner = (void*)(a & (~1));
36201         a_conv.is_owned = false;
36202         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36203         LDKNodeFeatures b_conv;
36204         b_conv.inner = (void*)(b & (~1));
36205         b_conv.is_owned = false;
36206         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36207         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
36208         return ret_val;
36209 }
36210
36211 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36212         LDKChannelFeatures a_conv;
36213         a_conv.inner = (void*)(a & (~1));
36214         a_conv.is_owned = false;
36215         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36216         LDKChannelFeatures b_conv;
36217         b_conv.inner = (void*)(b & (~1));
36218         b_conv.is_owned = false;
36219         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36220         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
36221         return ret_val;
36222 }
36223
36224 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36225         LDKInvoiceFeatures a_conv;
36226         a_conv.inner = (void*)(a & (~1));
36227         a_conv.is_owned = false;
36228         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36229         LDKInvoiceFeatures b_conv;
36230         b_conv.inner = (void*)(b & (~1));
36231         b_conv.is_owned = false;
36232         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36233         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
36234         return ret_val;
36235 }
36236
36237 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36238         LDKChannelTypeFeatures a_conv;
36239         a_conv.inner = (void*)(a & (~1));
36240         a_conv.is_owned = false;
36241         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36242         LDKChannelTypeFeatures b_conv;
36243         b_conv.inner = (void*)(b & (~1));
36244         b_conv.is_owned = false;
36245         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36246         jboolean ret_val = ChannelTypeFeatures_eq(&a_conv, &b_conv);
36247         return ret_val;
36248 }
36249
36250 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
36251         LDKInitFeatures ret_var = InitFeatures_clone(arg);
36252 uintptr_t ret_ref = 0;
36253 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36254 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36255 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36256 ret_ref = (uintptr_t)ret_var.inner;
36257 if (ret_var.is_owned) {
36258         ret_ref |= 1;
36259 }
36260         return ret_ref;
36261 }
36262 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36263         LDKInitFeatures arg_conv;
36264         arg_conv.inner = (void*)(arg & (~1));
36265         arg_conv.is_owned = false;
36266         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36267         intptr_t ret_val = InitFeatures_clone_ptr(&arg_conv);
36268         return ret_val;
36269 }
36270
36271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36272         LDKInitFeatures orig_conv;
36273         orig_conv.inner = (void*)(orig & (~1));
36274         orig_conv.is_owned = false;
36275         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36276         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
36277         uintptr_t ret_ref = 0;
36278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36281         ret_ref = (uintptr_t)ret_var.inner;
36282         if (ret_var.is_owned) {
36283                 ret_ref |= 1;
36284         }
36285         return ret_ref;
36286 }
36287
36288 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
36289         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
36290 uintptr_t ret_ref = 0;
36291 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36292 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36293 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36294 ret_ref = (uintptr_t)ret_var.inner;
36295 if (ret_var.is_owned) {
36296         ret_ref |= 1;
36297 }
36298         return ret_ref;
36299 }
36300 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36301         LDKNodeFeatures arg_conv;
36302         arg_conv.inner = (void*)(arg & (~1));
36303         arg_conv.is_owned = false;
36304         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36305         intptr_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
36306         return ret_val;
36307 }
36308
36309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36310         LDKNodeFeatures orig_conv;
36311         orig_conv.inner = (void*)(orig & (~1));
36312         orig_conv.is_owned = false;
36313         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36314         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
36315         uintptr_t ret_ref = 0;
36316         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36317         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36319         ret_ref = (uintptr_t)ret_var.inner;
36320         if (ret_var.is_owned) {
36321                 ret_ref |= 1;
36322         }
36323         return ret_ref;
36324 }
36325
36326 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
36327         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
36328 uintptr_t ret_ref = 0;
36329 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36330 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36331 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36332 ret_ref = (uintptr_t)ret_var.inner;
36333 if (ret_var.is_owned) {
36334         ret_ref |= 1;
36335 }
36336         return ret_ref;
36337 }
36338 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36339         LDKChannelFeatures arg_conv;
36340         arg_conv.inner = (void*)(arg & (~1));
36341         arg_conv.is_owned = false;
36342         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36343         intptr_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
36344         return ret_val;
36345 }
36346
36347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36348         LDKChannelFeatures orig_conv;
36349         orig_conv.inner = (void*)(orig & (~1));
36350         orig_conv.is_owned = false;
36351         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36352         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
36353         uintptr_t ret_ref = 0;
36354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36357         ret_ref = (uintptr_t)ret_var.inner;
36358         if (ret_var.is_owned) {
36359                 ret_ref |= 1;
36360         }
36361         return ret_ref;
36362 }
36363
36364 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
36365         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
36366 uintptr_t ret_ref = 0;
36367 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36368 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36369 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36370 ret_ref = (uintptr_t)ret_var.inner;
36371 if (ret_var.is_owned) {
36372         ret_ref |= 1;
36373 }
36374         return ret_ref;
36375 }
36376 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36377         LDKInvoiceFeatures arg_conv;
36378         arg_conv.inner = (void*)(arg & (~1));
36379         arg_conv.is_owned = false;
36380         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36381         intptr_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
36382         return ret_val;
36383 }
36384
36385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36386         LDKInvoiceFeatures orig_conv;
36387         orig_conv.inner = (void*)(orig & (~1));
36388         orig_conv.is_owned = false;
36389         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36390         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
36391         uintptr_t ret_ref = 0;
36392         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36393         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36395         ret_ref = (uintptr_t)ret_var.inner;
36396         if (ret_var.is_owned) {
36397                 ret_ref |= 1;
36398         }
36399         return ret_ref;
36400 }
36401
36402 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
36403         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
36404 uintptr_t ret_ref = 0;
36405 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36406 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36407 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36408 ret_ref = (uintptr_t)ret_var.inner;
36409 if (ret_var.is_owned) {
36410         ret_ref |= 1;
36411 }
36412         return ret_ref;
36413 }
36414 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36415         LDKChannelTypeFeatures arg_conv;
36416         arg_conv.inner = (void*)(arg & (~1));
36417         arg_conv.is_owned = false;
36418         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36419         intptr_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
36420         return ret_val;
36421 }
36422
36423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36424         LDKChannelTypeFeatures orig_conv;
36425         orig_conv.inner = (void*)(orig & (~1));
36426         orig_conv.is_owned = false;
36427         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36428         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
36429         uintptr_t ret_ref = 0;
36430         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36431         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36433         ret_ref = (uintptr_t)ret_var.inner;
36434         if (ret_var.is_owned) {
36435                 ret_ref |= 1;
36436         }
36437         return ret_ref;
36438 }
36439
36440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36441         LDKInitFeatures this_obj_conv;
36442         this_obj_conv.inner = (void*)(this_obj & (~1));
36443         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36445         InitFeatures_free(this_obj_conv);
36446 }
36447
36448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36449         LDKNodeFeatures this_obj_conv;
36450         this_obj_conv.inner = (void*)(this_obj & (~1));
36451         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36453         NodeFeatures_free(this_obj_conv);
36454 }
36455
36456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36457         LDKChannelFeatures this_obj_conv;
36458         this_obj_conv.inner = (void*)(this_obj & (~1));
36459         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36461         ChannelFeatures_free(this_obj_conv);
36462 }
36463
36464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36465         LDKInvoiceFeatures this_obj_conv;
36466         this_obj_conv.inner = (void*)(this_obj & (~1));
36467         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36469         InvoiceFeatures_free(this_obj_conv);
36470 }
36471
36472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36473         LDKChannelTypeFeatures this_obj_conv;
36474         this_obj_conv.inner = (void*)(this_obj & (~1));
36475         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36477         ChannelTypeFeatures_free(this_obj_conv);
36478 }
36479
36480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
36481         LDKInitFeatures ret_var = InitFeatures_empty();
36482         uintptr_t ret_ref = 0;
36483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36486         ret_ref = (uintptr_t)ret_var.inner;
36487         if (ret_var.is_owned) {
36488                 ret_ref |= 1;
36489         }
36490         return ret_ref;
36491 }
36492
36493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
36494         LDKInitFeatures ret_var = InitFeatures_known();
36495         uintptr_t ret_ref = 0;
36496         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36497         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36499         ret_ref = (uintptr_t)ret_var.inner;
36500         if (ret_var.is_owned) {
36501                 ret_ref |= 1;
36502         }
36503         return ret_ref;
36504 }
36505
36506 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
36507         LDKInitFeatures this_arg_conv;
36508         this_arg_conv.inner = (void*)(this_arg & (~1));
36509         this_arg_conv.is_owned = false;
36510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36511         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
36512         return ret_val;
36513 }
36514
36515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
36516         LDKNodeFeatures ret_var = NodeFeatures_empty();
36517         uintptr_t ret_ref = 0;
36518         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36519         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36521         ret_ref = (uintptr_t)ret_var.inner;
36522         if (ret_var.is_owned) {
36523                 ret_ref |= 1;
36524         }
36525         return ret_ref;
36526 }
36527
36528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
36529         LDKNodeFeatures ret_var = NodeFeatures_known();
36530         uintptr_t ret_ref = 0;
36531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36534         ret_ref = (uintptr_t)ret_var.inner;
36535         if (ret_var.is_owned) {
36536                 ret_ref |= 1;
36537         }
36538         return ret_ref;
36539 }
36540
36541 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
36542         LDKNodeFeatures this_arg_conv;
36543         this_arg_conv.inner = (void*)(this_arg & (~1));
36544         this_arg_conv.is_owned = false;
36545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36546         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
36547         return ret_val;
36548 }
36549
36550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
36551         LDKChannelFeatures ret_var = ChannelFeatures_empty();
36552         uintptr_t ret_ref = 0;
36553         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36554         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36556         ret_ref = (uintptr_t)ret_var.inner;
36557         if (ret_var.is_owned) {
36558                 ret_ref |= 1;
36559         }
36560         return ret_ref;
36561 }
36562
36563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
36564         LDKChannelFeatures ret_var = ChannelFeatures_known();
36565         uintptr_t ret_ref = 0;
36566         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36567         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36569         ret_ref = (uintptr_t)ret_var.inner;
36570         if (ret_var.is_owned) {
36571                 ret_ref |= 1;
36572         }
36573         return ret_ref;
36574 }
36575
36576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
36577         LDKChannelFeatures this_arg_conv;
36578         this_arg_conv.inner = (void*)(this_arg & (~1));
36579         this_arg_conv.is_owned = false;
36580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36581         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
36582         return ret_val;
36583 }
36584
36585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
36586         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
36587         uintptr_t ret_ref = 0;
36588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36591         ret_ref = (uintptr_t)ret_var.inner;
36592         if (ret_var.is_owned) {
36593                 ret_ref |= 1;
36594         }
36595         return ret_ref;
36596 }
36597
36598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
36599         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
36600         uintptr_t ret_ref = 0;
36601         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36602         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36604         ret_ref = (uintptr_t)ret_var.inner;
36605         if (ret_var.is_owned) {
36606                 ret_ref |= 1;
36607         }
36608         return ret_ref;
36609 }
36610
36611 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
36612         LDKInvoiceFeatures this_arg_conv;
36613         this_arg_conv.inner = (void*)(this_arg & (~1));
36614         this_arg_conv.is_owned = false;
36615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36616         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
36617         return ret_val;
36618 }
36619
36620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
36621         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
36622         uintptr_t ret_ref = 0;
36623         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36624         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36626         ret_ref = (uintptr_t)ret_var.inner;
36627         if (ret_var.is_owned) {
36628                 ret_ref |= 1;
36629         }
36630         return ret_ref;
36631 }
36632
36633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
36634         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
36635         uintptr_t ret_ref = 0;
36636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36639         ret_ref = (uintptr_t)ret_var.inner;
36640         if (ret_var.is_owned) {
36641                 ret_ref |= 1;
36642         }
36643         return ret_ref;
36644 }
36645
36646 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
36647         LDKChannelTypeFeatures this_arg_conv;
36648         this_arg_conv.inner = (void*)(this_arg & (~1));
36649         this_arg_conv.is_owned = false;
36650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36651         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
36652         return ret_val;
36653 }
36654
36655 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
36656         LDKInitFeatures obj_conv;
36657         obj_conv.inner = (void*)(obj & (~1));
36658         obj_conv.is_owned = false;
36659         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36660         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
36661         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36662         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36663         CVec_u8Z_free(ret_var);
36664         return ret_arr;
36665 }
36666
36667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36668         LDKu8slice ser_ref;
36669         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36670         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36671         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
36672         *ret_conv = InitFeatures_read(ser_ref);
36673         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36674         return (uintptr_t)ret_conv;
36675 }
36676
36677 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
36678         LDKChannelFeatures obj_conv;
36679         obj_conv.inner = (void*)(obj & (~1));
36680         obj_conv.is_owned = false;
36681         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36682         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
36683         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36684         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36685         CVec_u8Z_free(ret_var);
36686         return ret_arr;
36687 }
36688
36689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36690         LDKu8slice ser_ref;
36691         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36692         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36693         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
36694         *ret_conv = ChannelFeatures_read(ser_ref);
36695         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36696         return (uintptr_t)ret_conv;
36697 }
36698
36699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
36700         LDKNodeFeatures obj_conv;
36701         obj_conv.inner = (void*)(obj & (~1));
36702         obj_conv.is_owned = false;
36703         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36704         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
36705         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36706         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36707         CVec_u8Z_free(ret_var);
36708         return ret_arr;
36709 }
36710
36711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36712         LDKu8slice ser_ref;
36713         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36714         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36715         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
36716         *ret_conv = NodeFeatures_read(ser_ref);
36717         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36718         return (uintptr_t)ret_conv;
36719 }
36720
36721 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
36722         LDKInvoiceFeatures obj_conv;
36723         obj_conv.inner = (void*)(obj & (~1));
36724         obj_conv.is_owned = false;
36725         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36726         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
36727         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36728         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36729         CVec_u8Z_free(ret_var);
36730         return ret_arr;
36731 }
36732
36733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36734         LDKu8slice ser_ref;
36735         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36736         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36737         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
36738         *ret_conv = InvoiceFeatures_read(ser_ref);
36739         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36740         return (uintptr_t)ret_conv;
36741 }
36742
36743 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
36744         LDKChannelTypeFeatures obj_conv;
36745         obj_conv.inner = (void*)(obj & (~1));
36746         obj_conv.is_owned = false;
36747         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36748         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
36749         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36750         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36751         CVec_u8Z_free(ret_var);
36752         return ret_arr;
36753 }
36754
36755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36756         LDKu8slice ser_ref;
36757         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36758         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36759         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
36760         *ret_conv = ChannelTypeFeatures_read(ser_ref);
36761         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36762         return (uintptr_t)ret_conv;
36763 }
36764
36765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36766         LDKShutdownScript this_obj_conv;
36767         this_obj_conv.inner = (void*)(this_obj & (~1));
36768         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36770         ShutdownScript_free(this_obj_conv);
36771 }
36772
36773 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
36774         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
36775 uintptr_t ret_ref = 0;
36776 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36777 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36778 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36779 ret_ref = (uintptr_t)ret_var.inner;
36780 if (ret_var.is_owned) {
36781         ret_ref |= 1;
36782 }
36783         return ret_ref;
36784 }
36785 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36786         LDKShutdownScript arg_conv;
36787         arg_conv.inner = (void*)(arg & (~1));
36788         arg_conv.is_owned = false;
36789         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36790         intptr_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
36791         return ret_val;
36792 }
36793
36794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36795         LDKShutdownScript orig_conv;
36796         orig_conv.inner = (void*)(orig & (~1));
36797         orig_conv.is_owned = false;
36798         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36799         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
36800         uintptr_t ret_ref = 0;
36801         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36802         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36804         ret_ref = (uintptr_t)ret_var.inner;
36805         if (ret_var.is_owned) {
36806                 ret_ref |= 1;
36807         }
36808         return ret_ref;
36809 }
36810
36811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36812         LDKInvalidShutdownScript this_obj_conv;
36813         this_obj_conv.inner = (void*)(this_obj & (~1));
36814         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36816         InvalidShutdownScript_free(this_obj_conv);
36817 }
36818
36819 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
36820         LDKInvalidShutdownScript this_ptr_conv;
36821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36822         this_ptr_conv.is_owned = false;
36823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36824         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
36825         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36826         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36827         return ret_arr;
36828 }
36829
36830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36831         LDKInvalidShutdownScript this_ptr_conv;
36832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36833         this_ptr_conv.is_owned = false;
36834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36835         LDKCVec_u8Z val_ref;
36836         val_ref.datalen = (*env)->GetArrayLength(env, val);
36837         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
36838         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
36839         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
36840 }
36841
36842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
36843         LDKCVec_u8Z script_arg_ref;
36844         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
36845         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
36846         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
36847         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
36848         uintptr_t ret_ref = 0;
36849         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36850         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36852         ret_ref = (uintptr_t)ret_var.inner;
36853         if (ret_var.is_owned) {
36854                 ret_ref |= 1;
36855         }
36856         return ret_ref;
36857 }
36858
36859 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
36860         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
36861 uintptr_t ret_ref = 0;
36862 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36863 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36864 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36865 ret_ref = (uintptr_t)ret_var.inner;
36866 if (ret_var.is_owned) {
36867         ret_ref |= 1;
36868 }
36869         return ret_ref;
36870 }
36871 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36872         LDKInvalidShutdownScript arg_conv;
36873         arg_conv.inner = (void*)(arg & (~1));
36874         arg_conv.is_owned = false;
36875         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36876         intptr_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
36877         return ret_val;
36878 }
36879
36880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36881         LDKInvalidShutdownScript orig_conv;
36882         orig_conv.inner = (void*)(orig & (~1));
36883         orig_conv.is_owned = false;
36884         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36885         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
36886         uintptr_t ret_ref = 0;
36887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36890         ret_ref = (uintptr_t)ret_var.inner;
36891         if (ret_var.is_owned) {
36892                 ret_ref |= 1;
36893         }
36894         return ret_ref;
36895 }
36896
36897 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
36898         LDKShutdownScript obj_conv;
36899         obj_conv.inner = (void*)(obj & (~1));
36900         obj_conv.is_owned = false;
36901         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36902         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
36903         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36904         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36905         CVec_u8Z_free(ret_var);
36906         return ret_arr;
36907 }
36908
36909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36910         LDKu8slice ser_ref;
36911         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36912         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36913         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
36914         *ret_conv = ShutdownScript_read(ser_ref);
36915         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36916         return (uintptr_t)ret_conv;
36917 }
36918
36919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
36920         unsigned char pubkey_hash_arr[20];
36921         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
36922         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
36923         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
36924         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
36925         uintptr_t ret_ref = 0;
36926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36929         ret_ref = (uintptr_t)ret_var.inner;
36930         if (ret_var.is_owned) {
36931                 ret_ref |= 1;
36932         }
36933         return ret_ref;
36934 }
36935
36936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
36937         unsigned char script_hash_arr[32];
36938         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
36939         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
36940         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
36941         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
36942         uintptr_t ret_ref = 0;
36943         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36944         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36946         ret_ref = (uintptr_t)ret_var.inner;
36947         if (ret_var.is_owned) {
36948                 ret_ref |= 1;
36949         }
36950         return ret_ref;
36951 }
36952
36953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
36954         LDKu8slice program_ref;
36955         program_ref.datalen = (*env)->GetArrayLength(env, program);
36956         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
36957         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
36958         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
36959         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
36960         return (uintptr_t)ret_conv;
36961 }
36962
36963 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
36964         LDKShutdownScript this_arg_conv;
36965         this_arg_conv.inner = (void*)(this_arg & (~1));
36966         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
36967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36968         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
36969         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
36970         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36971         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36972         CVec_u8Z_free(ret_var);
36973         return ret_arr;
36974 }
36975
36976 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
36977         LDKShutdownScript this_arg_conv;
36978         this_arg_conv.inner = (void*)(this_arg & (~1));
36979         this_arg_conv.is_owned = false;
36980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36981         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36982         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
36983         return ret_arr;
36984 }
36985
36986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
36987         LDKShutdownScript this_arg_conv;
36988         this_arg_conv.inner = (void*)(this_arg & (~1));
36989         this_arg_conv.is_owned = false;
36990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36991         LDKInitFeatures features_conv;
36992         features_conv.inner = (void*)(features & (~1));
36993         features_conv.is_owned = false;
36994         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
36995         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
36996         return ret_val;
36997 }
36998
36999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37000         if ((this_ptr & 1) != 0) return;
37001         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37002         CHECK_ACCESS(this_ptr_ptr);
37003         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
37004         FREE((void*)this_ptr);
37005         CustomMessageReader_free(this_ptr_conv);
37006 }
37007
37008 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
37009         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
37010         *ret_ret = Type_clone(arg);
37011         return (uintptr_t)ret_ret;
37012 }
37013 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37014         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
37015         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
37016         LDKType* arg_conv = (LDKType*)arg_ptr;
37017         intptr_t ret_val = Type_clone_ptr(arg_conv);
37018         return ret_val;
37019 }
37020
37021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37022         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
37023         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
37024         LDKType* orig_conv = (LDKType*)orig_ptr;
37025         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
37026         *ret_ret = Type_clone(orig_conv);
37027         return (uintptr_t)ret_ret;
37028 }
37029
37030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37031         if ((this_ptr & 1) != 0) return;
37032         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37033         CHECK_ACCESS(this_ptr_ptr);
37034         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
37035         FREE((void*)this_ptr);
37036         Type_free(this_ptr_conv);
37037 }
37038
37039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37040         LDKNodeId this_obj_conv;
37041         this_obj_conv.inner = (void*)(this_obj & (~1));
37042         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37044         NodeId_free(this_obj_conv);
37045 }
37046
37047 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
37048         LDKNodeId ret_var = NodeId_clone(arg);
37049 uintptr_t ret_ref = 0;
37050 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37051 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37052 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37053 ret_ref = (uintptr_t)ret_var.inner;
37054 if (ret_var.is_owned) {
37055         ret_ref |= 1;
37056 }
37057         return ret_ref;
37058 }
37059 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37060         LDKNodeId arg_conv;
37061         arg_conv.inner = (void*)(arg & (~1));
37062         arg_conv.is_owned = false;
37063         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37064         intptr_t ret_val = NodeId_clone_ptr(&arg_conv);
37065         return ret_val;
37066 }
37067
37068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37069         LDKNodeId orig_conv;
37070         orig_conv.inner = (void*)(orig & (~1));
37071         orig_conv.is_owned = false;
37072         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37073         LDKNodeId ret_var = NodeId_clone(&orig_conv);
37074         uintptr_t ret_ref = 0;
37075         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37076         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37078         ret_ref = (uintptr_t)ret_var.inner;
37079         if (ret_var.is_owned) {
37080                 ret_ref |= 1;
37081         }
37082         return ret_ref;
37083 }
37084
37085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
37086         LDKPublicKey pubkey_ref;
37087         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
37088         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
37089         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
37090         uintptr_t ret_ref = 0;
37091         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37092         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37094         ret_ref = (uintptr_t)ret_var.inner;
37095         if (ret_var.is_owned) {
37096                 ret_ref |= 1;
37097         }
37098         return ret_ref;
37099 }
37100
37101 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
37102         LDKNodeId this_arg_conv;
37103         this_arg_conv.inner = (void*)(this_arg & (~1));
37104         this_arg_conv.is_owned = false;
37105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37106         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
37107         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37108         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37109         return ret_arr;
37110 }
37111
37112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
37113         LDKNodeId o_conv;
37114         o_conv.inner = (void*)(o & (~1));
37115         o_conv.is_owned = false;
37116         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37117         int64_t ret_val = NodeId_hash(&o_conv);
37118         return ret_val;
37119 }
37120
37121 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
37122         LDKNodeId obj_conv;
37123         obj_conv.inner = (void*)(obj & (~1));
37124         obj_conv.is_owned = false;
37125         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37126         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
37127         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37128         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37129         CVec_u8Z_free(ret_var);
37130         return ret_arr;
37131 }
37132
37133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37134         LDKu8slice ser_ref;
37135         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37136         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37137         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
37138         *ret_conv = NodeId_read(ser_ref);
37139         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37140         return (uintptr_t)ret_conv;
37141 }
37142
37143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37144         LDKNetworkGraph this_obj_conv;
37145         this_obj_conv.inner = (void*)(this_obj & (~1));
37146         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37148         NetworkGraph_free(this_obj_conv);
37149 }
37150
37151 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
37152         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
37153 uintptr_t ret_ref = 0;
37154 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37155 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37156 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37157 ret_ref = (uintptr_t)ret_var.inner;
37158 if (ret_var.is_owned) {
37159         ret_ref |= 1;
37160 }
37161         return ret_ref;
37162 }
37163 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37164         LDKNetworkGraph arg_conv;
37165         arg_conv.inner = (void*)(arg & (~1));
37166         arg_conv.is_owned = false;
37167         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37168         intptr_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
37169         return ret_val;
37170 }
37171
37172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37173         LDKNetworkGraph orig_conv;
37174         orig_conv.inner = (void*)(orig & (~1));
37175         orig_conv.is_owned = false;
37176         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37177         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
37178         uintptr_t ret_ref = 0;
37179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37182         ret_ref = (uintptr_t)ret_var.inner;
37183         if (ret_var.is_owned) {
37184                 ret_ref |= 1;
37185         }
37186         return ret_ref;
37187 }
37188
37189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37190         LDKReadOnlyNetworkGraph this_obj_conv;
37191         this_obj_conv.inner = (void*)(this_obj & (~1));
37192         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37194         ReadOnlyNetworkGraph_free(this_obj_conv);
37195 }
37196
37197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37198         if ((this_ptr & 1) != 0) return;
37199         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37200         CHECK_ACCESS(this_ptr_ptr);
37201         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
37202         FREE((void*)this_ptr);
37203         NetworkUpdate_free(this_ptr_conv);
37204 }
37205
37206 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
37207         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
37208         *ret_copy = NetworkUpdate_clone(arg);
37209 uintptr_t ret_ref = (uintptr_t)ret_copy;
37210         return ret_ref;
37211 }
37212 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37213         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
37214         intptr_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
37215         return ret_val;
37216 }
37217
37218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37219         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
37220         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
37221         *ret_copy = NetworkUpdate_clone(orig_conv);
37222         uintptr_t ret_ref = (uintptr_t)ret_copy;
37223         return ret_ref;
37224 }
37225
37226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
37227         LDKChannelUpdate msg_conv;
37228         msg_conv.inner = (void*)(msg & (~1));
37229         msg_conv.is_owned = (msg & 1) || (msg == 0);
37230         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37231         msg_conv = ChannelUpdate_clone(&msg_conv);
37232         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
37233         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
37234         uintptr_t ret_ref = (uintptr_t)ret_copy;
37235         return ret_ref;
37236 }
37237
37238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
37239         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
37240         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
37241         uintptr_t ret_ref = (uintptr_t)ret_copy;
37242         return ret_ref;
37243 }
37244
37245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
37246         LDKPublicKey node_id_ref;
37247         CHECK((*env)->GetArrayLength(env, node_id) == 33);
37248         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
37249         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
37250         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
37251         uintptr_t ret_ref = (uintptr_t)ret_copy;
37252         return ret_ref;
37253 }
37254
37255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
37256         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
37257         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
37258         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37259         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37260         CVec_u8Z_free(ret_var);
37261         return ret_arr;
37262 }
37263
37264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37265         LDKu8slice ser_ref;
37266         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37267         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37268         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
37269         *ret_conv = NetworkUpdate_read(ser_ref);
37270         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37271         return (uintptr_t)ret_conv;
37272 }
37273
37274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
37275         LDKNetGraphMsgHandler this_arg_conv;
37276         this_arg_conv.inner = (void*)(this_arg & (~1));
37277         this_arg_conv.is_owned = false;
37278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37279         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
37280         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
37281         return (uintptr_t)ret_ret;
37282 }
37283
37284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37285         LDKNetGraphMsgHandler this_obj_conv;
37286         this_obj_conv.inner = (void*)(this_obj & (~1));
37287         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37289         NetGraphMsgHandler_free(this_obj_conv);
37290 }
37291
37292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
37293         LDKNetworkGraph network_graph_conv;
37294         network_graph_conv.inner = (void*)(network_graph & (~1));
37295         network_graph_conv.is_owned = false;
37296         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
37297         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
37298         CHECK_ACCESS(chain_access_ptr);
37299         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37300         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
37301         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37302                 // Manually implement clone for Java trait instances
37303                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
37304                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37305                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
37306                 }
37307         }
37308         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
37309         CHECK_ACCESS(logger_ptr);
37310         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
37311         if (logger_conv.free == LDKLogger_JCalls_free) {
37312                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37313                 LDKLogger_JCalls_cloned(&logger_conv);
37314         }
37315         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
37316         uintptr_t ret_ref = 0;
37317         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37318         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37320         ret_ref = (uintptr_t)ret_var.inner;
37321         if (ret_var.is_owned) {
37322                 ret_ref |= 1;
37323         }
37324         return ret_ref;
37325 }
37326
37327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
37328         LDKNetGraphMsgHandler this_arg_conv;
37329         this_arg_conv.inner = (void*)(this_arg & (~1));
37330         this_arg_conv.is_owned = false;
37331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37332         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
37333         CHECK_ACCESS(chain_access_ptr);
37334         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37335         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
37336         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37337                 // Manually implement clone for Java trait instances
37338                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
37339                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37340                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
37341                 }
37342         }
37343         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
37344 }
37345
37346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
37347         LDKNetGraphMsgHandler this_arg_conv;
37348         this_arg_conv.inner = (void*)(this_arg & (~1));
37349         this_arg_conv.is_owned = false;
37350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37351         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
37352         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
37353         return (uintptr_t)ret_ret;
37354 }
37355
37356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
37357         LDKNetGraphMsgHandler this_arg_conv;
37358         this_arg_conv.inner = (void*)(this_arg & (~1));
37359         this_arg_conv.is_owned = false;
37360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37361         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
37362         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
37363         return (uintptr_t)ret_ret;
37364 }
37365
37366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37367         LDKDirectionalChannelInfo this_obj_conv;
37368         this_obj_conv.inner = (void*)(this_obj & (~1));
37369         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37371         DirectionalChannelInfo_free(this_obj_conv);
37372 }
37373
37374 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
37375         LDKDirectionalChannelInfo this_ptr_conv;
37376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37377         this_ptr_conv.is_owned = false;
37378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37379         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
37380         return ret_val;
37381 }
37382
37383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37384         LDKDirectionalChannelInfo this_ptr_conv;
37385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37386         this_ptr_conv.is_owned = false;
37387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37388         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
37389 }
37390
37391 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
37392         LDKDirectionalChannelInfo this_ptr_conv;
37393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37394         this_ptr_conv.is_owned = false;
37395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37396         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
37397         return ret_val;
37398 }
37399
37400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37401         LDKDirectionalChannelInfo this_ptr_conv;
37402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37403         this_ptr_conv.is_owned = false;
37404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37405         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
37406 }
37407
37408 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
37409         LDKDirectionalChannelInfo this_ptr_conv;
37410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37411         this_ptr_conv.is_owned = false;
37412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37413         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
37414         return ret_val;
37415 }
37416
37417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37418         LDKDirectionalChannelInfo this_ptr_conv;
37419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37420         this_ptr_conv.is_owned = false;
37421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37422         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
37423 }
37424
37425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37426         LDKDirectionalChannelInfo this_ptr_conv;
37427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37428         this_ptr_conv.is_owned = false;
37429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37430         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
37431         return ret_val;
37432 }
37433
37434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37435         LDKDirectionalChannelInfo this_ptr_conv;
37436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37437         this_ptr_conv.is_owned = false;
37438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37439         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
37440 }
37441
37442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37443         LDKDirectionalChannelInfo this_ptr_conv;
37444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37445         this_ptr_conv.is_owned = false;
37446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37447         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
37448         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
37449         uintptr_t ret_ref = (uintptr_t)ret_copy;
37450         return ret_ref;
37451 }
37452
37453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37454         LDKDirectionalChannelInfo this_ptr_conv;
37455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37456         this_ptr_conv.is_owned = false;
37457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37458         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37459         CHECK_ACCESS(val_ptr);
37460         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
37461         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
37462         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
37463 }
37464
37465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
37466         LDKDirectionalChannelInfo this_ptr_conv;
37467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37468         this_ptr_conv.is_owned = false;
37469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37470         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
37471         uintptr_t ret_ref = 0;
37472         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37473         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37475         ret_ref = (uintptr_t)ret_var.inner;
37476         if (ret_var.is_owned) {
37477                 ret_ref |= 1;
37478         }
37479         return ret_ref;
37480 }
37481
37482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37483         LDKDirectionalChannelInfo this_ptr_conv;
37484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37485         this_ptr_conv.is_owned = false;
37486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37487         LDKRoutingFees val_conv;
37488         val_conv.inner = (void*)(val & (~1));
37489         val_conv.is_owned = (val & 1) || (val == 0);
37490         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37491         val_conv = RoutingFees_clone(&val_conv);
37492         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
37493 }
37494
37495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
37496         LDKDirectionalChannelInfo this_ptr_conv;
37497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37498         this_ptr_conv.is_owned = false;
37499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37500         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
37501         uintptr_t ret_ref = 0;
37502         if ((uintptr_t)ret_var.inner > 4096) {
37503                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37504                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37506                 ret_ref = (uintptr_t)ret_var.inner;
37507                 if (ret_var.is_owned) {
37508                         ret_ref |= 1;
37509                 }
37510         }
37511         return ret_ref;
37512 }
37513
37514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37515         LDKDirectionalChannelInfo this_ptr_conv;
37516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37517         this_ptr_conv.is_owned = false;
37518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37519         LDKChannelUpdate val_conv;
37520         val_conv.inner = (void*)(val & (~1));
37521         val_conv.is_owned = (val & 1) || (val == 0);
37522         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37523         val_conv = ChannelUpdate_clone(&val_conv);
37524         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
37525 }
37526
37527 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) {
37528         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
37529         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
37530         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
37531         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
37532         LDKRoutingFees fees_arg_conv;
37533         fees_arg_conv.inner = (void*)(fees_arg & (~1));
37534         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
37535         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
37536         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
37537         LDKChannelUpdate last_update_message_arg_conv;
37538         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
37539         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
37540         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
37541         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
37542         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);
37543         uintptr_t ret_ref = 0;
37544         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37545         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37547         ret_ref = (uintptr_t)ret_var.inner;
37548         if (ret_var.is_owned) {
37549                 ret_ref |= 1;
37550         }
37551         return ret_ref;
37552 }
37553
37554 static inline uintptr_t DirectionalChannelInfo_clone_ptr(LDKDirectionalChannelInfo *NONNULL_PTR arg) {
37555         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(arg);
37556 uintptr_t ret_ref = 0;
37557 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37558 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37559 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37560 ret_ref = (uintptr_t)ret_var.inner;
37561 if (ret_var.is_owned) {
37562         ret_ref |= 1;
37563 }
37564         return ret_ref;
37565 }
37566 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37567         LDKDirectionalChannelInfo arg_conv;
37568         arg_conv.inner = (void*)(arg & (~1));
37569         arg_conv.is_owned = false;
37570         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37571         intptr_t ret_val = DirectionalChannelInfo_clone_ptr(&arg_conv);
37572         return ret_val;
37573 }
37574
37575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37576         LDKDirectionalChannelInfo orig_conv;
37577         orig_conv.inner = (void*)(orig & (~1));
37578         orig_conv.is_owned = false;
37579         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37580         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
37581         uintptr_t ret_ref = 0;
37582         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37583         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37585         ret_ref = (uintptr_t)ret_var.inner;
37586         if (ret_var.is_owned) {
37587                 ret_ref |= 1;
37588         }
37589         return ret_ref;
37590 }
37591
37592 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
37593         LDKDirectionalChannelInfo obj_conv;
37594         obj_conv.inner = (void*)(obj & (~1));
37595         obj_conv.is_owned = false;
37596         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37597         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
37598         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37599         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37600         CVec_u8Z_free(ret_var);
37601         return ret_arr;
37602 }
37603
37604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37605         LDKu8slice ser_ref;
37606         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37607         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37608         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
37609         *ret_conv = DirectionalChannelInfo_read(ser_ref);
37610         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37611         return (uintptr_t)ret_conv;
37612 }
37613
37614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37615         LDKChannelInfo this_obj_conv;
37616         this_obj_conv.inner = (void*)(this_obj & (~1));
37617         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37619         ChannelInfo_free(this_obj_conv);
37620 }
37621
37622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
37623         LDKChannelInfo this_ptr_conv;
37624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37625         this_ptr_conv.is_owned = false;
37626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37627         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
37628         uintptr_t ret_ref = 0;
37629         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37630         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37632         ret_ref = (uintptr_t)ret_var.inner;
37633         if (ret_var.is_owned) {
37634                 ret_ref |= 1;
37635         }
37636         return ret_ref;
37637 }
37638
37639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37640         LDKChannelInfo this_ptr_conv;
37641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37642         this_ptr_conv.is_owned = false;
37643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37644         LDKChannelFeatures val_conv;
37645         val_conv.inner = (void*)(val & (~1));
37646         val_conv.is_owned = (val & 1) || (val == 0);
37647         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37648         val_conv = ChannelFeatures_clone(&val_conv);
37649         ChannelInfo_set_features(&this_ptr_conv, val_conv);
37650 }
37651
37652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
37653         LDKChannelInfo this_ptr_conv;
37654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37655         this_ptr_conv.is_owned = false;
37656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37657         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
37658         uintptr_t ret_ref = 0;
37659         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37660         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37662         ret_ref = (uintptr_t)ret_var.inner;
37663         if (ret_var.is_owned) {
37664                 ret_ref |= 1;
37665         }
37666         return ret_ref;
37667 }
37668
37669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37670         LDKChannelInfo this_ptr_conv;
37671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37672         this_ptr_conv.is_owned = false;
37673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37674         LDKNodeId val_conv;
37675         val_conv.inner = (void*)(val & (~1));
37676         val_conv.is_owned = (val & 1) || (val == 0);
37677         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37678         val_conv = NodeId_clone(&val_conv);
37679         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
37680 }
37681
37682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
37683         LDKChannelInfo this_ptr_conv;
37684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37685         this_ptr_conv.is_owned = false;
37686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37687         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
37688         uintptr_t ret_ref = 0;
37689         if ((uintptr_t)ret_var.inner > 4096) {
37690                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37691                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37693                 ret_ref = (uintptr_t)ret_var.inner;
37694                 if (ret_var.is_owned) {
37695                         ret_ref |= 1;
37696                 }
37697         }
37698         return ret_ref;
37699 }
37700
37701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37702         LDKChannelInfo this_ptr_conv;
37703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37704         this_ptr_conv.is_owned = false;
37705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37706         LDKDirectionalChannelInfo val_conv;
37707         val_conv.inner = (void*)(val & (~1));
37708         val_conv.is_owned = (val & 1) || (val == 0);
37709         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37710         val_conv = DirectionalChannelInfo_clone(&val_conv);
37711         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
37712 }
37713
37714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
37715         LDKChannelInfo this_ptr_conv;
37716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37717         this_ptr_conv.is_owned = false;
37718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37719         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
37720         uintptr_t ret_ref = 0;
37721         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37722         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37724         ret_ref = (uintptr_t)ret_var.inner;
37725         if (ret_var.is_owned) {
37726                 ret_ref |= 1;
37727         }
37728         return ret_ref;
37729 }
37730
37731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37732         LDKChannelInfo this_ptr_conv;
37733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37734         this_ptr_conv.is_owned = false;
37735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37736         LDKNodeId val_conv;
37737         val_conv.inner = (void*)(val & (~1));
37738         val_conv.is_owned = (val & 1) || (val == 0);
37739         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37740         val_conv = NodeId_clone(&val_conv);
37741         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
37742 }
37743
37744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
37745         LDKChannelInfo this_ptr_conv;
37746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37747         this_ptr_conv.is_owned = false;
37748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37749         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
37750         uintptr_t ret_ref = 0;
37751         if ((uintptr_t)ret_var.inner > 4096) {
37752                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37753                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37755                 ret_ref = (uintptr_t)ret_var.inner;
37756                 if (ret_var.is_owned) {
37757                         ret_ref |= 1;
37758                 }
37759         }
37760         return ret_ref;
37761 }
37762
37763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37764         LDKChannelInfo this_ptr_conv;
37765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37766         this_ptr_conv.is_owned = false;
37767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37768         LDKDirectionalChannelInfo val_conv;
37769         val_conv.inner = (void*)(val & (~1));
37770         val_conv.is_owned = (val & 1) || (val == 0);
37771         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37772         val_conv = DirectionalChannelInfo_clone(&val_conv);
37773         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
37774 }
37775
37776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
37777         LDKChannelInfo this_ptr_conv;
37778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37779         this_ptr_conv.is_owned = false;
37780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37781         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
37782         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
37783         uintptr_t ret_ref = (uintptr_t)ret_copy;
37784         return ret_ref;
37785 }
37786
37787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37788         LDKChannelInfo this_ptr_conv;
37789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37790         this_ptr_conv.is_owned = false;
37791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37792         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37793         CHECK_ACCESS(val_ptr);
37794         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
37795         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
37796         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
37797 }
37798
37799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
37800         LDKChannelInfo this_ptr_conv;
37801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37802         this_ptr_conv.is_owned = false;
37803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37804         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
37805         uintptr_t ret_ref = 0;
37806         if ((uintptr_t)ret_var.inner > 4096) {
37807                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37808                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37810                 ret_ref = (uintptr_t)ret_var.inner;
37811                 if (ret_var.is_owned) {
37812                         ret_ref |= 1;
37813                 }
37814         }
37815         return ret_ref;
37816 }
37817
37818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37819         LDKChannelInfo this_ptr_conv;
37820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37821         this_ptr_conv.is_owned = false;
37822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37823         LDKChannelAnnouncement val_conv;
37824         val_conv.inner = (void*)(val & (~1));
37825         val_conv.is_owned = (val & 1) || (val == 0);
37826         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37827         val_conv = ChannelAnnouncement_clone(&val_conv);
37828         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
37829 }
37830
37831 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
37832         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
37833 uintptr_t ret_ref = 0;
37834 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37835 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37836 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37837 ret_ref = (uintptr_t)ret_var.inner;
37838 if (ret_var.is_owned) {
37839         ret_ref |= 1;
37840 }
37841         return ret_ref;
37842 }
37843 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37844         LDKChannelInfo arg_conv;
37845         arg_conv.inner = (void*)(arg & (~1));
37846         arg_conv.is_owned = false;
37847         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37848         intptr_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
37849         return ret_val;
37850 }
37851
37852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37853         LDKChannelInfo orig_conv;
37854         orig_conv.inner = (void*)(orig & (~1));
37855         orig_conv.is_owned = false;
37856         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37857         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
37858         uintptr_t ret_ref = 0;
37859         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37860         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37862         ret_ref = (uintptr_t)ret_var.inner;
37863         if (ret_var.is_owned) {
37864                 ret_ref |= 1;
37865         }
37866         return ret_ref;
37867 }
37868
37869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
37870         LDKChannelInfo obj_conv;
37871         obj_conv.inner = (void*)(obj & (~1));
37872         obj_conv.is_owned = false;
37873         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37874         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
37875         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37876         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37877         CVec_u8Z_free(ret_var);
37878         return ret_arr;
37879 }
37880
37881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37882         LDKu8slice ser_ref;
37883         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37884         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37885         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
37886         *ret_conv = ChannelInfo_read(ser_ref);
37887         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37888         return (uintptr_t)ret_conv;
37889 }
37890
37891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37892         LDKRoutingFees this_obj_conv;
37893         this_obj_conv.inner = (void*)(this_obj & (~1));
37894         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37896         RoutingFees_free(this_obj_conv);
37897 }
37898
37899 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37900         LDKRoutingFees this_ptr_conv;
37901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37902         this_ptr_conv.is_owned = false;
37903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37904         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
37905         return ret_val;
37906 }
37907
37908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37909         LDKRoutingFees this_ptr_conv;
37910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37911         this_ptr_conv.is_owned = false;
37912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37913         RoutingFees_set_base_msat(&this_ptr_conv, val);
37914 }
37915
37916 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
37917         LDKRoutingFees this_ptr_conv;
37918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37919         this_ptr_conv.is_owned = false;
37920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37921         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
37922         return ret_val;
37923 }
37924
37925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37926         LDKRoutingFees this_ptr_conv;
37927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37928         this_ptr_conv.is_owned = false;
37929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37930         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
37931 }
37932
37933 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) {
37934         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
37935         uintptr_t ret_ref = 0;
37936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37939         ret_ref = (uintptr_t)ret_var.inner;
37940         if (ret_var.is_owned) {
37941                 ret_ref |= 1;
37942         }
37943         return ret_ref;
37944 }
37945
37946 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37947         LDKRoutingFees a_conv;
37948         a_conv.inner = (void*)(a & (~1));
37949         a_conv.is_owned = false;
37950         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37951         LDKRoutingFees b_conv;
37952         b_conv.inner = (void*)(b & (~1));
37953         b_conv.is_owned = false;
37954         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37955         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
37956         return ret_val;
37957 }
37958
37959 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
37960         LDKRoutingFees ret_var = RoutingFees_clone(arg);
37961 uintptr_t ret_ref = 0;
37962 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37963 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37964 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37965 ret_ref = (uintptr_t)ret_var.inner;
37966 if (ret_var.is_owned) {
37967         ret_ref |= 1;
37968 }
37969         return ret_ref;
37970 }
37971 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37972         LDKRoutingFees arg_conv;
37973         arg_conv.inner = (void*)(arg & (~1));
37974         arg_conv.is_owned = false;
37975         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37976         intptr_t ret_val = RoutingFees_clone_ptr(&arg_conv);
37977         return ret_val;
37978 }
37979
37980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37981         LDKRoutingFees orig_conv;
37982         orig_conv.inner = (void*)(orig & (~1));
37983         orig_conv.is_owned = false;
37984         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37985         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
37986         uintptr_t ret_ref = 0;
37987         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37988         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37990         ret_ref = (uintptr_t)ret_var.inner;
37991         if (ret_var.is_owned) {
37992                 ret_ref |= 1;
37993         }
37994         return ret_ref;
37995 }
37996
37997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
37998         LDKRoutingFees o_conv;
37999         o_conv.inner = (void*)(o & (~1));
38000         o_conv.is_owned = false;
38001         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38002         int64_t ret_val = RoutingFees_hash(&o_conv);
38003         return ret_val;
38004 }
38005
38006 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
38007         LDKRoutingFees obj_conv;
38008         obj_conv.inner = (void*)(obj & (~1));
38009         obj_conv.is_owned = false;
38010         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38011         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
38012         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38013         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38014         CVec_u8Z_free(ret_var);
38015         return ret_arr;
38016 }
38017
38018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38019         LDKu8slice ser_ref;
38020         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38021         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38022         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
38023         *ret_conv = RoutingFees_read(ser_ref);
38024         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38025         return (uintptr_t)ret_conv;
38026 }
38027
38028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38029         LDKNodeAnnouncementInfo this_obj_conv;
38030         this_obj_conv.inner = (void*)(this_obj & (~1));
38031         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38033         NodeAnnouncementInfo_free(this_obj_conv);
38034 }
38035
38036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
38037         LDKNodeAnnouncementInfo this_ptr_conv;
38038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38039         this_ptr_conv.is_owned = false;
38040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38041         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
38042         uintptr_t ret_ref = 0;
38043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38046         ret_ref = (uintptr_t)ret_var.inner;
38047         if (ret_var.is_owned) {
38048                 ret_ref |= 1;
38049         }
38050         return ret_ref;
38051 }
38052
38053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38054         LDKNodeAnnouncementInfo this_ptr_conv;
38055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38056         this_ptr_conv.is_owned = false;
38057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38058         LDKNodeFeatures val_conv;
38059         val_conv.inner = (void*)(val & (~1));
38060         val_conv.is_owned = (val & 1) || (val == 0);
38061         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38062         val_conv = NodeFeatures_clone(&val_conv);
38063         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
38064 }
38065
38066 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
38067         LDKNodeAnnouncementInfo this_ptr_conv;
38068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38069         this_ptr_conv.is_owned = false;
38070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38071         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
38072         return ret_val;
38073 }
38074
38075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38076         LDKNodeAnnouncementInfo this_ptr_conv;
38077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38078         this_ptr_conv.is_owned = false;
38079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38080         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
38081 }
38082
38083 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
38084         LDKNodeAnnouncementInfo this_ptr_conv;
38085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38086         this_ptr_conv.is_owned = false;
38087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38088         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
38089         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
38090         return ret_arr;
38091 }
38092
38093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38094         LDKNodeAnnouncementInfo this_ptr_conv;
38095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38096         this_ptr_conv.is_owned = false;
38097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38098         LDKThreeBytes val_ref;
38099         CHECK((*env)->GetArrayLength(env, val) == 3);
38100         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
38101         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
38102 }
38103
38104 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
38105         LDKNodeAnnouncementInfo this_ptr_conv;
38106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38107         this_ptr_conv.is_owned = false;
38108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38109         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38110         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
38111         return ret_arr;
38112 }
38113
38114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38115         LDKNodeAnnouncementInfo this_ptr_conv;
38116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38117         this_ptr_conv.is_owned = false;
38118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38119         LDKThirtyTwoBytes val_ref;
38120         CHECK((*env)->GetArrayLength(env, val) == 32);
38121         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38122         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
38123 }
38124
38125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38126         LDKNodeAnnouncementInfo this_ptr_conv;
38127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38128         this_ptr_conv.is_owned = false;
38129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38130         LDKCVec_NetAddressZ val_constr;
38131         val_constr.datalen = (*env)->GetArrayLength(env, val);
38132         if (val_constr.datalen > 0)
38133                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
38134         else
38135                 val_constr.data = NULL;
38136         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38137         for (size_t m = 0; m < val_constr.datalen; m++) {
38138                 int64_t val_conv_12 = val_vals[m];
38139                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
38140                 CHECK_ACCESS(val_conv_12_ptr);
38141                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
38142                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
38143                 val_constr.data[m] = val_conv_12_conv;
38144         }
38145         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38146         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
38147 }
38148
38149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
38150         LDKNodeAnnouncementInfo this_ptr_conv;
38151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38152         this_ptr_conv.is_owned = false;
38153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38154         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
38155         uintptr_t ret_ref = 0;
38156         if ((uintptr_t)ret_var.inner > 4096) {
38157                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38158                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38160                 ret_ref = (uintptr_t)ret_var.inner;
38161                 if (ret_var.is_owned) {
38162                         ret_ref |= 1;
38163                 }
38164         }
38165         return ret_ref;
38166 }
38167
38168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38169         LDKNodeAnnouncementInfo this_ptr_conv;
38170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38171         this_ptr_conv.is_owned = false;
38172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38173         LDKNodeAnnouncement val_conv;
38174         val_conv.inner = (void*)(val & (~1));
38175         val_conv.is_owned = (val & 1) || (val == 0);
38176         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38177         val_conv = NodeAnnouncement_clone(&val_conv);
38178         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
38179 }
38180
38181 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) {
38182         LDKNodeFeatures features_arg_conv;
38183         features_arg_conv.inner = (void*)(features_arg & (~1));
38184         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
38185         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
38186         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
38187         LDKThreeBytes rgb_arg_ref;
38188         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
38189         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
38190         LDKThirtyTwoBytes alias_arg_ref;
38191         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
38192         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
38193         LDKCVec_NetAddressZ addresses_arg_constr;
38194         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
38195         if (addresses_arg_constr.datalen > 0)
38196                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
38197         else
38198                 addresses_arg_constr.data = NULL;
38199         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
38200         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
38201                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
38202                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
38203                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
38204                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
38205                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
38206         }
38207         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
38208         LDKNodeAnnouncement announcement_message_arg_conv;
38209         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
38210         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
38211         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
38212         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
38213         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
38214         uintptr_t ret_ref = 0;
38215         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38216         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38218         ret_ref = (uintptr_t)ret_var.inner;
38219         if (ret_var.is_owned) {
38220                 ret_ref |= 1;
38221         }
38222         return ret_ref;
38223 }
38224
38225 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
38226         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
38227 uintptr_t ret_ref = 0;
38228 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38229 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38230 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38231 ret_ref = (uintptr_t)ret_var.inner;
38232 if (ret_var.is_owned) {
38233         ret_ref |= 1;
38234 }
38235         return ret_ref;
38236 }
38237 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38238         LDKNodeAnnouncementInfo arg_conv;
38239         arg_conv.inner = (void*)(arg & (~1));
38240         arg_conv.is_owned = false;
38241         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38242         intptr_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
38243         return ret_val;
38244 }
38245
38246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38247         LDKNodeAnnouncementInfo orig_conv;
38248         orig_conv.inner = (void*)(orig & (~1));
38249         orig_conv.is_owned = false;
38250         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38251         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
38252         uintptr_t ret_ref = 0;
38253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38256         ret_ref = (uintptr_t)ret_var.inner;
38257         if (ret_var.is_owned) {
38258                 ret_ref |= 1;
38259         }
38260         return ret_ref;
38261 }
38262
38263 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
38264         LDKNodeAnnouncementInfo obj_conv;
38265         obj_conv.inner = (void*)(obj & (~1));
38266         obj_conv.is_owned = false;
38267         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38268         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
38269         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38270         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38271         CVec_u8Z_free(ret_var);
38272         return ret_arr;
38273 }
38274
38275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38276         LDKu8slice ser_ref;
38277         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38278         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38279         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
38280         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
38281         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38282         return (uintptr_t)ret_conv;
38283 }
38284
38285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38286         LDKNodeInfo this_obj_conv;
38287         this_obj_conv.inner = (void*)(this_obj & (~1));
38288         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38290         NodeInfo_free(this_obj_conv);
38291 }
38292
38293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38294         LDKNodeInfo this_ptr_conv;
38295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38296         this_ptr_conv.is_owned = false;
38297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38298         LDKCVec_u64Z val_constr;
38299         val_constr.datalen = (*env)->GetArrayLength(env, val);
38300         if (val_constr.datalen > 0)
38301                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
38302         else
38303                 val_constr.data = NULL;
38304         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38305         for (size_t g = 0; g < val_constr.datalen; g++) {
38306                 int64_t val_conv_6 = val_vals[g];
38307                 val_constr.data[g] = val_conv_6;
38308         }
38309         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38310         NodeInfo_set_channels(&this_ptr_conv, val_constr);
38311 }
38312
38313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
38314         LDKNodeInfo this_ptr_conv;
38315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38316         this_ptr_conv.is_owned = false;
38317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38318         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
38319         uintptr_t ret_ref = 0;
38320         if ((uintptr_t)ret_var.inner > 4096) {
38321                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38322                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38324                 ret_ref = (uintptr_t)ret_var.inner;
38325                 if (ret_var.is_owned) {
38326                         ret_ref |= 1;
38327                 }
38328         }
38329         return ret_ref;
38330 }
38331
38332 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) {
38333         LDKNodeInfo this_ptr_conv;
38334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38335         this_ptr_conv.is_owned = false;
38336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38337         LDKRoutingFees val_conv;
38338         val_conv.inner = (void*)(val & (~1));
38339         val_conv.is_owned = (val & 1) || (val == 0);
38340         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38341         val_conv = RoutingFees_clone(&val_conv);
38342         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
38343 }
38344
38345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
38346         LDKNodeInfo this_ptr_conv;
38347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38348         this_ptr_conv.is_owned = false;
38349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38350         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
38351         uintptr_t ret_ref = 0;
38352         if ((uintptr_t)ret_var.inner > 4096) {
38353                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38354                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38356                 ret_ref = (uintptr_t)ret_var.inner;
38357                 if (ret_var.is_owned) {
38358                         ret_ref |= 1;
38359                 }
38360         }
38361         return ret_ref;
38362 }
38363
38364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38365         LDKNodeInfo this_ptr_conv;
38366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38367         this_ptr_conv.is_owned = false;
38368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38369         LDKNodeAnnouncementInfo val_conv;
38370         val_conv.inner = (void*)(val & (~1));
38371         val_conv.is_owned = (val & 1) || (val == 0);
38372         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38373         val_conv = NodeAnnouncementInfo_clone(&val_conv);
38374         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
38375 }
38376
38377 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) {
38378         LDKCVec_u64Z channels_arg_constr;
38379         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
38380         if (channels_arg_constr.datalen > 0)
38381                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
38382         else
38383                 channels_arg_constr.data = NULL;
38384         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
38385         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
38386                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
38387                 channels_arg_constr.data[g] = channels_arg_conv_6;
38388         }
38389         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
38390         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
38391         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
38392         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
38393         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
38394         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
38395         LDKNodeAnnouncementInfo announcement_info_arg_conv;
38396         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
38397         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
38398         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
38399         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
38400         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
38401         uintptr_t ret_ref = 0;
38402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38405         ret_ref = (uintptr_t)ret_var.inner;
38406         if (ret_var.is_owned) {
38407                 ret_ref |= 1;
38408         }
38409         return ret_ref;
38410 }
38411
38412 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
38413         LDKNodeInfo ret_var = NodeInfo_clone(arg);
38414 uintptr_t ret_ref = 0;
38415 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38416 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38417 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38418 ret_ref = (uintptr_t)ret_var.inner;
38419 if (ret_var.is_owned) {
38420         ret_ref |= 1;
38421 }
38422         return ret_ref;
38423 }
38424 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38425         LDKNodeInfo arg_conv;
38426         arg_conv.inner = (void*)(arg & (~1));
38427         arg_conv.is_owned = false;
38428         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38429         intptr_t ret_val = NodeInfo_clone_ptr(&arg_conv);
38430         return ret_val;
38431 }
38432
38433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38434         LDKNodeInfo orig_conv;
38435         orig_conv.inner = (void*)(orig & (~1));
38436         orig_conv.is_owned = false;
38437         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38438         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
38439         uintptr_t ret_ref = 0;
38440         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38441         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38443         ret_ref = (uintptr_t)ret_var.inner;
38444         if (ret_var.is_owned) {
38445                 ret_ref |= 1;
38446         }
38447         return ret_ref;
38448 }
38449
38450 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
38451         LDKNodeInfo obj_conv;
38452         obj_conv.inner = (void*)(obj & (~1));
38453         obj_conv.is_owned = false;
38454         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38455         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
38456         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38457         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38458         CVec_u8Z_free(ret_var);
38459         return ret_arr;
38460 }
38461
38462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38463         LDKu8slice ser_ref;
38464         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38465         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38466         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
38467         *ret_conv = NodeInfo_read(ser_ref);
38468         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38469         return (uintptr_t)ret_conv;
38470 }
38471
38472 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
38473         LDKNetworkGraph obj_conv;
38474         obj_conv.inner = (void*)(obj & (~1));
38475         obj_conv.is_owned = false;
38476         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38477         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
38478         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38479         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38480         CVec_u8Z_free(ret_var);
38481         return ret_arr;
38482 }
38483
38484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38485         LDKu8slice ser_ref;
38486         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38487         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38488         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
38489         *ret_conv = NetworkGraph_read(ser_ref);
38490         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38491         return (uintptr_t)ret_conv;
38492 }
38493
38494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
38495         LDKThirtyTwoBytes genesis_hash_ref;
38496         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
38497         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
38498         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
38499         uintptr_t ret_ref = 0;
38500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38503         ret_ref = (uintptr_t)ret_var.inner;
38504         if (ret_var.is_owned) {
38505                 ret_ref |= 1;
38506         }
38507         return ret_ref;
38508 }
38509
38510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
38511         LDKNetworkGraph this_arg_conv;
38512         this_arg_conv.inner = (void*)(this_arg & (~1));
38513         this_arg_conv.is_owned = false;
38514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38515         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
38516         uintptr_t ret_ref = 0;
38517         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38518         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38520         ret_ref = (uintptr_t)ret_var.inner;
38521         if (ret_var.is_owned) {
38522                 ret_ref |= 1;
38523         }
38524         return ret_ref;
38525 }
38526
38527 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) {
38528         LDKNetworkGraph this_arg_conv;
38529         this_arg_conv.inner = (void*)(this_arg & (~1));
38530         this_arg_conv.is_owned = false;
38531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38532         LDKNodeAnnouncement msg_conv;
38533         msg_conv.inner = (void*)(msg & (~1));
38534         msg_conv.is_owned = false;
38535         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38536         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
38537         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
38538         return (uintptr_t)ret_conv;
38539 }
38540
38541 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) {
38542         LDKNetworkGraph this_arg_conv;
38543         this_arg_conv.inner = (void*)(this_arg & (~1));
38544         this_arg_conv.is_owned = false;
38545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38546         LDKUnsignedNodeAnnouncement msg_conv;
38547         msg_conv.inner = (void*)(msg & (~1));
38548         msg_conv.is_owned = false;
38549         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38550         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
38551         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
38552         return (uintptr_t)ret_conv;
38553 }
38554
38555 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) {
38556         LDKNetworkGraph this_arg_conv;
38557         this_arg_conv.inner = (void*)(this_arg & (~1));
38558         this_arg_conv.is_owned = false;
38559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38560         LDKChannelAnnouncement msg_conv;
38561         msg_conv.inner = (void*)(msg & (~1));
38562         msg_conv.is_owned = false;
38563         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38564         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
38565         CHECK_ACCESS(chain_access_ptr);
38566         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
38567         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
38568         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
38569                 // Manually implement clone for Java trait instances
38570                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
38571                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38572                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
38573                 }
38574         }
38575         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
38576         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
38577         return (uintptr_t)ret_conv;
38578 }
38579
38580 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) {
38581         LDKNetworkGraph this_arg_conv;
38582         this_arg_conv.inner = (void*)(this_arg & (~1));
38583         this_arg_conv.is_owned = false;
38584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38585         LDKUnsignedChannelAnnouncement msg_conv;
38586         msg_conv.inner = (void*)(msg & (~1));
38587         msg_conv.is_owned = false;
38588         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38589         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
38590         CHECK_ACCESS(chain_access_ptr);
38591         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
38592         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
38593         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
38594                 // Manually implement clone for Java trait instances
38595                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
38596                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38597                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
38598                 }
38599         }
38600         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
38601         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
38602         return (uintptr_t)ret_conv;
38603 }
38604
38605 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) {
38606         LDKNetworkGraph this_arg_conv;
38607         this_arg_conv.inner = (void*)(this_arg & (~1));
38608         this_arg_conv.is_owned = false;
38609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38610         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
38611 }
38612
38613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1fail_1node(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
38614         LDKNetworkGraph this_arg_conv;
38615         this_arg_conv.inner = (void*)(this_arg & (~1));
38616         this_arg_conv.is_owned = false;
38617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38618         LDKPublicKey _node_id_ref;
38619         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
38620         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
38621         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
38622 }
38623
38624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels_1with_1time(JNIEnv *env, jclass clz, int64_t this_arg, int64_t current_time_unix) {
38625         LDKNetworkGraph this_arg_conv;
38626         this_arg_conv.inner = (void*)(this_arg & (~1));
38627         this_arg_conv.is_owned = false;
38628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38629         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
38630 }
38631
38632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
38633         LDKNetworkGraph this_arg_conv;
38634         this_arg_conv.inner = (void*)(this_arg & (~1));
38635         this_arg_conv.is_owned = false;
38636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38637         LDKChannelUpdate msg_conv;
38638         msg_conv.inner = (void*)(msg & (~1));
38639         msg_conv.is_owned = false;
38640         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38641         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
38642         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
38643         return (uintptr_t)ret_conv;
38644 }
38645
38646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
38647         LDKNetworkGraph this_arg_conv;
38648         this_arg_conv.inner = (void*)(this_arg & (~1));
38649         this_arg_conv.is_owned = false;
38650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38651         LDKUnsignedChannelUpdate msg_conv;
38652         msg_conv.inner = (void*)(msg & (~1));
38653         msg_conv.is_owned = false;
38654         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
38655         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
38656         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
38657         return (uintptr_t)ret_conv;
38658 }
38659
38660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
38661         LDKReadOnlyNetworkGraph this_arg_conv;
38662         this_arg_conv.inner = (void*)(this_arg & (~1));
38663         this_arg_conv.is_owned = false;
38664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38665         LDKPublicKey pubkey_ref;
38666         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
38667         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
38668         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
38669         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
38670         uintptr_t ret_ref = (uintptr_t)ret_copy;
38671         return ret_ref;
38672 }
38673
38674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38675         LDKRouteHop this_obj_conv;
38676         this_obj_conv.inner = (void*)(this_obj & (~1));
38677         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38679         RouteHop_free(this_obj_conv);
38680 }
38681
38682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
38683         LDKRouteHop this_ptr_conv;
38684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38685         this_ptr_conv.is_owned = false;
38686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38687         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38688         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
38689         return ret_arr;
38690 }
38691
38692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38693         LDKRouteHop this_ptr_conv;
38694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38695         this_ptr_conv.is_owned = false;
38696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38697         LDKPublicKey val_ref;
38698         CHECK((*env)->GetArrayLength(env, val) == 33);
38699         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38700         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
38701 }
38702
38703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
38704         LDKRouteHop this_ptr_conv;
38705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38706         this_ptr_conv.is_owned = false;
38707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38708         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
38709         uintptr_t ret_ref = 0;
38710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38713         ret_ref = (uintptr_t)ret_var.inner;
38714         if (ret_var.is_owned) {
38715                 ret_ref |= 1;
38716         }
38717         return ret_ref;
38718 }
38719
38720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38721         LDKRouteHop this_ptr_conv;
38722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38723         this_ptr_conv.is_owned = false;
38724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38725         LDKNodeFeatures val_conv;
38726         val_conv.inner = (void*)(val & (~1));
38727         val_conv.is_owned = (val & 1) || (val == 0);
38728         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38729         val_conv = NodeFeatures_clone(&val_conv);
38730         RouteHop_set_node_features(&this_ptr_conv, val_conv);
38731 }
38732
38733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38734         LDKRouteHop this_ptr_conv;
38735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38736         this_ptr_conv.is_owned = false;
38737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38738         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
38739         return ret_val;
38740 }
38741
38742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38743         LDKRouteHop this_ptr_conv;
38744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38745         this_ptr_conv.is_owned = false;
38746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38747         RouteHop_set_short_channel_id(&this_ptr_conv, val);
38748 }
38749
38750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
38751         LDKRouteHop this_ptr_conv;
38752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38753         this_ptr_conv.is_owned = false;
38754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38755         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
38756         uintptr_t ret_ref = 0;
38757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38760         ret_ref = (uintptr_t)ret_var.inner;
38761         if (ret_var.is_owned) {
38762                 ret_ref |= 1;
38763         }
38764         return ret_ref;
38765 }
38766
38767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38768         LDKRouteHop this_ptr_conv;
38769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38770         this_ptr_conv.is_owned = false;
38771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38772         LDKChannelFeatures val_conv;
38773         val_conv.inner = (void*)(val & (~1));
38774         val_conv.is_owned = (val & 1) || (val == 0);
38775         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38776         val_conv = ChannelFeatures_clone(&val_conv);
38777         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
38778 }
38779
38780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38781         LDKRouteHop this_ptr_conv;
38782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38783         this_ptr_conv.is_owned = false;
38784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38785         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
38786         return ret_val;
38787 }
38788
38789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38790         LDKRouteHop this_ptr_conv;
38791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38792         this_ptr_conv.is_owned = false;
38793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38794         RouteHop_set_fee_msat(&this_ptr_conv, val);
38795 }
38796
38797 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
38798         LDKRouteHop this_ptr_conv;
38799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38800         this_ptr_conv.is_owned = false;
38801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38802         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
38803         return ret_val;
38804 }
38805
38806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38807         LDKRouteHop this_ptr_conv;
38808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38809         this_ptr_conv.is_owned = false;
38810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38811         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
38812 }
38813
38814 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) {
38815         LDKPublicKey pubkey_arg_ref;
38816         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
38817         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
38818         LDKNodeFeatures node_features_arg_conv;
38819         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
38820         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
38821         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
38822         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
38823         LDKChannelFeatures channel_features_arg_conv;
38824         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
38825         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
38826         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
38827         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
38828         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);
38829         uintptr_t ret_ref = 0;
38830         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38831         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38833         ret_ref = (uintptr_t)ret_var.inner;
38834         if (ret_var.is_owned) {
38835                 ret_ref |= 1;
38836         }
38837         return ret_ref;
38838 }
38839
38840 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
38841         LDKRouteHop ret_var = RouteHop_clone(arg);
38842 uintptr_t ret_ref = 0;
38843 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38844 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38845 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38846 ret_ref = (uintptr_t)ret_var.inner;
38847 if (ret_var.is_owned) {
38848         ret_ref |= 1;
38849 }
38850         return ret_ref;
38851 }
38852 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38853         LDKRouteHop arg_conv;
38854         arg_conv.inner = (void*)(arg & (~1));
38855         arg_conv.is_owned = false;
38856         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38857         intptr_t ret_val = RouteHop_clone_ptr(&arg_conv);
38858         return ret_val;
38859 }
38860
38861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38862         LDKRouteHop orig_conv;
38863         orig_conv.inner = (void*)(orig & (~1));
38864         orig_conv.is_owned = false;
38865         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38866         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
38867         uintptr_t ret_ref = 0;
38868         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38869         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38871         ret_ref = (uintptr_t)ret_var.inner;
38872         if (ret_var.is_owned) {
38873                 ret_ref |= 1;
38874         }
38875         return ret_ref;
38876 }
38877
38878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
38879         LDKRouteHop o_conv;
38880         o_conv.inner = (void*)(o & (~1));
38881         o_conv.is_owned = false;
38882         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38883         int64_t ret_val = RouteHop_hash(&o_conv);
38884         return ret_val;
38885 }
38886
38887 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38888         LDKRouteHop a_conv;
38889         a_conv.inner = (void*)(a & (~1));
38890         a_conv.is_owned = false;
38891         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38892         LDKRouteHop b_conv;
38893         b_conv.inner = (void*)(b & (~1));
38894         b_conv.is_owned = false;
38895         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38896         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
38897         return ret_val;
38898 }
38899
38900 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
38901         LDKRouteHop obj_conv;
38902         obj_conv.inner = (void*)(obj & (~1));
38903         obj_conv.is_owned = false;
38904         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38905         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
38906         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38907         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38908         CVec_u8Z_free(ret_var);
38909         return ret_arr;
38910 }
38911
38912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38913         LDKu8slice ser_ref;
38914         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38915         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38916         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
38917         *ret_conv = RouteHop_read(ser_ref);
38918         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38919         return (uintptr_t)ret_conv;
38920 }
38921
38922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38923         LDKRoute this_obj_conv;
38924         this_obj_conv.inner = (void*)(this_obj & (~1));
38925         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38927         Route_free(this_obj_conv);
38928 }
38929
38930 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
38931         LDKRoute this_ptr_conv;
38932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38933         this_ptr_conv.is_owned = false;
38934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38935         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
38936         jobjectArray ret_arr = NULL;
38937         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
38938         ;
38939         for (size_t m = 0; m < ret_var.datalen; m++) {
38940                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
38941                 int64_tArray ret_conv_12_arr = NULL;
38942                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
38943                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
38944                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
38945                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
38946                         uintptr_t ret_conv_12_conv_10_ref = 0;
38947                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38948                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38949                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
38950                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
38951                         if (ret_conv_12_conv_10_var.is_owned) {
38952                                 ret_conv_12_conv_10_ref |= 1;
38953                         }
38954                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
38955                 }
38956                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
38957                 FREE(ret_conv_12_var.data);
38958                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
38959         }
38960         
38961         FREE(ret_var.data);
38962         return ret_arr;
38963 }
38964
38965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
38966         LDKRoute this_ptr_conv;
38967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38968         this_ptr_conv.is_owned = false;
38969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38970         LDKCVec_CVec_RouteHopZZ val_constr;
38971         val_constr.datalen = (*env)->GetArrayLength(env, val);
38972         if (val_constr.datalen > 0)
38973                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
38974         else
38975                 val_constr.data = NULL;
38976         for (size_t m = 0; m < val_constr.datalen; m++) {
38977                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
38978                 LDKCVec_RouteHopZ val_conv_12_constr;
38979                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
38980                 if (val_conv_12_constr.datalen > 0)
38981                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
38982                 else
38983                         val_conv_12_constr.data = NULL;
38984                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
38985                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
38986                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
38987                         LDKRouteHop val_conv_12_conv_10_conv;
38988                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
38989                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
38990                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
38991                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
38992                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
38993                 }
38994                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
38995                 val_constr.data[m] = val_conv_12_constr;
38996         }
38997         Route_set_paths(&this_ptr_conv, val_constr);
38998 }
38999
39000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payee(JNIEnv *env, jclass clz, int64_t this_ptr) {
39001         LDKRoute this_ptr_conv;
39002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39003         this_ptr_conv.is_owned = false;
39004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39005         LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
39006         uintptr_t ret_ref = 0;
39007         if ((uintptr_t)ret_var.inner > 4096) {
39008                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39009                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39011                 ret_ref = (uintptr_t)ret_var.inner;
39012                 if (ret_var.is_owned) {
39013                         ret_ref |= 1;
39014                 }
39015         }
39016         return ret_ref;
39017 }
39018
39019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39020         LDKRoute this_ptr_conv;
39021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39022         this_ptr_conv.is_owned = false;
39023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39024         LDKPayee val_conv;
39025         val_conv.inner = (void*)(val & (~1));
39026         val_conv.is_owned = (val & 1) || (val == 0);
39027         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39028         val_conv = Payee_clone(&val_conv);
39029         Route_set_payee(&this_ptr_conv, val_conv);
39030 }
39031
39032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payee_arg) {
39033         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
39034         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
39035         if (paths_arg_constr.datalen > 0)
39036                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
39037         else
39038                 paths_arg_constr.data = NULL;
39039         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
39040                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
39041                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
39042                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
39043                 if (paths_arg_conv_12_constr.datalen > 0)
39044                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
39045                 else
39046                         paths_arg_conv_12_constr.data = NULL;
39047                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
39048                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
39049                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
39050                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
39051                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
39052                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
39053                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
39054                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
39055                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
39056                 }
39057                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
39058                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
39059         }
39060         LDKPayee payee_arg_conv;
39061         payee_arg_conv.inner = (void*)(payee_arg & (~1));
39062         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
39063         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
39064         payee_arg_conv = Payee_clone(&payee_arg_conv);
39065         LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
39066         uintptr_t ret_ref = 0;
39067         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39068         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39070         ret_ref = (uintptr_t)ret_var.inner;
39071         if (ret_var.is_owned) {
39072                 ret_ref |= 1;
39073         }
39074         return ret_ref;
39075 }
39076
39077 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
39078         LDKRoute ret_var = Route_clone(arg);
39079 uintptr_t ret_ref = 0;
39080 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39081 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39082 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39083 ret_ref = (uintptr_t)ret_var.inner;
39084 if (ret_var.is_owned) {
39085         ret_ref |= 1;
39086 }
39087         return ret_ref;
39088 }
39089 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39090         LDKRoute arg_conv;
39091         arg_conv.inner = (void*)(arg & (~1));
39092         arg_conv.is_owned = false;
39093         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39094         intptr_t ret_val = Route_clone_ptr(&arg_conv);
39095         return ret_val;
39096 }
39097
39098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39099         LDKRoute orig_conv;
39100         orig_conv.inner = (void*)(orig & (~1));
39101         orig_conv.is_owned = false;
39102         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39103         LDKRoute ret_var = Route_clone(&orig_conv);
39104         uintptr_t ret_ref = 0;
39105         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39106         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39108         ret_ref = (uintptr_t)ret_var.inner;
39109         if (ret_var.is_owned) {
39110                 ret_ref |= 1;
39111         }
39112         return ret_ref;
39113 }
39114
39115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
39116         LDKRoute o_conv;
39117         o_conv.inner = (void*)(o & (~1));
39118         o_conv.is_owned = false;
39119         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39120         int64_t ret_val = Route_hash(&o_conv);
39121         return ret_val;
39122 }
39123
39124 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39125         LDKRoute a_conv;
39126         a_conv.inner = (void*)(a & (~1));
39127         a_conv.is_owned = false;
39128         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39129         LDKRoute b_conv;
39130         b_conv.inner = (void*)(b & (~1));
39131         b_conv.is_owned = false;
39132         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39133         jboolean ret_val = Route_eq(&a_conv, &b_conv);
39134         return ret_val;
39135 }
39136
39137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
39138         LDKRoute this_arg_conv;
39139         this_arg_conv.inner = (void*)(this_arg & (~1));
39140         this_arg_conv.is_owned = false;
39141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39142         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
39143         return ret_val;
39144 }
39145
39146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
39147         LDKRoute this_arg_conv;
39148         this_arg_conv.inner = (void*)(this_arg & (~1));
39149         this_arg_conv.is_owned = false;
39150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39151         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
39152         return ret_val;
39153 }
39154
39155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
39156         LDKRoute obj_conv;
39157         obj_conv.inner = (void*)(obj & (~1));
39158         obj_conv.is_owned = false;
39159         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39160         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
39161         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39162         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39163         CVec_u8Z_free(ret_var);
39164         return ret_arr;
39165 }
39166
39167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39168         LDKu8slice ser_ref;
39169         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39170         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39171         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
39172         *ret_conv = Route_read(ser_ref);
39173         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39174         return (uintptr_t)ret_conv;
39175 }
39176
39177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39178         LDKRouteParameters this_obj_conv;
39179         this_obj_conv.inner = (void*)(this_obj & (~1));
39180         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39182         RouteParameters_free(this_obj_conv);
39183 }
39184
39185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payee(JNIEnv *env, jclass clz, int64_t this_ptr) {
39186         LDKRouteParameters this_ptr_conv;
39187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39188         this_ptr_conv.is_owned = false;
39189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39190         LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
39191         uintptr_t ret_ref = 0;
39192         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39193         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39195         ret_ref = (uintptr_t)ret_var.inner;
39196         if (ret_var.is_owned) {
39197                 ret_ref |= 1;
39198         }
39199         return ret_ref;
39200 }
39201
39202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39203         LDKRouteParameters this_ptr_conv;
39204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39205         this_ptr_conv.is_owned = false;
39206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39207         LDKPayee val_conv;
39208         val_conv.inner = (void*)(val & (~1));
39209         val_conv.is_owned = (val & 1) || (val == 0);
39210         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39211         val_conv = Payee_clone(&val_conv);
39212         RouteParameters_set_payee(&this_ptr_conv, val_conv);
39213 }
39214
39215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39216         LDKRouteParameters this_ptr_conv;
39217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39218         this_ptr_conv.is_owned = false;
39219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39220         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
39221         return ret_val;
39222 }
39223
39224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39225         LDKRouteParameters this_ptr_conv;
39226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39227         this_ptr_conv.is_owned = false;
39228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39229         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
39230 }
39231
39232 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
39233         LDKRouteParameters this_ptr_conv;
39234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39235         this_ptr_conv.is_owned = false;
39236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39237         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
39238         return ret_val;
39239 }
39240
39241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39242         LDKRouteParameters this_ptr_conv;
39243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39244         this_ptr_conv.is_owned = false;
39245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39246         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
39247 }
39248
39249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1new(JNIEnv *env, jclass clz, int64_t payee_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
39250         LDKPayee payee_arg_conv;
39251         payee_arg_conv.inner = (void*)(payee_arg & (~1));
39252         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
39253         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
39254         payee_arg_conv = Payee_clone(&payee_arg_conv);
39255         LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
39256         uintptr_t ret_ref = 0;
39257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39260         ret_ref = (uintptr_t)ret_var.inner;
39261         if (ret_var.is_owned) {
39262                 ret_ref |= 1;
39263         }
39264         return ret_ref;
39265 }
39266
39267 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
39268         LDKRouteParameters ret_var = RouteParameters_clone(arg);
39269 uintptr_t ret_ref = 0;
39270 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39271 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39272 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39273 ret_ref = (uintptr_t)ret_var.inner;
39274 if (ret_var.is_owned) {
39275         ret_ref |= 1;
39276 }
39277         return ret_ref;
39278 }
39279 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39280         LDKRouteParameters arg_conv;
39281         arg_conv.inner = (void*)(arg & (~1));
39282         arg_conv.is_owned = false;
39283         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39284         intptr_t ret_val = RouteParameters_clone_ptr(&arg_conv);
39285         return ret_val;
39286 }
39287
39288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39289         LDKRouteParameters orig_conv;
39290         orig_conv.inner = (void*)(orig & (~1));
39291         orig_conv.is_owned = false;
39292         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39293         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
39294         uintptr_t ret_ref = 0;
39295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39298         ret_ref = (uintptr_t)ret_var.inner;
39299         if (ret_var.is_owned) {
39300                 ret_ref |= 1;
39301         }
39302         return ret_ref;
39303 }
39304
39305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
39306         LDKRouteParameters obj_conv;
39307         obj_conv.inner = (void*)(obj & (~1));
39308         obj_conv.is_owned = false;
39309         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39310         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
39311         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39312         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39313         CVec_u8Z_free(ret_var);
39314         return ret_arr;
39315 }
39316
39317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39318         LDKu8slice ser_ref;
39319         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39320         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39321         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
39322         *ret_conv = RouteParameters_read(ser_ref);
39323         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39324         return (uintptr_t)ret_conv;
39325 }
39326
39327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39328         LDKPayee this_obj_conv;
39329         this_obj_conv.inner = (void*)(this_obj & (~1));
39330         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39332         Payee_free(this_obj_conv);
39333 }
39334
39335 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
39336         LDKPayee this_ptr_conv;
39337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39338         this_ptr_conv.is_owned = false;
39339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39340         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39341         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Payee_get_pubkey(&this_ptr_conv).compressed_form);
39342         return ret_arr;
39343 }
39344
39345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39346         LDKPayee this_ptr_conv;
39347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39348         this_ptr_conv.is_owned = false;
39349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39350         LDKPublicKey val_ref;
39351         CHECK((*env)->GetArrayLength(env, val) == 33);
39352         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39353         Payee_set_pubkey(&this_ptr_conv, val_ref);
39354 }
39355
39356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
39357         LDKPayee this_ptr_conv;
39358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39359         this_ptr_conv.is_owned = false;
39360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39361         LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
39362         uintptr_t ret_ref = 0;
39363         if ((uintptr_t)ret_var.inner > 4096) {
39364                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39365                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39367                 ret_ref = (uintptr_t)ret_var.inner;
39368                 if (ret_var.is_owned) {
39369                         ret_ref |= 1;
39370                 }
39371         }
39372         return ret_ref;
39373 }
39374
39375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39376         LDKPayee this_ptr_conv;
39377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39378         this_ptr_conv.is_owned = false;
39379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39380         LDKInvoiceFeatures val_conv;
39381         val_conv.inner = (void*)(val & (~1));
39382         val_conv.is_owned = (val & 1) || (val == 0);
39383         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39384         val_conv = InvoiceFeatures_clone(&val_conv);
39385         Payee_set_features(&this_ptr_conv, val_conv);
39386 }
39387
39388 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
39389         LDKPayee this_ptr_conv;
39390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39391         this_ptr_conv.is_owned = false;
39392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39393         LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
39394         int64_tArray ret_arr = NULL;
39395         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39396         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39397         for (size_t l = 0; l < ret_var.datalen; l++) {
39398                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
39399                 uintptr_t ret_conv_11_ref = 0;
39400                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39401                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39402                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
39403                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
39404                 if (ret_conv_11_var.is_owned) {
39405                         ret_conv_11_ref |= 1;
39406                 }
39407                 ret_arr_ptr[l] = ret_conv_11_ref;
39408         }
39409         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39410         FREE(ret_var.data);
39411         return ret_arr;
39412 }
39413
39414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39415         LDKPayee this_ptr_conv;
39416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39417         this_ptr_conv.is_owned = false;
39418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39419         LDKCVec_RouteHintZ val_constr;
39420         val_constr.datalen = (*env)->GetArrayLength(env, val);
39421         if (val_constr.datalen > 0)
39422                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
39423         else
39424                 val_constr.data = NULL;
39425         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39426         for (size_t l = 0; l < val_constr.datalen; l++) {
39427                 int64_t val_conv_11 = val_vals[l];
39428                 LDKRouteHint val_conv_11_conv;
39429                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
39430                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
39431                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
39432                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
39433                 val_constr.data[l] = val_conv_11_conv;
39434         }
39435         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39436         Payee_set_route_hints(&this_ptr_conv, val_constr);
39437 }
39438
39439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
39440         LDKPayee this_ptr_conv;
39441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39442         this_ptr_conv.is_owned = false;
39443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39444         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39445         *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
39446         uintptr_t ret_ref = (uintptr_t)ret_copy;
39447         return ret_ref;
39448 }
39449
39450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39451         LDKPayee this_ptr_conv;
39452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39453         this_ptr_conv.is_owned = false;
39454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39455         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39456         CHECK_ACCESS(val_ptr);
39457         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
39458         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
39459         Payee_set_expiry_time(&this_ptr_conv, val_conv);
39460 }
39461
39462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1new(JNIEnv *env, jclass clz, int8_tArray pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg) {
39463         LDKPublicKey pubkey_arg_ref;
39464         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
39465         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
39466         LDKInvoiceFeatures features_arg_conv;
39467         features_arg_conv.inner = (void*)(features_arg & (~1));
39468         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
39469         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
39470         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
39471         LDKCVec_RouteHintZ route_hints_arg_constr;
39472         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
39473         if (route_hints_arg_constr.datalen > 0)
39474                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
39475         else
39476                 route_hints_arg_constr.data = NULL;
39477         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
39478         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
39479                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
39480                 LDKRouteHint route_hints_arg_conv_11_conv;
39481                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
39482                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
39483                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
39484                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
39485                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
39486         }
39487         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
39488         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
39489         CHECK_ACCESS(expiry_time_arg_ptr);
39490         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
39491         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
39492         LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
39493         uintptr_t ret_ref = 0;
39494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39497         ret_ref = (uintptr_t)ret_var.inner;
39498         if (ret_var.is_owned) {
39499                 ret_ref |= 1;
39500         }
39501         return ret_ref;
39502 }
39503
39504 static inline uintptr_t Payee_clone_ptr(LDKPayee *NONNULL_PTR arg) {
39505         LDKPayee ret_var = Payee_clone(arg);
39506 uintptr_t ret_ref = 0;
39507 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39508 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39509 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39510 ret_ref = (uintptr_t)ret_var.inner;
39511 if (ret_var.is_owned) {
39512         ret_ref |= 1;
39513 }
39514         return ret_ref;
39515 }
39516 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Payee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39517         LDKPayee arg_conv;
39518         arg_conv.inner = (void*)(arg & (~1));
39519         arg_conv.is_owned = false;
39520         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39521         intptr_t ret_val = Payee_clone_ptr(&arg_conv);
39522         return ret_val;
39523 }
39524
39525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39526         LDKPayee orig_conv;
39527         orig_conv.inner = (void*)(orig & (~1));
39528         orig_conv.is_owned = false;
39529         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39530         LDKPayee ret_var = Payee_clone(&orig_conv);
39531         uintptr_t ret_ref = 0;
39532         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39533         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39535         ret_ref = (uintptr_t)ret_var.inner;
39536         if (ret_var.is_owned) {
39537                 ret_ref |= 1;
39538         }
39539         return ret_ref;
39540 }
39541
39542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1hash(JNIEnv *env, jclass clz, int64_t o) {
39543         LDKPayee o_conv;
39544         o_conv.inner = (void*)(o & (~1));
39545         o_conv.is_owned = false;
39546         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39547         int64_t ret_val = Payee_hash(&o_conv);
39548         return ret_val;
39549 }
39550
39551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Payee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39552         LDKPayee a_conv;
39553         a_conv.inner = (void*)(a & (~1));
39554         a_conv.is_owned = false;
39555         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39556         LDKPayee b_conv;
39557         b_conv.inner = (void*)(b & (~1));
39558         b_conv.is_owned = false;
39559         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39560         jboolean ret_val = Payee_eq(&a_conv, &b_conv);
39561         return ret_val;
39562 }
39563
39564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1write(JNIEnv *env, jclass clz, int64_t obj) {
39565         LDKPayee obj_conv;
39566         obj_conv.inner = (void*)(obj & (~1));
39567         obj_conv.is_owned = false;
39568         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39569         LDKCVec_u8Z ret_var = Payee_write(&obj_conv);
39570         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39571         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39572         CVec_u8Z_free(ret_var);
39573         return ret_arr;
39574 }
39575
39576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39577         LDKu8slice ser_ref;
39578         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39579         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39580         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
39581         *ret_conv = Payee_read(ser_ref);
39582         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39583         return (uintptr_t)ret_conv;
39584 }
39585
39586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray pubkey) {
39587         LDKPublicKey pubkey_ref;
39588         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
39589         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
39590         LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
39591         uintptr_t ret_ref = 0;
39592         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39593         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39595         ret_ref = (uintptr_t)ret_var.inner;
39596         if (ret_var.is_owned) {
39597                 ret_ref |= 1;
39598         }
39599         return ret_ref;
39600 }
39601
39602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray pubkey) {
39603         LDKPublicKey pubkey_ref;
39604         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
39605         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
39606         LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
39607         uintptr_t ret_ref = 0;
39608         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39609         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39611         ret_ref = (uintptr_t)ret_var.inner;
39612         if (ret_var.is_owned) {
39613                 ret_ref |= 1;
39614         }
39615         return ret_ref;
39616 }
39617
39618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39619         LDKRouteHint this_obj_conv;
39620         this_obj_conv.inner = (void*)(this_obj & (~1));
39621         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39623         RouteHint_free(this_obj_conv);
39624 }
39625
39626 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
39627         LDKRouteHint this_ptr_conv;
39628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39629         this_ptr_conv.is_owned = false;
39630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39631         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
39632         int64_tArray ret_arr = NULL;
39633         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39634         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39635         for (size_t o = 0; o < ret_var.datalen; o++) {
39636                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
39637                 uintptr_t ret_conv_14_ref = 0;
39638                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39639                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39640                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
39641                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
39642                 if (ret_conv_14_var.is_owned) {
39643                         ret_conv_14_ref |= 1;
39644                 }
39645                 ret_arr_ptr[o] = ret_conv_14_ref;
39646         }
39647         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39648         FREE(ret_var.data);
39649         return ret_arr;
39650 }
39651
39652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39653         LDKRouteHint this_ptr_conv;
39654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39655         this_ptr_conv.is_owned = false;
39656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39657         LDKCVec_RouteHintHopZ val_constr;
39658         val_constr.datalen = (*env)->GetArrayLength(env, val);
39659         if (val_constr.datalen > 0)
39660                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
39661         else
39662                 val_constr.data = NULL;
39663         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39664         for (size_t o = 0; o < val_constr.datalen; o++) {
39665                 int64_t val_conv_14 = val_vals[o];
39666                 LDKRouteHintHop val_conv_14_conv;
39667                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
39668                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
39669                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
39670                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
39671                 val_constr.data[o] = val_conv_14_conv;
39672         }
39673         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39674         RouteHint_set_a(&this_ptr_conv, val_constr);
39675 }
39676
39677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
39678         LDKCVec_RouteHintHopZ a_arg_constr;
39679         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
39680         if (a_arg_constr.datalen > 0)
39681                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
39682         else
39683                 a_arg_constr.data = NULL;
39684         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
39685         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
39686                 int64_t a_arg_conv_14 = a_arg_vals[o];
39687                 LDKRouteHintHop a_arg_conv_14_conv;
39688                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
39689                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
39690                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
39691                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
39692                 a_arg_constr.data[o] = a_arg_conv_14_conv;
39693         }
39694         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
39695         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
39696         uintptr_t ret_ref = 0;
39697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39700         ret_ref = (uintptr_t)ret_var.inner;
39701         if (ret_var.is_owned) {
39702                 ret_ref |= 1;
39703         }
39704         return ret_ref;
39705 }
39706
39707 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
39708         LDKRouteHint ret_var = RouteHint_clone(arg);
39709 uintptr_t ret_ref = 0;
39710 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39711 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39712 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39713 ret_ref = (uintptr_t)ret_var.inner;
39714 if (ret_var.is_owned) {
39715         ret_ref |= 1;
39716 }
39717         return ret_ref;
39718 }
39719 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39720         LDKRouteHint arg_conv;
39721         arg_conv.inner = (void*)(arg & (~1));
39722         arg_conv.is_owned = false;
39723         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39724         intptr_t ret_val = RouteHint_clone_ptr(&arg_conv);
39725         return ret_val;
39726 }
39727
39728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39729         LDKRouteHint orig_conv;
39730         orig_conv.inner = (void*)(orig & (~1));
39731         orig_conv.is_owned = false;
39732         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39733         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
39734         uintptr_t ret_ref = 0;
39735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39738         ret_ref = (uintptr_t)ret_var.inner;
39739         if (ret_var.is_owned) {
39740                 ret_ref |= 1;
39741         }
39742         return ret_ref;
39743 }
39744
39745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
39746         LDKRouteHint o_conv;
39747         o_conv.inner = (void*)(o & (~1));
39748         o_conv.is_owned = false;
39749         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39750         int64_t ret_val = RouteHint_hash(&o_conv);
39751         return ret_val;
39752 }
39753
39754 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39755         LDKRouteHint a_conv;
39756         a_conv.inner = (void*)(a & (~1));
39757         a_conv.is_owned = false;
39758         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39759         LDKRouteHint b_conv;
39760         b_conv.inner = (void*)(b & (~1));
39761         b_conv.is_owned = false;
39762         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39763         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
39764         return ret_val;
39765 }
39766
39767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
39768         LDKRouteHint obj_conv;
39769         obj_conv.inner = (void*)(obj & (~1));
39770         obj_conv.is_owned = false;
39771         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39772         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
39773         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39774         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39775         CVec_u8Z_free(ret_var);
39776         return ret_arr;
39777 }
39778
39779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39780         LDKu8slice ser_ref;
39781         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39782         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39783         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
39784         *ret_conv = RouteHint_read(ser_ref);
39785         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39786         return (uintptr_t)ret_conv;
39787 }
39788
39789 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39790         LDKRouteHintHop this_obj_conv;
39791         this_obj_conv.inner = (void*)(this_obj & (~1));
39792         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39794         RouteHintHop_free(this_obj_conv);
39795 }
39796
39797 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
39798         LDKRouteHintHop this_ptr_conv;
39799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39800         this_ptr_conv.is_owned = false;
39801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39802         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39803         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
39804         return ret_arr;
39805 }
39806
39807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39808         LDKRouteHintHop this_ptr_conv;
39809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39810         this_ptr_conv.is_owned = false;
39811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39812         LDKPublicKey val_ref;
39813         CHECK((*env)->GetArrayLength(env, val) == 33);
39814         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39815         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
39816 }
39817
39818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
39819         LDKRouteHintHop this_ptr_conv;
39820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39821         this_ptr_conv.is_owned = false;
39822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39823         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
39824         return ret_val;
39825 }
39826
39827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39828         LDKRouteHintHop this_ptr_conv;
39829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39830         this_ptr_conv.is_owned = false;
39831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39832         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
39833 }
39834
39835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
39836         LDKRouteHintHop this_ptr_conv;
39837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39838         this_ptr_conv.is_owned = false;
39839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39840         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
39841         uintptr_t ret_ref = 0;
39842         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39843         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39845         ret_ref = (uintptr_t)ret_var.inner;
39846         if (ret_var.is_owned) {
39847                 ret_ref |= 1;
39848         }
39849         return ret_ref;
39850 }
39851
39852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39853         LDKRouteHintHop this_ptr_conv;
39854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39855         this_ptr_conv.is_owned = false;
39856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39857         LDKRoutingFees val_conv;
39858         val_conv.inner = (void*)(val & (~1));
39859         val_conv.is_owned = (val & 1) || (val == 0);
39860         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39861         val_conv = RoutingFees_clone(&val_conv);
39862         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
39863 }
39864
39865 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
39866         LDKRouteHintHop this_ptr_conv;
39867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39868         this_ptr_conv.is_owned = false;
39869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39870         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
39871         return ret_val;
39872 }
39873
39874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39875         LDKRouteHintHop this_ptr_conv;
39876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39877         this_ptr_conv.is_owned = false;
39878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39879         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
39880 }
39881
39882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39883         LDKRouteHintHop this_ptr_conv;
39884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39885         this_ptr_conv.is_owned = false;
39886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39887         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39888         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
39889         uintptr_t ret_ref = (uintptr_t)ret_copy;
39890         return ret_ref;
39891 }
39892
39893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39894         LDKRouteHintHop this_ptr_conv;
39895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39896         this_ptr_conv.is_owned = false;
39897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39898         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39899         CHECK_ACCESS(val_ptr);
39900         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
39901         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
39902         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
39903 }
39904
39905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39906         LDKRouteHintHop this_ptr_conv;
39907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39908         this_ptr_conv.is_owned = false;
39909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39910         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39911         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
39912         uintptr_t ret_ref = (uintptr_t)ret_copy;
39913         return ret_ref;
39914 }
39915
39916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39917         LDKRouteHintHop this_ptr_conv;
39918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39919         this_ptr_conv.is_owned = false;
39920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39921         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39922         CHECK_ACCESS(val_ptr);
39923         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
39924         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
39925         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
39926 }
39927
39928 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) {
39929         LDKPublicKey src_node_id_arg_ref;
39930         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
39931         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
39932         LDKRoutingFees fees_arg_conv;
39933         fees_arg_conv.inner = (void*)(fees_arg & (~1));
39934         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
39935         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
39936         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
39937         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
39938         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
39939         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
39940         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
39941         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
39942         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
39943         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
39944         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
39945         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);
39946         uintptr_t ret_ref = 0;
39947         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39948         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39950         ret_ref = (uintptr_t)ret_var.inner;
39951         if (ret_var.is_owned) {
39952                 ret_ref |= 1;
39953         }
39954         return ret_ref;
39955 }
39956
39957 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
39958         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
39959 uintptr_t ret_ref = 0;
39960 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39961 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39962 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39963 ret_ref = (uintptr_t)ret_var.inner;
39964 if (ret_var.is_owned) {
39965         ret_ref |= 1;
39966 }
39967         return ret_ref;
39968 }
39969 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39970         LDKRouteHintHop arg_conv;
39971         arg_conv.inner = (void*)(arg & (~1));
39972         arg_conv.is_owned = false;
39973         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39974         intptr_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
39975         return ret_val;
39976 }
39977
39978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39979         LDKRouteHintHop orig_conv;
39980         orig_conv.inner = (void*)(orig & (~1));
39981         orig_conv.is_owned = false;
39982         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39983         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
39984         uintptr_t ret_ref = 0;
39985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39988         ret_ref = (uintptr_t)ret_var.inner;
39989         if (ret_var.is_owned) {
39990                 ret_ref |= 1;
39991         }
39992         return ret_ref;
39993 }
39994
39995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
39996         LDKRouteHintHop o_conv;
39997         o_conv.inner = (void*)(o & (~1));
39998         o_conv.is_owned = false;
39999         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40000         int64_t ret_val = RouteHintHop_hash(&o_conv);
40001         return ret_val;
40002 }
40003
40004 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40005         LDKRouteHintHop a_conv;
40006         a_conv.inner = (void*)(a & (~1));
40007         a_conv.is_owned = false;
40008         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40009         LDKRouteHintHop b_conv;
40010         b_conv.inner = (void*)(b & (~1));
40011         b_conv.is_owned = false;
40012         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40013         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
40014         return ret_val;
40015 }
40016
40017 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
40018         LDKRouteHintHop obj_conv;
40019         obj_conv.inner = (void*)(obj & (~1));
40020         obj_conv.is_owned = false;
40021         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40022         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
40023         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40024         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40025         CVec_u8Z_free(ret_var);
40026         return ret_arr;
40027 }
40028
40029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40030         LDKu8slice ser_ref;
40031         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40032         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40033         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
40034         *ret_conv = RouteHintHop_read(ser_ref);
40035         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40036         return (uintptr_t)ret_conv;
40037 }
40038
40039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t params, int64_t network, int64_tArray first_hops, int64_t logger, int64_t scorer) {
40040         LDKPublicKey our_node_pubkey_ref;
40041         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
40042         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
40043         LDKRouteParameters params_conv;
40044         params_conv.inner = (void*)(params & (~1));
40045         params_conv.is_owned = false;
40046         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
40047         LDKNetworkGraph network_conv;
40048         network_conv.inner = (void*)(network & (~1));
40049         network_conv.is_owned = false;
40050         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
40051         LDKCVec_ChannelDetailsZ first_hops_constr;
40052         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
40053         if (first_hops != NULL) {
40054                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
40055                 if (first_hops_constr.datalen > 0)
40056                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
40057                 else
40058                         first_hops_constr.data = NULL;
40059                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
40060                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
40061                         int64_t first_hops_conv_16 = first_hops_vals[q];
40062                         LDKChannelDetails first_hops_conv_16_conv;
40063                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
40064                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
40065                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
40066                         first_hops_constr.data[q] = first_hops_conv_16_conv;
40067                 }
40068                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
40069                 first_hops_ptr = &first_hops_constr;
40070         }
40071         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
40072         CHECK_ACCESS(logger_ptr);
40073         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40074         if (logger_conv.free == LDKLogger_JCalls_free) {
40075                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40076                 LDKLogger_JCalls_cloned(&logger_conv);
40077         }
40078         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
40079         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
40080         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
40081         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
40082         *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
40083         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
40084         return (uintptr_t)ret_conv;
40085 }
40086
40087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40088         if ((this_ptr & 1) != 0) return;
40089         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40090         CHECK_ACCESS(this_ptr_ptr);
40091         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
40092         FREE((void*)this_ptr);
40093         Score_free(this_ptr_conv);
40094 }
40095
40096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40097         if ((this_ptr & 1) != 0) return;
40098         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40099         CHECK_ACCESS(this_ptr_ptr);
40100         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
40101         FREE((void*)this_ptr);
40102         LockableScore_free(this_ptr_conv);
40103 }
40104
40105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40106         LDKMultiThreadedLockableScore this_obj_conv;
40107         this_obj_conv.inner = (void*)(this_obj & (~1));
40108         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40110         MultiThreadedLockableScore_free(this_obj_conv);
40111 }
40112
40113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
40114         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
40115         CHECK_ACCESS(score_ptr);
40116         LDKScore score_conv = *(LDKScore*)(score_ptr);
40117         if (score_conv.free == LDKScore_JCalls_free) {
40118                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40119                 LDKScore_JCalls_cloned(&score_conv);
40120         }
40121         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
40122         uintptr_t ret_ref = 0;
40123         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40124         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40126         ret_ref = (uintptr_t)ret_var.inner;
40127         if (ret_var.is_owned) {
40128                 ret_ref |= 1;
40129         }
40130         return ret_ref;
40131 }
40132
40133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40134         LDKScorer this_obj_conv;
40135         this_obj_conv.inner = (void*)(this_obj & (~1));
40136         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40138         Scorer_free(this_obj_conv);
40139 }
40140
40141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40142         LDKScoringParameters this_obj_conv;
40143         this_obj_conv.inner = (void*)(this_obj & (~1));
40144         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40146         ScoringParameters_free(this_obj_conv);
40147 }
40148
40149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40150         LDKScoringParameters this_ptr_conv;
40151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40152         this_ptr_conv.is_owned = false;
40153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40154         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
40155         return ret_val;
40156 }
40157
40158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40159         LDKScoringParameters this_ptr_conv;
40160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40161         this_ptr_conv.is_owned = false;
40162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40163         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
40164 }
40165
40166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40167         LDKScoringParameters this_ptr_conv;
40168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40169         this_ptr_conv.is_owned = false;
40170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40171         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
40172         return ret_val;
40173 }
40174
40175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40176         LDKScoringParameters this_ptr_conv;
40177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40178         this_ptr_conv.is_owned = false;
40179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40180         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
40181 }
40182
40183 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1start_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
40184         LDKScoringParameters this_ptr_conv;
40185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40186         this_ptr_conv.is_owned = false;
40187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40188         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
40189         return ret_val;
40190 }
40191
40192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1overuse_1penalty_1start_11024th(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
40193         LDKScoringParameters this_ptr_conv;
40194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40195         this_ptr_conv.is_owned = false;
40196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40197         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
40198 }
40199
40200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1msat_1per_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
40201         LDKScoringParameters this_ptr_conv;
40202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40203         this_ptr_conv.is_owned = false;
40204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40205         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
40206         return ret_val;
40207 }
40208
40209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1overuse_1penalty_1msat_1per_11024th(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40210         LDKScoringParameters this_ptr_conv;
40211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40212         this_ptr_conv.is_owned = false;
40213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40214         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
40215 }
40216
40217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
40218         LDKScoringParameters this_ptr_conv;
40219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40220         this_ptr_conv.is_owned = false;
40221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40222         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
40223         return ret_val;
40224 }
40225
40226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40227         LDKScoringParameters this_ptr_conv;
40228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40229         this_ptr_conv.is_owned = false;
40230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40231         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
40232 }
40233
40234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int16_t overuse_penalty_start_1024th_arg, int64_t overuse_penalty_msat_per_1024th_arg, int64_t failure_penalty_half_life_arg) {
40235         LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, overuse_penalty_start_1024th_arg, overuse_penalty_msat_per_1024th_arg, failure_penalty_half_life_arg);
40236         uintptr_t ret_ref = 0;
40237         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40238         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40240         ret_ref = (uintptr_t)ret_var.inner;
40241         if (ret_var.is_owned) {
40242                 ret_ref |= 1;
40243         }
40244         return ret_ref;
40245 }
40246
40247 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
40248         LDKScoringParameters obj_conv;
40249         obj_conv.inner = (void*)(obj & (~1));
40250         obj_conv.is_owned = false;
40251         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40252         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
40253         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40254         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40255         CVec_u8Z_free(ret_var);
40256         return ret_arr;
40257 }
40258
40259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40260         LDKu8slice ser_ref;
40261         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40262         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40263         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
40264         *ret_conv = ScoringParameters_read(ser_ref);
40265         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40266         return (uintptr_t)ret_conv;
40267 }
40268
40269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t params) {
40270         LDKScoringParameters params_conv;
40271         params_conv.inner = (void*)(params & (~1));
40272         params_conv.is_owned = (params & 1) || (params == 0);
40273         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
40274         // Warning: we need a move here but no clone is available for LDKScoringParameters
40275         LDKScorer ret_var = Scorer_new(params_conv);
40276         uintptr_t ret_ref = 0;
40277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40280         ret_ref = (uintptr_t)ret_var.inner;
40281         if (ret_var.is_owned) {
40282                 ret_ref |= 1;
40283         }
40284         return ret_ref;
40285 }
40286
40287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
40288         LDKScorer ret_var = Scorer_default();
40289         uintptr_t ret_ref = 0;
40290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40293         ret_ref = (uintptr_t)ret_var.inner;
40294         if (ret_var.is_owned) {
40295                 ret_ref |= 1;
40296         }
40297         return ret_ref;
40298 }
40299
40300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1default(JNIEnv *env, jclass clz) {
40301         LDKScoringParameters ret_var = ScoringParameters_default();
40302         uintptr_t ret_ref = 0;
40303         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40304         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40306         ret_ref = (uintptr_t)ret_var.inner;
40307         if (ret_var.is_owned) {
40308                 ret_ref |= 1;
40309         }
40310         return ret_ref;
40311 }
40312
40313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
40314         LDKScorer this_arg_conv;
40315         this_arg_conv.inner = (void*)(this_arg & (~1));
40316         this_arg_conv.is_owned = false;
40317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40318         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
40319         *ret_ret = Scorer_as_Score(&this_arg_conv);
40320         return (uintptr_t)ret_ret;
40321 }
40322
40323 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Scorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
40324         LDKScorer obj_conv;
40325         obj_conv.inner = (void*)(obj & (~1));
40326         obj_conv.is_owned = false;
40327         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40328         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
40329         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40330         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40331         CVec_u8Z_free(ret_var);
40332         return ret_arr;
40333 }
40334
40335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40336         LDKu8slice ser_ref;
40337         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40338         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40339         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
40340         *ret_conv = Scorer_read(ser_ref);
40341         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40342         return (uintptr_t)ret_conv;
40343 }
40344
40345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40346         LDKFilesystemPersister this_obj_conv;
40347         this_obj_conv.inner = (void*)(this_obj & (~1));
40348         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40350         FilesystemPersister_free(this_obj_conv);
40351 }
40352
40353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
40354         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
40355         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
40356         uintptr_t ret_ref = 0;
40357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40360         ret_ref = (uintptr_t)ret_var.inner;
40361         if (ret_var.is_owned) {
40362                 ret_ref |= 1;
40363         }
40364         return ret_ref;
40365 }
40366
40367 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
40368         LDKFilesystemPersister this_arg_conv;
40369         this_arg_conv.inner = (void*)(this_arg & (~1));
40370         this_arg_conv.is_owned = false;
40371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40372         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
40373         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40374         Str_free(ret_str);
40375         return ret_conv;
40376 }
40377
40378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
40379         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
40380         LDKChannelManager manager_conv;
40381         manager_conv.inner = (void*)(manager & (~1));
40382         manager_conv.is_owned = false;
40383         CHECK_INNER_FIELD_ACCESS_OR_NULL(manager_conv);
40384         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
40385         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
40386         return (uintptr_t)ret_conv;
40387 }
40388
40389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
40390         LDKFilesystemPersister this_arg_conv;
40391         this_arg_conv.inner = (void*)(this_arg & (~1));
40392         this_arg_conv.is_owned = false;
40393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40394         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
40395         CHECK_ACCESS(keys_manager_ptr);
40396         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
40397         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
40398                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40399                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
40400         }
40401         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
40402         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
40403         return (uintptr_t)ret_conv;
40404 }
40405
40406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
40407         LDKFilesystemPersister this_arg_conv;
40408         this_arg_conv.inner = (void*)(this_arg & (~1));
40409         this_arg_conv.is_owned = false;
40410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40411         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
40412         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
40413         return (uintptr_t)ret_ret;
40414 }
40415
40416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40417         LDKBackgroundProcessor this_obj_conv;
40418         this_obj_conv.inner = (void*)(this_obj & (~1));
40419         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40421         BackgroundProcessor_free(this_obj_conv);
40422 }
40423
40424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40425         if ((this_ptr & 1) != 0) return;
40426         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40427         CHECK_ACCESS(this_ptr_ptr);
40428         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
40429         FREE((void*)this_ptr);
40430         ChannelManagerPersister_free(this_ptr_conv);
40431 }
40432
40433 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 net_graph_msg_handler, int64_t peer_manager, int64_t logger) {
40434         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
40435         CHECK_ACCESS(persister_ptr);
40436         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
40437         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
40438                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40439                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
40440         }
40441         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
40442         CHECK_ACCESS(event_handler_ptr);
40443         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
40444         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
40445                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40446                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
40447         }
40448         LDKChainMonitor chain_monitor_conv;
40449         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
40450         chain_monitor_conv.is_owned = false;
40451         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
40452         LDKChannelManager channel_manager_conv;
40453         channel_manager_conv.inner = (void*)(channel_manager & (~1));
40454         channel_manager_conv.is_owned = false;
40455         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
40456         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
40457         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
40458         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
40459         CHECK_INNER_FIELD_ACCESS_OR_NULL(net_graph_msg_handler_conv);
40460         LDKPeerManager peer_manager_conv;
40461         peer_manager_conv.inner = (void*)(peer_manager & (~1));
40462         peer_manager_conv.is_owned = false;
40463         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
40464         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
40465         CHECK_ACCESS(logger_ptr);
40466         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40467         if (logger_conv.free == LDKLogger_JCalls_free) {
40468                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40469                 LDKLogger_JCalls_cloned(&logger_conv);
40470         }
40471         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv);
40472         uintptr_t ret_ref = 0;
40473         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40474         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40476         ret_ref = (uintptr_t)ret_var.inner;
40477         if (ret_var.is_owned) {
40478                 ret_ref |= 1;
40479         }
40480         return ret_ref;
40481 }
40482
40483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
40484         LDKBackgroundProcessor this_arg_conv;
40485         this_arg_conv.inner = (void*)(this_arg & (~1));
40486         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40488         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
40489         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
40490         *ret_conv = BackgroundProcessor_join(this_arg_conv);
40491         return (uintptr_t)ret_conv;
40492 }
40493
40494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
40495         LDKBackgroundProcessor this_arg_conv;
40496         this_arg_conv.inner = (void*)(this_arg & (~1));
40497         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40499         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
40500         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
40501         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
40502         return (uintptr_t)ret_conv;
40503 }
40504
40505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
40506         check_platform();
40507 }
40508
40509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40510         LDKInvoice this_obj_conv;
40511         this_obj_conv.inner = (void*)(this_obj & (~1));
40512         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40514         Invoice_free(this_obj_conv);
40515 }
40516
40517 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40518         LDKInvoice a_conv;
40519         a_conv.inner = (void*)(a & (~1));
40520         a_conv.is_owned = false;
40521         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40522         LDKInvoice b_conv;
40523         b_conv.inner = (void*)(b & (~1));
40524         b_conv.is_owned = false;
40525         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40526         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
40527         return ret_val;
40528 }
40529
40530 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
40531         LDKInvoice ret_var = Invoice_clone(arg);
40532 uintptr_t ret_ref = 0;
40533 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40534 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40535 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40536 ret_ref = (uintptr_t)ret_var.inner;
40537 if (ret_var.is_owned) {
40538         ret_ref |= 1;
40539 }
40540         return ret_ref;
40541 }
40542 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40543         LDKInvoice arg_conv;
40544         arg_conv.inner = (void*)(arg & (~1));
40545         arg_conv.is_owned = false;
40546         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40547         intptr_t ret_val = Invoice_clone_ptr(&arg_conv);
40548         return ret_val;
40549 }
40550
40551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40552         LDKInvoice orig_conv;
40553         orig_conv.inner = (void*)(orig & (~1));
40554         orig_conv.is_owned = false;
40555         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40556         LDKInvoice ret_var = Invoice_clone(&orig_conv);
40557         uintptr_t ret_ref = 0;
40558         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40559         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40561         ret_ref = (uintptr_t)ret_var.inner;
40562         if (ret_var.is_owned) {
40563                 ret_ref |= 1;
40564         }
40565         return ret_ref;
40566 }
40567
40568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40569         LDKSignedRawInvoice this_obj_conv;
40570         this_obj_conv.inner = (void*)(this_obj & (~1));
40571         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40573         SignedRawInvoice_free(this_obj_conv);
40574 }
40575
40576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40577         LDKSignedRawInvoice a_conv;
40578         a_conv.inner = (void*)(a & (~1));
40579         a_conv.is_owned = false;
40580         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40581         LDKSignedRawInvoice b_conv;
40582         b_conv.inner = (void*)(b & (~1));
40583         b_conv.is_owned = false;
40584         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40585         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
40586         return ret_val;
40587 }
40588
40589 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
40590         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
40591 uintptr_t ret_ref = 0;
40592 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40593 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40594 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40595 ret_ref = (uintptr_t)ret_var.inner;
40596 if (ret_var.is_owned) {
40597         ret_ref |= 1;
40598 }
40599         return ret_ref;
40600 }
40601 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40602         LDKSignedRawInvoice arg_conv;
40603         arg_conv.inner = (void*)(arg & (~1));
40604         arg_conv.is_owned = false;
40605         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40606         intptr_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
40607         return ret_val;
40608 }
40609
40610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40611         LDKSignedRawInvoice orig_conv;
40612         orig_conv.inner = (void*)(orig & (~1));
40613         orig_conv.is_owned = false;
40614         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40615         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
40616         uintptr_t ret_ref = 0;
40617         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40618         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40620         ret_ref = (uintptr_t)ret_var.inner;
40621         if (ret_var.is_owned) {
40622                 ret_ref |= 1;
40623         }
40624         return ret_ref;
40625 }
40626
40627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40628         LDKRawInvoice this_obj_conv;
40629         this_obj_conv.inner = (void*)(this_obj & (~1));
40630         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40632         RawInvoice_free(this_obj_conv);
40633 }
40634
40635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
40636         LDKRawInvoice this_ptr_conv;
40637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40638         this_ptr_conv.is_owned = false;
40639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40640         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
40641         uintptr_t ret_ref = 0;
40642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40645         ret_ref = (uintptr_t)ret_var.inner;
40646         if (ret_var.is_owned) {
40647                 ret_ref |= 1;
40648         }
40649         return ret_ref;
40650 }
40651
40652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40653         LDKRawInvoice this_ptr_conv;
40654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40655         this_ptr_conv.is_owned = false;
40656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40657         LDKRawDataPart val_conv;
40658         val_conv.inner = (void*)(val & (~1));
40659         val_conv.is_owned = (val & 1) || (val == 0);
40660         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40661         val_conv = RawDataPart_clone(&val_conv);
40662         RawInvoice_set_data(&this_ptr_conv, val_conv);
40663 }
40664
40665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40666         LDKRawInvoice a_conv;
40667         a_conv.inner = (void*)(a & (~1));
40668         a_conv.is_owned = false;
40669         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40670         LDKRawInvoice b_conv;
40671         b_conv.inner = (void*)(b & (~1));
40672         b_conv.is_owned = false;
40673         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40674         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
40675         return ret_val;
40676 }
40677
40678 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
40679         LDKRawInvoice ret_var = RawInvoice_clone(arg);
40680 uintptr_t ret_ref = 0;
40681 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40682 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40683 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40684 ret_ref = (uintptr_t)ret_var.inner;
40685 if (ret_var.is_owned) {
40686         ret_ref |= 1;
40687 }
40688         return ret_ref;
40689 }
40690 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40691         LDKRawInvoice arg_conv;
40692         arg_conv.inner = (void*)(arg & (~1));
40693         arg_conv.is_owned = false;
40694         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40695         intptr_t ret_val = RawInvoice_clone_ptr(&arg_conv);
40696         return ret_val;
40697 }
40698
40699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40700         LDKRawInvoice orig_conv;
40701         orig_conv.inner = (void*)(orig & (~1));
40702         orig_conv.is_owned = false;
40703         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40704         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
40705         uintptr_t ret_ref = 0;
40706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40709         ret_ref = (uintptr_t)ret_var.inner;
40710         if (ret_var.is_owned) {
40711                 ret_ref |= 1;
40712         }
40713         return ret_ref;
40714 }
40715
40716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40717         LDKRawDataPart this_obj_conv;
40718         this_obj_conv.inner = (void*)(this_obj & (~1));
40719         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40721         RawDataPart_free(this_obj_conv);
40722 }
40723
40724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
40725         LDKRawDataPart this_ptr_conv;
40726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40727         this_ptr_conv.is_owned = false;
40728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40729         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
40730         uintptr_t ret_ref = 0;
40731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40734         ret_ref = (uintptr_t)ret_var.inner;
40735         if (ret_var.is_owned) {
40736                 ret_ref |= 1;
40737         }
40738         return ret_ref;
40739 }
40740
40741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40742         LDKRawDataPart this_ptr_conv;
40743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40744         this_ptr_conv.is_owned = false;
40745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40746         LDKPositiveTimestamp val_conv;
40747         val_conv.inner = (void*)(val & (~1));
40748         val_conv.is_owned = (val & 1) || (val == 0);
40749         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40750         val_conv = PositiveTimestamp_clone(&val_conv);
40751         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
40752 }
40753
40754 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40755         LDKRawDataPart a_conv;
40756         a_conv.inner = (void*)(a & (~1));
40757         a_conv.is_owned = false;
40758         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40759         LDKRawDataPart b_conv;
40760         b_conv.inner = (void*)(b & (~1));
40761         b_conv.is_owned = false;
40762         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40763         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
40764         return ret_val;
40765 }
40766
40767 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
40768         LDKRawDataPart ret_var = RawDataPart_clone(arg);
40769 uintptr_t ret_ref = 0;
40770 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40771 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40772 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40773 ret_ref = (uintptr_t)ret_var.inner;
40774 if (ret_var.is_owned) {
40775         ret_ref |= 1;
40776 }
40777         return ret_ref;
40778 }
40779 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40780         LDKRawDataPart arg_conv;
40781         arg_conv.inner = (void*)(arg & (~1));
40782         arg_conv.is_owned = false;
40783         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40784         intptr_t ret_val = RawDataPart_clone_ptr(&arg_conv);
40785         return ret_val;
40786 }
40787
40788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40789         LDKRawDataPart orig_conv;
40790         orig_conv.inner = (void*)(orig & (~1));
40791         orig_conv.is_owned = false;
40792         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40793         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
40794         uintptr_t ret_ref = 0;
40795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40798         ret_ref = (uintptr_t)ret_var.inner;
40799         if (ret_var.is_owned) {
40800                 ret_ref |= 1;
40801         }
40802         return ret_ref;
40803 }
40804
40805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40806         LDKPositiveTimestamp this_obj_conv;
40807         this_obj_conv.inner = (void*)(this_obj & (~1));
40808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40810         PositiveTimestamp_free(this_obj_conv);
40811 }
40812
40813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40814         LDKPositiveTimestamp a_conv;
40815         a_conv.inner = (void*)(a & (~1));
40816         a_conv.is_owned = false;
40817         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40818         LDKPositiveTimestamp b_conv;
40819         b_conv.inner = (void*)(b & (~1));
40820         b_conv.is_owned = false;
40821         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40822         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
40823         return ret_val;
40824 }
40825
40826 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
40827         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
40828 uintptr_t ret_ref = 0;
40829 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40830 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40831 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40832 ret_ref = (uintptr_t)ret_var.inner;
40833 if (ret_var.is_owned) {
40834         ret_ref |= 1;
40835 }
40836         return ret_ref;
40837 }
40838 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40839         LDKPositiveTimestamp arg_conv;
40840         arg_conv.inner = (void*)(arg & (~1));
40841         arg_conv.is_owned = false;
40842         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40843         intptr_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
40844         return ret_val;
40845 }
40846
40847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40848         LDKPositiveTimestamp orig_conv;
40849         orig_conv.inner = (void*)(orig & (~1));
40850         orig_conv.is_owned = false;
40851         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40852         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
40853         uintptr_t ret_ref = 0;
40854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40857         ret_ref = (uintptr_t)ret_var.inner;
40858         if (ret_var.is_owned) {
40859                 ret_ref |= 1;
40860         }
40861         return ret_ref;
40862 }
40863
40864 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40865         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
40866         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
40867         return ret_conv;
40868 }
40869
40870 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
40871         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
40872         return ret_conv;
40873 }
40874
40875 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
40876         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
40877         return ret_conv;
40878 }
40879
40880 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
40881         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
40882         return ret_conv;
40883 }
40884
40885 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
40886         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
40887         return ret_conv;
40888 }
40889
40890 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40891         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
40892         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
40893         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
40894         return ret_val;
40895 }
40896
40897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
40898         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
40899         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
40900         return ret_val;
40901 }
40902
40903 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40904         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
40905         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
40906         return ret_conv;
40907 }
40908
40909 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
40910         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
40911         return ret_conv;
40912 }
40913
40914 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
40915         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
40916         return ret_conv;
40917 }
40918
40919 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
40920         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
40921         return ret_conv;
40922 }
40923
40924 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
40925         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
40926         return ret_conv;
40927 }
40928
40929 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
40930         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
40931         return ret_conv;
40932 }
40933
40934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
40935         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
40936         int64_t ret_val = Currency_hash(o_conv);
40937         return ret_val;
40938 }
40939
40940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40941         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
40942         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
40943         jboolean ret_val = Currency_eq(a_conv, b_conv);
40944         return ret_val;
40945 }
40946
40947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40948         LDKSha256 this_obj_conv;
40949         this_obj_conv.inner = (void*)(this_obj & (~1));
40950         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40952         Sha256_free(this_obj_conv);
40953 }
40954
40955 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
40956         LDKSha256 ret_var = Sha256_clone(arg);
40957 uintptr_t ret_ref = 0;
40958 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40959 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40960 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40961 ret_ref = (uintptr_t)ret_var.inner;
40962 if (ret_var.is_owned) {
40963         ret_ref |= 1;
40964 }
40965         return ret_ref;
40966 }
40967 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40968         LDKSha256 arg_conv;
40969         arg_conv.inner = (void*)(arg & (~1));
40970         arg_conv.is_owned = false;
40971         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40972         intptr_t ret_val = Sha256_clone_ptr(&arg_conv);
40973         return ret_val;
40974 }
40975
40976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40977         LDKSha256 orig_conv;
40978         orig_conv.inner = (void*)(orig & (~1));
40979         orig_conv.is_owned = false;
40980         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40981         LDKSha256 ret_var = Sha256_clone(&orig_conv);
40982         uintptr_t ret_ref = 0;
40983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40986         ret_ref = (uintptr_t)ret_var.inner;
40987         if (ret_var.is_owned) {
40988                 ret_ref |= 1;
40989         }
40990         return ret_ref;
40991 }
40992
40993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
40994         LDKSha256 o_conv;
40995         o_conv.inner = (void*)(o & (~1));
40996         o_conv.is_owned = false;
40997         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40998         int64_t ret_val = Sha256_hash(&o_conv);
40999         return ret_val;
41000 }
41001
41002 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41003         LDKSha256 a_conv;
41004         a_conv.inner = (void*)(a & (~1));
41005         a_conv.is_owned = false;
41006         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41007         LDKSha256 b_conv;
41008         b_conv.inner = (void*)(b & (~1));
41009         b_conv.is_owned = false;
41010         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41011         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
41012         return ret_val;
41013 }
41014
41015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41016         LDKDescription this_obj_conv;
41017         this_obj_conv.inner = (void*)(this_obj & (~1));
41018         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41020         Description_free(this_obj_conv);
41021 }
41022
41023 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
41024         LDKDescription ret_var = Description_clone(arg);
41025 uintptr_t ret_ref = 0;
41026 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41027 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41028 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41029 ret_ref = (uintptr_t)ret_var.inner;
41030 if (ret_var.is_owned) {
41031         ret_ref |= 1;
41032 }
41033         return ret_ref;
41034 }
41035 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41036         LDKDescription arg_conv;
41037         arg_conv.inner = (void*)(arg & (~1));
41038         arg_conv.is_owned = false;
41039         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41040         intptr_t ret_val = Description_clone_ptr(&arg_conv);
41041         return ret_val;
41042 }
41043
41044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41045         LDKDescription orig_conv;
41046         orig_conv.inner = (void*)(orig & (~1));
41047         orig_conv.is_owned = false;
41048         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41049         LDKDescription ret_var = Description_clone(&orig_conv);
41050         uintptr_t ret_ref = 0;
41051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41054         ret_ref = (uintptr_t)ret_var.inner;
41055         if (ret_var.is_owned) {
41056                 ret_ref |= 1;
41057         }
41058         return ret_ref;
41059 }
41060
41061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
41062         LDKDescription o_conv;
41063         o_conv.inner = (void*)(o & (~1));
41064         o_conv.is_owned = false;
41065         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41066         int64_t ret_val = Description_hash(&o_conv);
41067         return ret_val;
41068 }
41069
41070 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41071         LDKDescription a_conv;
41072         a_conv.inner = (void*)(a & (~1));
41073         a_conv.is_owned = false;
41074         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41075         LDKDescription b_conv;
41076         b_conv.inner = (void*)(b & (~1));
41077         b_conv.is_owned = false;
41078         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41079         jboolean ret_val = Description_eq(&a_conv, &b_conv);
41080         return ret_val;
41081 }
41082
41083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41084         LDKPayeePubKey this_obj_conv;
41085         this_obj_conv.inner = (void*)(this_obj & (~1));
41086         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41088         PayeePubKey_free(this_obj_conv);
41089 }
41090
41091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
41092         LDKPayeePubKey this_ptr_conv;
41093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41094         this_ptr_conv.is_owned = false;
41095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41096         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41097         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
41098         return ret_arr;
41099 }
41100
41101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41102         LDKPayeePubKey this_ptr_conv;
41103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41104         this_ptr_conv.is_owned = false;
41105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41106         LDKPublicKey val_ref;
41107         CHECK((*env)->GetArrayLength(env, val) == 33);
41108         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41109         PayeePubKey_set_a(&this_ptr_conv, val_ref);
41110 }
41111
41112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
41113         LDKPublicKey a_arg_ref;
41114         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
41115         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
41116         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
41117         uintptr_t ret_ref = 0;
41118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41121         ret_ref = (uintptr_t)ret_var.inner;
41122         if (ret_var.is_owned) {
41123                 ret_ref |= 1;
41124         }
41125         return ret_ref;
41126 }
41127
41128 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
41129         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
41130 uintptr_t ret_ref = 0;
41131 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41132 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41133 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41134 ret_ref = (uintptr_t)ret_var.inner;
41135 if (ret_var.is_owned) {
41136         ret_ref |= 1;
41137 }
41138         return ret_ref;
41139 }
41140 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41141         LDKPayeePubKey arg_conv;
41142         arg_conv.inner = (void*)(arg & (~1));
41143         arg_conv.is_owned = false;
41144         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41145         intptr_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
41146         return ret_val;
41147 }
41148
41149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41150         LDKPayeePubKey orig_conv;
41151         orig_conv.inner = (void*)(orig & (~1));
41152         orig_conv.is_owned = false;
41153         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41154         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
41155         uintptr_t ret_ref = 0;
41156         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41157         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41159         ret_ref = (uintptr_t)ret_var.inner;
41160         if (ret_var.is_owned) {
41161                 ret_ref |= 1;
41162         }
41163         return ret_ref;
41164 }
41165
41166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
41167         LDKPayeePubKey o_conv;
41168         o_conv.inner = (void*)(o & (~1));
41169         o_conv.is_owned = false;
41170         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41171         int64_t ret_val = PayeePubKey_hash(&o_conv);
41172         return ret_val;
41173 }
41174
41175 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41176         LDKPayeePubKey a_conv;
41177         a_conv.inner = (void*)(a & (~1));
41178         a_conv.is_owned = false;
41179         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41180         LDKPayeePubKey b_conv;
41181         b_conv.inner = (void*)(b & (~1));
41182         b_conv.is_owned = false;
41183         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41184         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
41185         return ret_val;
41186 }
41187
41188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41189         LDKExpiryTime this_obj_conv;
41190         this_obj_conv.inner = (void*)(this_obj & (~1));
41191         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41193         ExpiryTime_free(this_obj_conv);
41194 }
41195
41196 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
41197         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
41198 uintptr_t ret_ref = 0;
41199 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41200 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41201 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41202 ret_ref = (uintptr_t)ret_var.inner;
41203 if (ret_var.is_owned) {
41204         ret_ref |= 1;
41205 }
41206         return ret_ref;
41207 }
41208 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41209         LDKExpiryTime arg_conv;
41210         arg_conv.inner = (void*)(arg & (~1));
41211         arg_conv.is_owned = false;
41212         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41213         intptr_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
41214         return ret_val;
41215 }
41216
41217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41218         LDKExpiryTime orig_conv;
41219         orig_conv.inner = (void*)(orig & (~1));
41220         orig_conv.is_owned = false;
41221         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41222         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
41223         uintptr_t ret_ref = 0;
41224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41227         ret_ref = (uintptr_t)ret_var.inner;
41228         if (ret_var.is_owned) {
41229                 ret_ref |= 1;
41230         }
41231         return ret_ref;
41232 }
41233
41234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
41235         LDKExpiryTime o_conv;
41236         o_conv.inner = (void*)(o & (~1));
41237         o_conv.is_owned = false;
41238         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41239         int64_t ret_val = ExpiryTime_hash(&o_conv);
41240         return ret_val;
41241 }
41242
41243 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41244         LDKExpiryTime a_conv;
41245         a_conv.inner = (void*)(a & (~1));
41246         a_conv.is_owned = false;
41247         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41248         LDKExpiryTime b_conv;
41249         b_conv.inner = (void*)(b & (~1));
41250         b_conv.is_owned = false;
41251         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41252         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
41253         return ret_val;
41254 }
41255
41256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41257         LDKMinFinalCltvExpiry this_obj_conv;
41258         this_obj_conv.inner = (void*)(this_obj & (~1));
41259         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41261         MinFinalCltvExpiry_free(this_obj_conv);
41262 }
41263
41264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
41265         LDKMinFinalCltvExpiry this_ptr_conv;
41266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41267         this_ptr_conv.is_owned = false;
41268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41269         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
41270         return ret_val;
41271 }
41272
41273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41274         LDKMinFinalCltvExpiry this_ptr_conv;
41275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41276         this_ptr_conv.is_owned = false;
41277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41278         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
41279 }
41280
41281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
41282         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
41283         uintptr_t ret_ref = 0;
41284         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41285         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41287         ret_ref = (uintptr_t)ret_var.inner;
41288         if (ret_var.is_owned) {
41289                 ret_ref |= 1;
41290         }
41291         return ret_ref;
41292 }
41293
41294 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
41295         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
41296 uintptr_t ret_ref = 0;
41297 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41298 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41299 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41300 ret_ref = (uintptr_t)ret_var.inner;
41301 if (ret_var.is_owned) {
41302         ret_ref |= 1;
41303 }
41304         return ret_ref;
41305 }
41306 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41307         LDKMinFinalCltvExpiry arg_conv;
41308         arg_conv.inner = (void*)(arg & (~1));
41309         arg_conv.is_owned = false;
41310         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41311         intptr_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
41312         return ret_val;
41313 }
41314
41315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41316         LDKMinFinalCltvExpiry orig_conv;
41317         orig_conv.inner = (void*)(orig & (~1));
41318         orig_conv.is_owned = false;
41319         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41320         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
41321         uintptr_t ret_ref = 0;
41322         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41323         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41325         ret_ref = (uintptr_t)ret_var.inner;
41326         if (ret_var.is_owned) {
41327                 ret_ref |= 1;
41328         }
41329         return ret_ref;
41330 }
41331
41332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
41333         LDKMinFinalCltvExpiry o_conv;
41334         o_conv.inner = (void*)(o & (~1));
41335         o_conv.is_owned = false;
41336         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41337         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
41338         return ret_val;
41339 }
41340
41341 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41342         LDKMinFinalCltvExpiry a_conv;
41343         a_conv.inner = (void*)(a & (~1));
41344         a_conv.is_owned = false;
41345         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41346         LDKMinFinalCltvExpiry b_conv;
41347         b_conv.inner = (void*)(b & (~1));
41348         b_conv.is_owned = false;
41349         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41350         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
41351         return ret_val;
41352 }
41353
41354 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41355         if ((this_ptr & 1) != 0) return;
41356         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41357         CHECK_ACCESS(this_ptr_ptr);
41358         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
41359         FREE((void*)this_ptr);
41360         Fallback_free(this_ptr_conv);
41361 }
41362
41363 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
41364         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
41365         *ret_copy = Fallback_clone(arg);
41366 uintptr_t ret_ref = (uintptr_t)ret_copy;
41367         return ret_ref;
41368 }
41369 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41370         LDKFallback* arg_conv = (LDKFallback*)arg;
41371         intptr_t ret_val = Fallback_clone_ptr(arg_conv);
41372         return ret_val;
41373 }
41374
41375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41376         LDKFallback* orig_conv = (LDKFallback*)orig;
41377         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
41378         *ret_copy = Fallback_clone(orig_conv);
41379         uintptr_t ret_ref = (uintptr_t)ret_copy;
41380         return ret_ref;
41381 }
41382
41383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
41384         
41385         LDKCVec_u8Z program_ref;
41386         program_ref.datalen = (*env)->GetArrayLength(env, program);
41387         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
41388         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
41389         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
41390         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
41391         uintptr_t ret_ref = (uintptr_t)ret_copy;
41392         return ret_ref;
41393 }
41394
41395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
41396         LDKTwentyBytes a_ref;
41397         CHECK((*env)->GetArrayLength(env, a) == 20);
41398         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
41399         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
41400         *ret_copy = Fallback_pub_key_hash(a_ref);
41401         uintptr_t ret_ref = (uintptr_t)ret_copy;
41402         return ret_ref;
41403 }
41404
41405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
41406         LDKTwentyBytes a_ref;
41407         CHECK((*env)->GetArrayLength(env, a) == 20);
41408         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
41409         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
41410         *ret_copy = Fallback_script_hash(a_ref);
41411         uintptr_t ret_ref = (uintptr_t)ret_copy;
41412         return ret_ref;
41413 }
41414
41415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
41416         LDKFallback* o_conv = (LDKFallback*)o;
41417         int64_t ret_val = Fallback_hash(o_conv);
41418         return ret_val;
41419 }
41420
41421 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41422         LDKFallback* a_conv = (LDKFallback*)a;
41423         LDKFallback* b_conv = (LDKFallback*)b;
41424         jboolean ret_val = Fallback_eq(a_conv, b_conv);
41425         return ret_val;
41426 }
41427
41428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41429         LDKInvoiceSignature this_obj_conv;
41430         this_obj_conv.inner = (void*)(this_obj & (~1));
41431         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41433         InvoiceSignature_free(this_obj_conv);
41434 }
41435
41436 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
41437         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
41438 uintptr_t ret_ref = 0;
41439 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41440 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41441 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41442 ret_ref = (uintptr_t)ret_var.inner;
41443 if (ret_var.is_owned) {
41444         ret_ref |= 1;
41445 }
41446         return ret_ref;
41447 }
41448 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41449         LDKInvoiceSignature arg_conv;
41450         arg_conv.inner = (void*)(arg & (~1));
41451         arg_conv.is_owned = false;
41452         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41453         intptr_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
41454         return ret_val;
41455 }
41456
41457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41458         LDKInvoiceSignature orig_conv;
41459         orig_conv.inner = (void*)(orig & (~1));
41460         orig_conv.is_owned = false;
41461         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41462         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
41463         uintptr_t ret_ref = 0;
41464         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41465         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41467         ret_ref = (uintptr_t)ret_var.inner;
41468         if (ret_var.is_owned) {
41469                 ret_ref |= 1;
41470         }
41471         return ret_ref;
41472 }
41473
41474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41475         LDKInvoiceSignature a_conv;
41476         a_conv.inner = (void*)(a & (~1));
41477         a_conv.is_owned = false;
41478         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41479         LDKInvoiceSignature b_conv;
41480         b_conv.inner = (void*)(b & (~1));
41481         b_conv.is_owned = false;
41482         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41483         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
41484         return ret_val;
41485 }
41486
41487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41488         LDKPrivateRoute this_obj_conv;
41489         this_obj_conv.inner = (void*)(this_obj & (~1));
41490         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41492         PrivateRoute_free(this_obj_conv);
41493 }
41494
41495 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
41496         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
41497 uintptr_t ret_ref = 0;
41498 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41499 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41500 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41501 ret_ref = (uintptr_t)ret_var.inner;
41502 if (ret_var.is_owned) {
41503         ret_ref |= 1;
41504 }
41505         return ret_ref;
41506 }
41507 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41508         LDKPrivateRoute arg_conv;
41509         arg_conv.inner = (void*)(arg & (~1));
41510         arg_conv.is_owned = false;
41511         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41512         intptr_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
41513         return ret_val;
41514 }
41515
41516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41517         LDKPrivateRoute orig_conv;
41518         orig_conv.inner = (void*)(orig & (~1));
41519         orig_conv.is_owned = false;
41520         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41521         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
41522         uintptr_t ret_ref = 0;
41523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41526         ret_ref = (uintptr_t)ret_var.inner;
41527         if (ret_var.is_owned) {
41528                 ret_ref |= 1;
41529         }
41530         return ret_ref;
41531 }
41532
41533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
41534         LDKPrivateRoute o_conv;
41535         o_conv.inner = (void*)(o & (~1));
41536         o_conv.is_owned = false;
41537         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41538         int64_t ret_val = PrivateRoute_hash(&o_conv);
41539         return ret_val;
41540 }
41541
41542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41543         LDKPrivateRoute a_conv;
41544         a_conv.inner = (void*)(a & (~1));
41545         a_conv.is_owned = false;
41546         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41547         LDKPrivateRoute b_conv;
41548         b_conv.inner = (void*)(b & (~1));
41549         b_conv.is_owned = false;
41550         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41551         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
41552         return ret_val;
41553 }
41554
41555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
41556         LDKSignedRawInvoice this_arg_conv;
41557         this_arg_conv.inner = (void*)(this_arg & (~1));
41558         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41560         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
41561         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
41562         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
41563         return ((uintptr_t)ret_conv);
41564 }
41565
41566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
41567         LDKSignedRawInvoice this_arg_conv;
41568         this_arg_conv.inner = (void*)(this_arg & (~1));
41569         this_arg_conv.is_owned = false;
41570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41571         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
41572         uintptr_t ret_ref = 0;
41573         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41574         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41576         ret_ref = (uintptr_t)ret_var.inner;
41577         if (ret_var.is_owned) {
41578                 ret_ref |= 1;
41579         }
41580         return ret_ref;
41581 }
41582
41583 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
41584         LDKSignedRawInvoice this_arg_conv;
41585         this_arg_conv.inner = (void*)(this_arg & (~1));
41586         this_arg_conv.is_owned = false;
41587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41588         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41589         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
41590         return ret_arr;
41591 }
41592
41593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
41594         LDKSignedRawInvoice this_arg_conv;
41595         this_arg_conv.inner = (void*)(this_arg & (~1));
41596         this_arg_conv.is_owned = false;
41597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41598         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
41599         uintptr_t ret_ref = 0;
41600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41603         ret_ref = (uintptr_t)ret_var.inner;
41604         if (ret_var.is_owned) {
41605                 ret_ref |= 1;
41606         }
41607         return ret_ref;
41608 }
41609
41610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41611         LDKSignedRawInvoice this_arg_conv;
41612         this_arg_conv.inner = (void*)(this_arg & (~1));
41613         this_arg_conv.is_owned = false;
41614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41615         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
41616         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
41617         return (uintptr_t)ret_conv;
41618 }
41619
41620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
41621         LDKSignedRawInvoice this_arg_conv;
41622         this_arg_conv.inner = (void*)(this_arg & (~1));
41623         this_arg_conv.is_owned = false;
41624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41625         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
41626         return ret_val;
41627 }
41628
41629 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
41630         LDKRawInvoice this_arg_conv;
41631         this_arg_conv.inner = (void*)(this_arg & (~1));
41632         this_arg_conv.is_owned = false;
41633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41634         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41635         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
41636         return ret_arr;
41637 }
41638
41639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
41640         LDKRawInvoice this_arg_conv;
41641         this_arg_conv.inner = (void*)(this_arg & (~1));
41642         this_arg_conv.is_owned = false;
41643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41644         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
41645         uintptr_t ret_ref = 0;
41646         if ((uintptr_t)ret_var.inner > 4096) {
41647                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41648                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41650                 ret_ref = (uintptr_t)ret_var.inner;
41651                 if (ret_var.is_owned) {
41652                         ret_ref |= 1;
41653                 }
41654         }
41655         return ret_ref;
41656 }
41657
41658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
41659         LDKRawInvoice this_arg_conv;
41660         this_arg_conv.inner = (void*)(this_arg & (~1));
41661         this_arg_conv.is_owned = false;
41662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41663         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
41664         uintptr_t ret_ref = 0;
41665         if ((uintptr_t)ret_var.inner > 4096) {
41666                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41667                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41669                 ret_ref = (uintptr_t)ret_var.inner;
41670                 if (ret_var.is_owned) {
41671                         ret_ref |= 1;
41672                 }
41673         }
41674         return ret_ref;
41675 }
41676
41677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41678         LDKRawInvoice this_arg_conv;
41679         this_arg_conv.inner = (void*)(this_arg & (~1));
41680         this_arg_conv.is_owned = false;
41681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41682         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
41683         uintptr_t ret_ref = 0;
41684         if ((uintptr_t)ret_var.inner > 4096) {
41685                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41686                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41688                 ret_ref = (uintptr_t)ret_var.inner;
41689                 if (ret_var.is_owned) {
41690                         ret_ref |= 1;
41691                 }
41692         }
41693         return ret_ref;
41694 }
41695
41696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
41697         LDKRawInvoice this_arg_conv;
41698         this_arg_conv.inner = (void*)(this_arg & (~1));
41699         this_arg_conv.is_owned = false;
41700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41701         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
41702         uintptr_t ret_ref = 0;
41703         if ((uintptr_t)ret_var.inner > 4096) {
41704                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41705                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41707                 ret_ref = (uintptr_t)ret_var.inner;
41708                 if (ret_var.is_owned) {
41709                         ret_ref |= 1;
41710                 }
41711         }
41712         return ret_ref;
41713 }
41714
41715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
41716         LDKRawInvoice this_arg_conv;
41717         this_arg_conv.inner = (void*)(this_arg & (~1));
41718         this_arg_conv.is_owned = false;
41719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41720         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
41721         uintptr_t ret_ref = 0;
41722         if ((uintptr_t)ret_var.inner > 4096) {
41723                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41724                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41726                 ret_ref = (uintptr_t)ret_var.inner;
41727                 if (ret_var.is_owned) {
41728                         ret_ref |= 1;
41729                 }
41730         }
41731         return ret_ref;
41732 }
41733
41734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
41735         LDKRawInvoice this_arg_conv;
41736         this_arg_conv.inner = (void*)(this_arg & (~1));
41737         this_arg_conv.is_owned = false;
41738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41739         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
41740         uintptr_t ret_ref = 0;
41741         if ((uintptr_t)ret_var.inner > 4096) {
41742                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41743                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41745                 ret_ref = (uintptr_t)ret_var.inner;
41746                 if (ret_var.is_owned) {
41747                         ret_ref |= 1;
41748                 }
41749         }
41750         return ret_ref;
41751 }
41752
41753 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41754         LDKRawInvoice this_arg_conv;
41755         this_arg_conv.inner = (void*)(this_arg & (~1));
41756         this_arg_conv.is_owned = false;
41757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41758         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41759         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
41760         return ret_arr;
41761 }
41762
41763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
41764         LDKRawInvoice this_arg_conv;
41765         this_arg_conv.inner = (void*)(this_arg & (~1));
41766         this_arg_conv.is_owned = false;
41767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41768         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
41769         uintptr_t ret_ref = 0;
41770         if ((uintptr_t)ret_var.inner > 4096) {
41771                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41772                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41774                 ret_ref = (uintptr_t)ret_var.inner;
41775                 if (ret_var.is_owned) {
41776                         ret_ref |= 1;
41777                 }
41778         }
41779         return ret_ref;
41780 }
41781
41782 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
41783         LDKRawInvoice this_arg_conv;
41784         this_arg_conv.inner = (void*)(this_arg & (~1));
41785         this_arg_conv.is_owned = false;
41786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41787         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
41788         int64_tArray ret_arr = NULL;
41789         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
41790         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
41791         for (size_t o = 0; o < ret_var.datalen; o++) {
41792                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
41793                 uintptr_t ret_conv_14_ref = 0;
41794                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41795                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41796                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
41797                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
41798                 if (ret_conv_14_var.is_owned) {
41799                         ret_conv_14_ref |= 1;
41800                 }
41801                 ret_arr_ptr[o] = ret_conv_14_ref;
41802         }
41803         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
41804         FREE(ret_var.data);
41805         return ret_arr;
41806 }
41807
41808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
41809         LDKRawInvoice this_arg_conv;
41810         this_arg_conv.inner = (void*)(this_arg & (~1));
41811         this_arg_conv.is_owned = false;
41812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41813         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41814         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
41815         uintptr_t ret_ref = (uintptr_t)ret_copy;
41816         return ret_ref;
41817 }
41818
41819 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
41820         LDKRawInvoice this_arg_conv;
41821         this_arg_conv.inner = (void*)(this_arg & (~1));
41822         this_arg_conv.is_owned = false;
41823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41824         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
41825         return ret_conv;
41826 }
41827
41828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
41829         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
41830         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
41831         return (uintptr_t)ret_conv;
41832 }
41833
41834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
41835         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
41836         *ret_conv = PositiveTimestamp_from_system_time(time);
41837         return (uintptr_t)ret_conv;
41838 }
41839
41840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
41841         LDKPositiveTimestamp this_arg_conv;
41842         this_arg_conv.inner = (void*)(this_arg & (~1));
41843         this_arg_conv.is_owned = false;
41844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41845         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
41846         return ret_val;
41847 }
41848
41849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
41850         LDKPositiveTimestamp this_arg_conv;
41851         this_arg_conv.inner = (void*)(this_arg & (~1));
41852         this_arg_conv.is_owned = false;
41853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41854         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
41855         return ret_val;
41856 }
41857
41858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
41859         LDKInvoice this_arg_conv;
41860         this_arg_conv.inner = (void*)(this_arg & (~1));
41861         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41863         this_arg_conv = Invoice_clone(&this_arg_conv);
41864         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
41865         uintptr_t ret_ref = 0;
41866         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41867         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41869         ret_ref = (uintptr_t)ret_var.inner;
41870         if (ret_var.is_owned) {
41871                 ret_ref |= 1;
41872         }
41873         return ret_ref;
41874 }
41875
41876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
41877         LDKInvoice this_arg_conv;
41878         this_arg_conv.inner = (void*)(this_arg & (~1));
41879         this_arg_conv.is_owned = false;
41880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41881         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
41882         *ret_conv = Invoice_check_signature(&this_arg_conv);
41883         return (uintptr_t)ret_conv;
41884 }
41885
41886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
41887         LDKSignedRawInvoice signed_invoice_conv;
41888         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
41889         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
41890         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
41891         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
41892         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
41893         *ret_conv = Invoice_from_signed(signed_invoice_conv);
41894         return (uintptr_t)ret_conv;
41895 }
41896
41897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
41898         LDKInvoice this_arg_conv;
41899         this_arg_conv.inner = (void*)(this_arg & (~1));
41900         this_arg_conv.is_owned = false;
41901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41902         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
41903         return ret_val;
41904 }
41905
41906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
41907         LDKInvoice this_arg_conv;
41908         this_arg_conv.inner = (void*)(this_arg & (~1));
41909         this_arg_conv.is_owned = false;
41910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41911         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41912         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
41913         return ret_arr;
41914 }
41915
41916 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41917         LDKInvoice this_arg_conv;
41918         this_arg_conv.inner = (void*)(this_arg & (~1));
41919         this_arg_conv.is_owned = false;
41920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41921         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41922         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
41923         return ret_arr;
41924 }
41925
41926 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41927         LDKInvoice this_arg_conv;
41928         this_arg_conv.inner = (void*)(this_arg & (~1));
41929         this_arg_conv.is_owned = false;
41930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41931         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41932         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
41933         return ret_arr;
41934 }
41935
41936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
41937         LDKInvoice this_arg_conv;
41938         this_arg_conv.inner = (void*)(this_arg & (~1));
41939         this_arg_conv.is_owned = false;
41940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41941         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
41942         uintptr_t ret_ref = 0;
41943         if ((uintptr_t)ret_var.inner > 4096) {
41944                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41945                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41947                 ret_ref = (uintptr_t)ret_var.inner;
41948                 if (ret_var.is_owned) {
41949                         ret_ref |= 1;
41950                 }
41951         }
41952         return ret_ref;
41953 }
41954
41955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41956         LDKInvoice this_arg_conv;
41957         this_arg_conv.inner = (void*)(this_arg & (~1));
41958         this_arg_conv.is_owned = false;
41959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41960         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41961         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
41962         return ret_arr;
41963 }
41964
41965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
41966         LDKInvoice this_arg_conv;
41967         this_arg_conv.inner = (void*)(this_arg & (~1));
41968         this_arg_conv.is_owned = false;
41969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41970         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
41971         return ret_val;
41972 }
41973
41974 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
41975         LDKInvoice this_arg_conv;
41976         this_arg_conv.inner = (void*)(this_arg & (~1));
41977         this_arg_conv.is_owned = false;
41978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41979         jboolean ret_val = Invoice_is_expired(&this_arg_conv);
41980         return ret_val;
41981 }
41982
41983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
41984         LDKInvoice this_arg_conv;
41985         this_arg_conv.inner = (void*)(this_arg & (~1));
41986         this_arg_conv.is_owned = false;
41987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41988         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
41989         return ret_val;
41990 }
41991
41992 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
41993         LDKInvoice this_arg_conv;
41994         this_arg_conv.inner = (void*)(this_arg & (~1));
41995         this_arg_conv.is_owned = false;
41996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41997         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
41998         int64_tArray ret_arr = NULL;
41999         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
42000         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
42001         for (size_t o = 0; o < ret_var.datalen; o++) {
42002                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
42003                 uintptr_t ret_conv_14_ref = 0;
42004                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42005                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42006                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
42007                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
42008                 if (ret_conv_14_var.is_owned) {
42009                         ret_conv_14_ref |= 1;
42010                 }
42011                 ret_arr_ptr[o] = ret_conv_14_ref;
42012         }
42013         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
42014         FREE(ret_var.data);
42015         return ret_arr;
42016 }
42017
42018 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
42019         LDKInvoice this_arg_conv;
42020         this_arg_conv.inner = (void*)(this_arg & (~1));
42021         this_arg_conv.is_owned = false;
42022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42023         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
42024         int64_tArray ret_arr = NULL;
42025         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
42026         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
42027         for (size_t l = 0; l < ret_var.datalen; l++) {
42028                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
42029                 uintptr_t ret_conv_11_ref = 0;
42030                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42031                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42032                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
42033                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
42034                 if (ret_conv_11_var.is_owned) {
42035                         ret_conv_11_ref |= 1;
42036                 }
42037                 ret_arr_ptr[l] = ret_conv_11_ref;
42038         }
42039         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
42040         FREE(ret_var.data);
42041         return ret_arr;
42042 }
42043
42044 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
42045         LDKInvoice this_arg_conv;
42046         this_arg_conv.inner = (void*)(this_arg & (~1));
42047         this_arg_conv.is_owned = false;
42048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42049         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
42050         return ret_conv;
42051 }
42052
42053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
42054         LDKInvoice this_arg_conv;
42055         this_arg_conv.inner = (void*)(this_arg & (~1));
42056         this_arg_conv.is_owned = false;
42057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42058         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42059         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
42060         uintptr_t ret_ref = (uintptr_t)ret_copy;
42061         return ret_ref;
42062 }
42063
42064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
42065         LDKStr description_conv = java_to_owned_str(env, description);
42066         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
42067         *ret_conv = Description_new(description_conv);
42068         return (uintptr_t)ret_conv;
42069 }
42070
42071 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
42072         LDKDescription this_arg_conv;
42073         this_arg_conv.inner = (void*)(this_arg & (~1));
42074         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
42075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42076         this_arg_conv = Description_clone(&this_arg_conv);
42077         LDKStr ret_str = Description_into_inner(this_arg_conv);
42078         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
42079         Str_free(ret_str);
42080         return ret_conv;
42081 }
42082
42083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
42084         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
42085         *ret_conv = ExpiryTime_from_seconds(seconds);
42086         return (uintptr_t)ret_conv;
42087 }
42088
42089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
42090         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
42091         *ret_conv = ExpiryTime_from_duration(duration);
42092         return (uintptr_t)ret_conv;
42093 }
42094
42095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
42096         LDKExpiryTime this_arg_conv;
42097         this_arg_conv.inner = (void*)(this_arg & (~1));
42098         this_arg_conv.is_owned = false;
42099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42100         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
42101         return ret_val;
42102 }
42103
42104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
42105         LDKExpiryTime this_arg_conv;
42106         this_arg_conv.inner = (void*)(this_arg & (~1));
42107         this_arg_conv.is_owned = false;
42108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42109         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
42110         return ret_val;
42111 }
42112
42113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
42114         LDKRouteHint hops_conv;
42115         hops_conv.inner = (void*)(hops & (~1));
42116         hops_conv.is_owned = (hops & 1) || (hops == 0);
42117         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
42118         hops_conv = RouteHint_clone(&hops_conv);
42119         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
42120         *ret_conv = PrivateRoute_new(hops_conv);
42121         return (uintptr_t)ret_conv;
42122 }
42123
42124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
42125         LDKPrivateRoute this_arg_conv;
42126         this_arg_conv.inner = (void*)(this_arg & (~1));
42127         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
42128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42129         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
42130         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
42131         uintptr_t ret_ref = 0;
42132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42135         ret_ref = (uintptr_t)ret_var.inner;
42136         if (ret_var.is_owned) {
42137                 ret_ref |= 1;
42138         }
42139         return ret_ref;
42140 }
42141
42142 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42143         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
42144         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
42145         return ret_conv;
42146 }
42147
42148 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
42149         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
42150         return ret_conv;
42151 }
42152
42153 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
42154         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
42155         return ret_conv;
42156 }
42157
42158 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
42159         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
42160         return ret_conv;
42161 }
42162
42163 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1expiry_1time_1out_1of_1bounds(JNIEnv *env, jclass clz) {
42164         jclass ret_conv = LDKCreationError_to_java(env, CreationError_expiry_time_out_of_bounds());
42165         return ret_conv;
42166 }
42167
42168 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
42169         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
42170         return ret_conv;
42171 }
42172
42173 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42174         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
42175         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
42176         jboolean ret_val = CreationError_eq(a_conv, b_conv);
42177         return ret_val;
42178 }
42179
42180 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
42181         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
42182         LDKStr ret_str = CreationError_to_str(o_conv);
42183         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
42184         Str_free(ret_str);
42185         return ret_conv;
42186 }
42187
42188 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42189         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
42190         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
42191         return ret_conv;
42192 }
42193
42194 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
42195         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
42196         return ret_conv;
42197 }
42198
42199 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
42200         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
42201         return ret_conv;
42202 }
42203
42204 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
42205         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
42206         return ret_conv;
42207 }
42208
42209 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
42210         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
42211         return ret_conv;
42212 }
42213
42214 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
42215         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
42216         return ret_conv;
42217 }
42218
42219 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
42220         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
42221         return ret_conv;
42222 }
42223
42224 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
42225         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
42226         return ret_conv;
42227 }
42228
42229 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
42230         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
42231         return ret_conv;
42232 }
42233
42234 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
42235         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
42236         return ret_conv;
42237 }
42238
42239 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
42240         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
42241         return ret_conv;
42242 }
42243
42244 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42245         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
42246         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
42247         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
42248         return ret_val;
42249 }
42250
42251 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
42252         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
42253         LDKStr ret_str = SemanticError_to_str(o_conv);
42254         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
42255         Str_free(ret_str);
42256         return ret_conv;
42257 }
42258
42259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42260         if ((this_ptr & 1) != 0) return;
42261         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42262         CHECK_ACCESS(this_ptr_ptr);
42263         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
42264         FREE((void*)this_ptr);
42265         SignOrCreationError_free(this_ptr_conv);
42266 }
42267
42268 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
42269         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
42270         *ret_copy = SignOrCreationError_clone(arg);
42271 uintptr_t ret_ref = (uintptr_t)ret_copy;
42272         return ret_ref;
42273 }
42274 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42275         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
42276         intptr_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
42277         return ret_val;
42278 }
42279
42280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42281         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
42282         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
42283         *ret_copy = SignOrCreationError_clone(orig_conv);
42284         uintptr_t ret_ref = (uintptr_t)ret_copy;
42285         return ret_ref;
42286 }
42287
42288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
42289         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
42290         *ret_copy = SignOrCreationError_sign_error();
42291         uintptr_t ret_ref = (uintptr_t)ret_copy;
42292         return ret_ref;
42293 }
42294
42295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
42296         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
42297         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
42298         *ret_copy = SignOrCreationError_creation_error(a_conv);
42299         uintptr_t ret_ref = (uintptr_t)ret_copy;
42300         return ret_ref;
42301 }
42302
42303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42304         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
42305         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
42306         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
42307         return ret_val;
42308 }
42309
42310 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
42311         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
42312         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
42313         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
42314         Str_free(ret_str);
42315         return ret_conv;
42316 }
42317
42318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42319         LDKInvoicePayer this_obj_conv;
42320         this_obj_conv.inner = (void*)(this_obj & (~1));
42321         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42323         InvoicePayer_free(this_obj_conv);
42324 }
42325
42326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42327         if ((this_ptr & 1) != 0) return;
42328         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42329         CHECK_ACCESS(this_ptr_ptr);
42330         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
42331         FREE((void*)this_ptr);
42332         Payer_free(this_ptr_conv);
42333 }
42334
42335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42336         if ((this_ptr & 1) != 0) return;
42337         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42338         CHECK_ACCESS(this_ptr_ptr);
42339         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
42340         FREE((void*)this_ptr);
42341         Router_free(this_ptr_conv);
42342 }
42343
42344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42345         LDKRetryAttempts this_obj_conv;
42346         this_obj_conv.inner = (void*)(this_obj & (~1));
42347         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42349         RetryAttempts_free(this_obj_conv);
42350 }
42351
42352 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
42353         LDKRetryAttempts this_ptr_conv;
42354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42355         this_ptr_conv.is_owned = false;
42356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42357         intptr_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
42358         return ret_val;
42359 }
42360
42361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, intptr_t val) {
42362         LDKRetryAttempts this_ptr_conv;
42363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42364         this_ptr_conv.is_owned = false;
42365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42366         RetryAttempts_set_a(&this_ptr_conv, val);
42367 }
42368
42369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1new(JNIEnv *env, jclass clz, intptr_t a_arg) {
42370         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
42371         uintptr_t ret_ref = 0;
42372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42375         ret_ref = (uintptr_t)ret_var.inner;
42376         if (ret_var.is_owned) {
42377                 ret_ref |= 1;
42378         }
42379         return ret_ref;
42380 }
42381
42382 static inline uintptr_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
42383         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
42384 uintptr_t ret_ref = 0;
42385 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42386 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42387 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42388 ret_ref = (uintptr_t)ret_var.inner;
42389 if (ret_var.is_owned) {
42390         ret_ref |= 1;
42391 }
42392         return ret_ref;
42393 }
42394 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42395         LDKRetryAttempts arg_conv;
42396         arg_conv.inner = (void*)(arg & (~1));
42397         arg_conv.is_owned = false;
42398         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42399         intptr_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
42400         return ret_val;
42401 }
42402
42403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42404         LDKRetryAttempts orig_conv;
42405         orig_conv.inner = (void*)(orig & (~1));
42406         orig_conv.is_owned = false;
42407         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42408         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
42409         uintptr_t ret_ref = 0;
42410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42413         ret_ref = (uintptr_t)ret_var.inner;
42414         if (ret_var.is_owned) {
42415                 ret_ref |= 1;
42416         }
42417         return ret_ref;
42418 }
42419
42420 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42421         LDKRetryAttempts a_conv;
42422         a_conv.inner = (void*)(a & (~1));
42423         a_conv.is_owned = false;
42424         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42425         LDKRetryAttempts b_conv;
42426         b_conv.inner = (void*)(b & (~1));
42427         b_conv.is_owned = false;
42428         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42429         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
42430         return ret_val;
42431 }
42432
42433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1hash(JNIEnv *env, jclass clz, int64_t o) {
42434         LDKRetryAttempts o_conv;
42435         o_conv.inner = (void*)(o & (~1));
42436         o_conv.is_owned = false;
42437         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42438         int64_t ret_val = RetryAttempts_hash(&o_conv);
42439         return ret_val;
42440 }
42441
42442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42443         if ((this_ptr & 1) != 0) return;
42444         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42445         CHECK_ACCESS(this_ptr_ptr);
42446         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
42447         FREE((void*)this_ptr);
42448         PaymentError_free(this_ptr_conv);
42449 }
42450
42451 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
42452         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
42453         *ret_copy = PaymentError_clone(arg);
42454 uintptr_t ret_ref = (uintptr_t)ret_copy;
42455         return ret_ref;
42456 }
42457 JNIEXPORT intptr_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42458         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
42459         intptr_t ret_val = PaymentError_clone_ptr(arg_conv);
42460         return ret_val;
42461 }
42462
42463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42464         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
42465         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
42466         *ret_copy = PaymentError_clone(orig_conv);
42467         uintptr_t ret_ref = (uintptr_t)ret_copy;
42468         return ret_ref;
42469 }
42470
42471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
42472         LDKStr a_conv = java_to_owned_str(env, a);
42473         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
42474         *ret_copy = PaymentError_invoice(a_conv);
42475         uintptr_t ret_ref = (uintptr_t)ret_copy;
42476         return ret_ref;
42477 }
42478
42479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
42480         LDKLightningError a_conv;
42481         a_conv.inner = (void*)(a & (~1));
42482         a_conv.is_owned = (a & 1) || (a == 0);
42483         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42484         a_conv = LightningError_clone(&a_conv);
42485         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
42486         *ret_copy = PaymentError_routing(a_conv);
42487         uintptr_t ret_ref = (uintptr_t)ret_copy;
42488         return ret_ref;
42489 }
42490
42491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
42492         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
42493         CHECK_ACCESS(a_ptr);
42494         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
42495         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
42496         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
42497         *ret_copy = PaymentError_sending(a_conv);
42498         uintptr_t ret_ref = (uintptr_t)ret_copy;
42499         return ret_ref;
42500 }
42501
42502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new(JNIEnv *env, jclass clz, int64_t payer, int64_t router, int64_t scorer, int64_t logger, int64_t event_handler, int64_t retry_attempts) {
42503         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
42504         CHECK_ACCESS(payer_ptr);
42505         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
42506         if (payer_conv.free == LDKPayer_JCalls_free) {
42507                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42508                 LDKPayer_JCalls_cloned(&payer_conv);
42509         }
42510         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
42511         CHECK_ACCESS(router_ptr);
42512         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
42513         if (router_conv.free == LDKRouter_JCalls_free) {
42514                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42515                 LDKRouter_JCalls_cloned(&router_conv);
42516         }
42517         LDKMultiThreadedLockableScore scorer_conv;
42518         scorer_conv.inner = (void*)(scorer & (~1));
42519         scorer_conv.is_owned = false;
42520         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
42521         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42522         CHECK_ACCESS(logger_ptr);
42523         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42524         if (logger_conv.free == LDKLogger_JCalls_free) {
42525                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42526                 LDKLogger_JCalls_cloned(&logger_conv);
42527         }
42528         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
42529         CHECK_ACCESS(event_handler_ptr);
42530         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
42531         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
42532                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42533                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
42534         }
42535         LDKRetryAttempts retry_attempts_conv;
42536         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
42537         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
42538         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
42539         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
42540         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
42541         uintptr_t ret_ref = 0;
42542         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42543         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42545         ret_ref = (uintptr_t)ret_var.inner;
42546         if (ret_var.is_owned) {
42547                 ret_ref |= 1;
42548         }
42549         return ret_ref;
42550 }
42551
42552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
42553         LDKInvoicePayer this_arg_conv;
42554         this_arg_conv.inner = (void*)(this_arg & (~1));
42555         this_arg_conv.is_owned = false;
42556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42557         LDKInvoice invoice_conv;
42558         invoice_conv.inner = (void*)(invoice & (~1));
42559         invoice_conv.is_owned = false;
42560         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
42561         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
42562         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
42563         return (uintptr_t)ret_conv;
42564 }
42565
42566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1zero_1value_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice, int64_t amount_msats) {
42567         LDKInvoicePayer this_arg_conv;
42568         this_arg_conv.inner = (void*)(this_arg & (~1));
42569         this_arg_conv.is_owned = false;
42570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42571         LDKInvoice invoice_conv;
42572         invoice_conv.inner = (void*)(invoice & (~1));
42573         invoice_conv.is_owned = false;
42574         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
42575         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
42576         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
42577         return (uintptr_t)ret_conv;
42578 }
42579
42580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey, int8_tArray payment_preimage, int64_t amount_msats, int32_t final_cltv_expiry_delta) {
42581         LDKInvoicePayer this_arg_conv;
42582         this_arg_conv.inner = (void*)(this_arg & (~1));
42583         this_arg_conv.is_owned = false;
42584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42585         LDKPublicKey pubkey_ref;
42586         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
42587         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
42588         LDKThirtyTwoBytes payment_preimage_ref;
42589         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
42590         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
42591         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
42592         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
42593         return (uintptr_t)ret_conv;
42594 }
42595
42596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
42597         LDKInvoicePayer this_arg_conv;
42598         this_arg_conv.inner = (void*)(this_arg & (~1));
42599         this_arg_conv.is_owned = false;
42600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42601         unsigned char payment_hash_arr[32];
42602         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
42603         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
42604         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
42605         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
42606 }
42607
42608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
42609         LDKInvoicePayer this_arg_conv;
42610         this_arg_conv.inner = (void*)(this_arg & (~1));
42611         this_arg_conv.is_owned = false;
42612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42613         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
42614         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
42615         return (uintptr_t)ret_ret;
42616 }
42617
42618 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) {
42619         LDKChannelManager channelmanager_conv;
42620         channelmanager_conv.inner = (void*)(channelmanager & (~1));
42621         channelmanager_conv.is_owned = false;
42622         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
42623         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
42624         CHECK_ACCESS(keys_manager_ptr);
42625         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
42626         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
42627                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42628                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
42629         }
42630         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
42631         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
42632         CHECK_ACCESS(amt_msat_ptr);
42633         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
42634         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
42635         LDKStr description_conv = java_to_owned_str(env, description);
42636         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
42637         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
42638         return (uintptr_t)ret_conv;
42639 }
42640
42641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42642         LDKDefaultRouter this_obj_conv;
42643         this_obj_conv.inner = (void*)(this_obj & (~1));
42644         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42646         DefaultRouter_free(this_obj_conv);
42647 }
42648
42649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
42650         LDKNetworkGraph network_graph_conv;
42651         network_graph_conv.inner = (void*)(network_graph & (~1));
42652         network_graph_conv.is_owned = false;
42653         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42654         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42655         CHECK_ACCESS(logger_ptr);
42656         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42657         if (logger_conv.free == LDKLogger_JCalls_free) {
42658                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42659                 LDKLogger_JCalls_cloned(&logger_conv);
42660         }
42661         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
42662         uintptr_t ret_ref = 0;
42663         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42664         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42666         ret_ref = (uintptr_t)ret_var.inner;
42667         if (ret_var.is_owned) {
42668                 ret_ref |= 1;
42669         }
42670         return ret_ref;
42671 }
42672
42673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
42674         LDKDefaultRouter this_arg_conv;
42675         this_arg_conv.inner = (void*)(this_arg & (~1));
42676         this_arg_conv.is_owned = false;
42677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42678         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
42679         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
42680         return (uintptr_t)ret_ret;
42681 }
42682
42683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
42684         LDKChannelManager this_arg_conv;
42685         this_arg_conv.inner = (void*)(this_arg & (~1));
42686         this_arg_conv.is_owned = false;
42687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42688         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
42689         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
42690         return (uintptr_t)ret_ret;
42691 }
42692
42693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
42694         LDKStr s_conv = java_to_owned_str(env, s);
42695         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
42696         *ret_conv = SiPrefix_from_str(s_conv);
42697         return (uintptr_t)ret_conv;
42698 }
42699
42700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
42701         LDKStr s_conv = java_to_owned_str(env, s);
42702         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
42703         *ret_conv = Invoice_from_str(s_conv);
42704         return (uintptr_t)ret_conv;
42705 }
42706
42707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
42708         LDKStr s_conv = java_to_owned_str(env, s);
42709         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
42710         *ret_conv = SignedRawInvoice_from_str(s_conv);
42711         return (uintptr_t)ret_conv;
42712 }
42713
42714 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
42715         LDKInvoice o_conv;
42716         o_conv.inner = (void*)(o & (~1));
42717         o_conv.is_owned = false;
42718         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42719         LDKStr ret_str = Invoice_to_str(&o_conv);
42720         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
42721         Str_free(ret_str);
42722         return ret_conv;
42723 }
42724
42725 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
42726         LDKSignedRawInvoice o_conv;
42727         o_conv.inner = (void*)(o & (~1));
42728         o_conv.is_owned = false;
42729         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42730         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
42731         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
42732         Str_free(ret_str);
42733         return ret_conv;
42734 }
42735
42736 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
42737         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
42738         LDKStr ret_str = Currency_to_str(o_conv);
42739         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
42740         Str_free(ret_str);
42741         return ret_conv;
42742 }
42743
42744 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
42745         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
42746         LDKStr ret_str = SiPrefix_to_str(o_conv);
42747         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
42748         Str_free(ret_str);
42749         return ret_conv;
42750 }
42751