[Java] Update auto-generated Java bindings for 0.0.108
[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_InvalidAmount;
309                 case 4: return LDKCreationError_MissingRouteHints;
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_InvalidAmount = NULL;
319 static jfieldID CreationError_LDKCreationError_MissingRouteHints = 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_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
330         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
331         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
332         CHECK(CreationError_LDKCreationError_MissingRouteHints != 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_InvalidAmount:
343                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
344                 case LDKCreationError_MissingRouteHints:
345                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
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 LDKRecipient LDKRecipient_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 Recipient.ordinal() from rust threw an exception.");
641         }
642         switch (ord) {
643                 case 0: return LDKRecipient_Node;
644                 case 1: return LDKRecipient_PhantomNode;
645         }
646         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
647         abort(); // Unreachable, but will let the compiler know we don't return here
648 }
649 static jclass Recipient_class = NULL;
650 static jfieldID Recipient_LDKRecipient_Node = NULL;
651 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
652 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
653         Recipient_class = (*env)->NewGlobalRef(env, clz);
654         CHECK(Recipient_class != NULL);
655         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
656         CHECK(Recipient_LDKRecipient_Node != NULL);
657         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
658         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
659 }
660 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
661         switch (val) {
662                 case LDKRecipient_Node:
663                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
664                 case LDKRecipient_PhantomNode:
665                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
666                 default: abort();
667         }
668 }
669
670 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
671         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
672         if (UNLIKELY((*env)->ExceptionCheck(env))) {
673                 (*env)->ExceptionDescribe(env);
674                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
675         }
676         switch (ord) {
677                 case 0: return LDKSecp256k1Error_IncorrectSignature;
678                 case 1: return LDKSecp256k1Error_InvalidMessage;
679                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
680                 case 3: return LDKSecp256k1Error_InvalidSignature;
681                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
682                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
683                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
684                 case 7: return LDKSecp256k1Error_InvalidTweak;
685                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
686                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
687                 case 10: return LDKSecp256k1Error_InvalidParityValue;
688         }
689         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
690         abort(); // Unreachable, but will let the compiler know we don't return here
691 }
692 static jclass Secp256k1Error_class = NULL;
693 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
694 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
695 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
696 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
697 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
698 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = NULL;
699 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
700 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
701 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
702 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = NULL;
703 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = NULL;
704 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
705         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
706         CHECK(Secp256k1Error_class != NULL);
707         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
708         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
709         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
710         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
711         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
712         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
713         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
714         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
715         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
716         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
717         Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSharedSecret", "Lorg/ldk/enums/Secp256k1Error;");
718         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret != NULL);
719         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
720         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
721         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
722         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
723         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
724         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
725         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKeySum", "Lorg/ldk/enums/Secp256k1Error;");
726         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum != NULL);
727         Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidParityValue", "Lorg/ldk/enums/Secp256k1Error;");
728         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidParityValue != NULL);
729 }
730 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
731         switch (val) {
732                 case LDKSecp256k1Error_IncorrectSignature:
733                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
734                 case LDKSecp256k1Error_InvalidMessage:
735                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
736                 case LDKSecp256k1Error_InvalidPublicKey:
737                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
738                 case LDKSecp256k1Error_InvalidSignature:
739                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
740                 case LDKSecp256k1Error_InvalidSecretKey:
741                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
742                 case LDKSecp256k1Error_InvalidSharedSecret:
743                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret);
744                 case LDKSecp256k1Error_InvalidRecoveryId:
745                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
746                 case LDKSecp256k1Error_InvalidTweak:
747                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
748                 case LDKSecp256k1Error_NotEnoughMemory:
749                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
750                 case LDKSecp256k1Error_InvalidPublicKeySum:
751                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum);
752                 case LDKSecp256k1Error_InvalidParityValue:
753                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidParityValue);
754                 default: abort();
755         }
756 }
757
758 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
759         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
760         if (UNLIKELY((*env)->ExceptionCheck(env))) {
761                 (*env)->ExceptionDescribe(env);
762                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
763         }
764         switch (ord) {
765                 case 0: return LDKSemanticError_NoPaymentHash;
766                 case 1: return LDKSemanticError_MultiplePaymentHashes;
767                 case 2: return LDKSemanticError_NoDescription;
768                 case 3: return LDKSemanticError_MultipleDescriptions;
769                 case 4: return LDKSemanticError_NoPaymentSecret;
770                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
771                 case 6: return LDKSemanticError_InvalidFeatures;
772                 case 7: return LDKSemanticError_InvalidRecoveryId;
773                 case 8: return LDKSemanticError_InvalidSignature;
774                 case 9: return LDKSemanticError_ImpreciseAmount;
775         }
776         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
777         abort(); // Unreachable, but will let the compiler know we don't return here
778 }
779 static jclass SemanticError_class = NULL;
780 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
781 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
782 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
783 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
784 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
785 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
786 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
787 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
788 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
789 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
790 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
791         SemanticError_class = (*env)->NewGlobalRef(env, clz);
792         CHECK(SemanticError_class != NULL);
793         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
794         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
795         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
796         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
797         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
798         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
799         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
800         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
801         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
802         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
803         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
804         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
805         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
806         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
807         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
808         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
809         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
810         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
811         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
812         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
813 }
814 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
815         switch (val) {
816                 case LDKSemanticError_NoPaymentHash:
817                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
818                 case LDKSemanticError_MultiplePaymentHashes:
819                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
820                 case LDKSemanticError_NoDescription:
821                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
822                 case LDKSemanticError_MultipleDescriptions:
823                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
824                 case LDKSemanticError_NoPaymentSecret:
825                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
826                 case LDKSemanticError_MultiplePaymentSecrets:
827                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
828                 case LDKSemanticError_InvalidFeatures:
829                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
830                 case LDKSemanticError_InvalidRecoveryId:
831                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
832                 case LDKSemanticError_InvalidSignature:
833                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
834                 case LDKSemanticError_ImpreciseAmount:
835                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
836                 default: abort();
837         }
838 }
839
840 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
841         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
842         if (UNLIKELY((*env)->ExceptionCheck(env))) {
843                 (*env)->ExceptionDescribe(env);
844                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
845         }
846         switch (ord) {
847                 case 0: return LDKSiPrefix_Milli;
848                 case 1: return LDKSiPrefix_Micro;
849                 case 2: return LDKSiPrefix_Nano;
850                 case 3: return LDKSiPrefix_Pico;
851         }
852         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
853         abort(); // Unreachable, but will let the compiler know we don't return here
854 }
855 static jclass SiPrefix_class = NULL;
856 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
857 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
858 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
859 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
860 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
861         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
862         CHECK(SiPrefix_class != NULL);
863         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
864         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
865         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
866         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
867         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
868         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
869         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
870         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
871 }
872 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
873         switch (val) {
874                 case LDKSiPrefix_Milli:
875                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
876                 case LDKSiPrefix_Micro:
877                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
878                 case LDKSiPrefix_Nano:
879                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
880                 case LDKSiPrefix_Pico:
881                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
882                 default: abort();
883         }
884 }
885
886 static jclass LDKBech32Error_MissingSeparator_class = NULL;
887 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
888 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
889 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
890 static jclass LDKBech32Error_InvalidLength_class = NULL;
891 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
892 static jclass LDKBech32Error_InvalidChar_class = NULL;
893 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
894 static jclass LDKBech32Error_InvalidData_class = NULL;
895 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
896 static jclass LDKBech32Error_InvalidPadding_class = NULL;
897 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
898 static jclass LDKBech32Error_MixedCase_class = NULL;
899 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
901         LDKBech32Error_MissingSeparator_class =
902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
903         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
904         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
905         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
906         LDKBech32Error_InvalidChecksum_class =
907                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
908         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
909         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
910         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
911         LDKBech32Error_InvalidLength_class =
912                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
913         CHECK(LDKBech32Error_InvalidLength_class != NULL);
914         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
915         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
916         LDKBech32Error_InvalidChar_class =
917                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
918         CHECK(LDKBech32Error_InvalidChar_class != NULL);
919         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
920         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
921         LDKBech32Error_InvalidData_class =
922                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
923         CHECK(LDKBech32Error_InvalidData_class != NULL);
924         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
925         CHECK(LDKBech32Error_InvalidData_meth != NULL);
926         LDKBech32Error_InvalidPadding_class =
927                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
928         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
929         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
930         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
931         LDKBech32Error_MixedCase_class =
932                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
933         CHECK(LDKBech32Error_MixedCase_class != NULL);
934         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
935         CHECK(LDKBech32Error_MixedCase_meth != NULL);
936 }
937 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
938         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
939         switch(obj->tag) {
940                 case LDKBech32Error_MissingSeparator: {
941                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
942                 }
943                 case LDKBech32Error_InvalidChecksum: {
944                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
945                 }
946                 case LDKBech32Error_InvalidLength: {
947                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
948                 }
949                 case LDKBech32Error_InvalidChar: {
950                         int32_t invalid_char_conv = obj->invalid_char;
951                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
952                 }
953                 case LDKBech32Error_InvalidData: {
954                         int8_t invalid_data_conv = obj->invalid_data;
955                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
956                 }
957                 case LDKBech32Error_InvalidPadding: {
958                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
959                 }
960                 case LDKBech32Error_MixedCase: {
961                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
962                 }
963                 default: abort();
964         }
965 }
966 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
967         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
968         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
969         return ret;
970 }
971 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) {
972         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
973         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
974         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
975         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
976         CVec_u8Z_free(ret_var);
977         return ret_arr;
978 }
979
980 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) {
981         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
982         int64_t ret_conv = TxOut_get_value(thing_conv);
983         return ret_conv;
984 }
985
986 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
987 CHECK(owner->result_ok);
988         return *owner->contents.result;
989 }
990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
991         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
992         CResult_NoneNoneZ_get_ok(owner_conv);
993 }
994
995 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
996 CHECK(!owner->result_ok);
997         return *owner->contents.err;
998 }
999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1000         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
1001         CResult_NoneNoneZ_get_err(owner_conv);
1002 }
1003
1004 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1005 CHECK(owner->result_ok);
1006         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
1007 }
1008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1009         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1010         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1011         int64_t ret_ref = 0;
1012         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1013         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1015         ret_ref = (uintptr_t)ret_var.inner;
1016         if (ret_var.is_owned) {
1017                 ret_ref |= 1;
1018         }
1019         return ret_ref;
1020 }
1021
1022 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1023 CHECK(!owner->result_ok);
1024         return DecodeError_clone(&*owner->contents.err);
1025 }
1026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1027         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1028         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1029         int64_t ret_ref = 0;
1030         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1031         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1033         ret_ref = (uintptr_t)ret_var.inner;
1034         if (ret_var.is_owned) {
1035                 ret_ref |= 1;
1036         }
1037         return ret_ref;
1038 }
1039
1040 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1041 CHECK(owner->result_ok);
1042         return *owner->contents.result;
1043 }
1044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1045         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1046         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1047         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
1048         return ret_arr;
1049 }
1050
1051 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1052 CHECK(!owner->result_ok);
1053         return *owner->contents.err;
1054 }
1055 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1056         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1057         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
1058         return ret_conv;
1059 }
1060
1061 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1062 CHECK(owner->result_ok);
1063         return *owner->contents.result;
1064 }
1065 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1066         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1067         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1068         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
1069         return ret_arr;
1070 }
1071
1072 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1073 CHECK(!owner->result_ok);
1074         return *owner->contents.err;
1075 }
1076 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1077         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1078         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
1079         return ret_conv;
1080 }
1081
1082 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1083 CHECK(owner->result_ok);
1084         return TxCreationKeys_clone(&*owner->contents.result);
1085 }
1086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1087         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1088         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1089         int64_t ret_ref = 0;
1090         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1091         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1093         ret_ref = (uintptr_t)ret_var.inner;
1094         if (ret_var.is_owned) {
1095                 ret_ref |= 1;
1096         }
1097         return ret_ref;
1098 }
1099
1100 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1101 CHECK(!owner->result_ok);
1102         return DecodeError_clone(&*owner->contents.err);
1103 }
1104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1105         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1106         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1107         int64_t ret_ref = 0;
1108         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1109         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1111         ret_ref = (uintptr_t)ret_var.inner;
1112         if (ret_var.is_owned) {
1113                 ret_ref |= 1;
1114         }
1115         return ret_ref;
1116 }
1117
1118 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1119 CHECK(owner->result_ok);
1120         return ChannelPublicKeys_clone(&*owner->contents.result);
1121 }
1122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1123         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1124         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1125         int64_t ret_ref = 0;
1126         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1127         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1129         ret_ref = (uintptr_t)ret_var.inner;
1130         if (ret_var.is_owned) {
1131                 ret_ref |= 1;
1132         }
1133         return ret_ref;
1134 }
1135
1136 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1137 CHECK(!owner->result_ok);
1138         return DecodeError_clone(&*owner->contents.err);
1139 }
1140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1141         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1142         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1143         int64_t ret_ref = 0;
1144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1147         ret_ref = (uintptr_t)ret_var.inner;
1148         if (ret_var.is_owned) {
1149                 ret_ref |= 1;
1150         }
1151         return ret_ref;
1152 }
1153
1154 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1155 CHECK(owner->result_ok);
1156         return TxCreationKeys_clone(&*owner->contents.result);
1157 }
1158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1159         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1160         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
1161         int64_t ret_ref = 0;
1162         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1163         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1165         ret_ref = (uintptr_t)ret_var.inner;
1166         if (ret_var.is_owned) {
1167                 ret_ref |= 1;
1168         }
1169         return ret_ref;
1170 }
1171
1172 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1173 CHECK(!owner->result_ok);
1174         return *owner->contents.err;
1175 }
1176 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1177         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1178         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1179         return ret_conv;
1180 }
1181
1182 static jclass LDKCOption_u32Z_Some_class = NULL;
1183 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1184 static jclass LDKCOption_u32Z_None_class = NULL;
1185 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1187         LDKCOption_u32Z_Some_class =
1188                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1189         CHECK(LDKCOption_u32Z_Some_class != NULL);
1190         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1191         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1192         LDKCOption_u32Z_None_class =
1193                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1194         CHECK(LDKCOption_u32Z_None_class != NULL);
1195         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1196         CHECK(LDKCOption_u32Z_None_meth != NULL);
1197 }
1198 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1199         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
1200         switch(obj->tag) {
1201                 case LDKCOption_u32Z_Some: {
1202                         int32_t some_conv = obj->some;
1203                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1204                 }
1205                 case LDKCOption_u32Z_None: {
1206                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1207                 }
1208                 default: abort();
1209         }
1210 }
1211 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1212 CHECK(owner->result_ok);
1213         return HTLCOutputInCommitment_clone(&*owner->contents.result);
1214 }
1215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1216         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1217         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1218         int64_t ret_ref = 0;
1219         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1220         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1222         ret_ref = (uintptr_t)ret_var.inner;
1223         if (ret_var.is_owned) {
1224                 ret_ref |= 1;
1225         }
1226         return ret_ref;
1227 }
1228
1229 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1230 CHECK(!owner->result_ok);
1231         return DecodeError_clone(&*owner->contents.err);
1232 }
1233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1234         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1235         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1236         int64_t ret_ref = 0;
1237         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1238         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1240         ret_ref = (uintptr_t)ret_var.inner;
1241         if (ret_var.is_owned) {
1242                 ret_ref |= 1;
1243         }
1244         return ret_ref;
1245 }
1246
1247 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1248 CHECK(owner->result_ok);
1249         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
1250 }
1251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1252         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1253         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1254         int64_t ret_ref = 0;
1255         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1256         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1258         ret_ref = (uintptr_t)ret_var.inner;
1259         if (ret_var.is_owned) {
1260                 ret_ref |= 1;
1261         }
1262         return ret_ref;
1263 }
1264
1265 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1266 CHECK(!owner->result_ok);
1267         return DecodeError_clone(&*owner->contents.err);
1268 }
1269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1270         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1271         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1272         int64_t ret_ref = 0;
1273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1276         ret_ref = (uintptr_t)ret_var.inner;
1277         if (ret_var.is_owned) {
1278                 ret_ref |= 1;
1279         }
1280         return ret_ref;
1281 }
1282
1283 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1284 CHECK(owner->result_ok);
1285         return ChannelTransactionParameters_clone(&*owner->contents.result);
1286 }
1287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1288         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1289         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1290         int64_t ret_ref = 0;
1291         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1292         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1294         ret_ref = (uintptr_t)ret_var.inner;
1295         if (ret_var.is_owned) {
1296                 ret_ref |= 1;
1297         }
1298         return ret_ref;
1299 }
1300
1301 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1302 CHECK(!owner->result_ok);
1303         return DecodeError_clone(&*owner->contents.err);
1304 }
1305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1306         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1307         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1308         int64_t ret_ref = 0;
1309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1312         ret_ref = (uintptr_t)ret_var.inner;
1313         if (ret_var.is_owned) {
1314                 ret_ref |= 1;
1315         }
1316         return ret_ref;
1317 }
1318
1319 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1320 CHECK(owner->result_ok);
1321         return HolderCommitmentTransaction_clone(&*owner->contents.result);
1322 }
1323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1324         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1325         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1326         int64_t ret_ref = 0;
1327         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1328         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1330         ret_ref = (uintptr_t)ret_var.inner;
1331         if (ret_var.is_owned) {
1332                 ret_ref |= 1;
1333         }
1334         return ret_ref;
1335 }
1336
1337 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1338 CHECK(!owner->result_ok);
1339         return DecodeError_clone(&*owner->contents.err);
1340 }
1341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1342         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1343         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1344         int64_t ret_ref = 0;
1345         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1346         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1348         ret_ref = (uintptr_t)ret_var.inner;
1349         if (ret_var.is_owned) {
1350                 ret_ref |= 1;
1351         }
1352         return ret_ref;
1353 }
1354
1355 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1356 CHECK(owner->result_ok);
1357         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
1358 }
1359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1360         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1361         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1362         int64_t ret_ref = 0;
1363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1366         ret_ref = (uintptr_t)ret_var.inner;
1367         if (ret_var.is_owned) {
1368                 ret_ref |= 1;
1369         }
1370         return ret_ref;
1371 }
1372
1373 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1374 CHECK(!owner->result_ok);
1375         return DecodeError_clone(&*owner->contents.err);
1376 }
1377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1378         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1379         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1380         int64_t ret_ref = 0;
1381         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1382         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1384         ret_ref = (uintptr_t)ret_var.inner;
1385         if (ret_var.is_owned) {
1386                 ret_ref |= 1;
1387         }
1388         return ret_ref;
1389 }
1390
1391 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1392 CHECK(owner->result_ok);
1393         return &*owner->contents.result;
1394 }
1395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1396         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1397         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1398         int64_t ret_ref = 0;
1399         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1400         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1402         ret_ref = (uintptr_t)ret_var.inner & ~1;
1403         return ret_ref;
1404 }
1405
1406 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1407 CHECK(!owner->result_ok);
1408         return *owner->contents.err;
1409 }
1410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1411         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1412         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1413 }
1414
1415 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1416 CHECK(owner->result_ok);
1417         return CommitmentTransaction_clone(&*owner->contents.result);
1418 }
1419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1420         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1421         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1422         int64_t ret_ref = 0;
1423         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1424         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1426         ret_ref = (uintptr_t)ret_var.inner;
1427         if (ret_var.is_owned) {
1428                 ret_ref |= 1;
1429         }
1430         return ret_ref;
1431 }
1432
1433 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1434 CHECK(!owner->result_ok);
1435         return DecodeError_clone(&*owner->contents.err);
1436 }
1437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1438         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1439         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1440         int64_t ret_ref = 0;
1441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1444         ret_ref = (uintptr_t)ret_var.inner;
1445         if (ret_var.is_owned) {
1446                 ret_ref |= 1;
1447         }
1448         return ret_ref;
1449 }
1450
1451 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1452 CHECK(owner->result_ok);
1453         return &*owner->contents.result;
1454 }
1455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1456         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1457         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1458         int64_t ret_ref = 0;
1459         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1460         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1462         ret_ref = (uintptr_t)ret_var.inner & ~1;
1463         return ret_ref;
1464 }
1465
1466 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1467 CHECK(!owner->result_ok);
1468         return *owner->contents.err;
1469 }
1470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1471         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1472         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1473 }
1474
1475 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1476 CHECK(owner->result_ok);
1477         return *owner->contents.result;
1478 }
1479 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1480         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1481         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1482         jobjectArray ret_arr = NULL;
1483         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1484         ;
1485         for (size_t i = 0; i < ret_var.datalen; i++) {
1486                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1487                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1488                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1489         }
1490         
1491         return ret_arr;
1492 }
1493
1494 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1495 CHECK(!owner->result_ok);
1496         return *owner->contents.err;
1497 }
1498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1499         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1500         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1501 }
1502
1503 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1504 CHECK(owner->result_ok);
1505         return ShutdownScript_clone(&*owner->contents.result);
1506 }
1507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1508         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1509         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1510         int64_t ret_ref = 0;
1511         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1512         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1514         ret_ref = (uintptr_t)ret_var.inner;
1515         if (ret_var.is_owned) {
1516                 ret_ref |= 1;
1517         }
1518         return ret_ref;
1519 }
1520
1521 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1522 CHECK(!owner->result_ok);
1523         return DecodeError_clone(&*owner->contents.err);
1524 }
1525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1526         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1527         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1528         int64_t ret_ref = 0;
1529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1532         ret_ref = (uintptr_t)ret_var.inner;
1533         if (ret_var.is_owned) {
1534                 ret_ref |= 1;
1535         }
1536         return ret_ref;
1537 }
1538
1539 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1540 CHECK(owner->result_ok);
1541         return ShutdownScript_clone(&*owner->contents.result);
1542 }
1543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1544         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1545         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1546         int64_t ret_ref = 0;
1547         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1548         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1550         ret_ref = (uintptr_t)ret_var.inner;
1551         if (ret_var.is_owned) {
1552                 ret_ref |= 1;
1553         }
1554         return ret_ref;
1555 }
1556
1557 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1558 CHECK(!owner->result_ok);
1559         return InvalidShutdownScript_clone(&*owner->contents.err);
1560 }
1561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1562         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1563         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1564         int64_t ret_ref = 0;
1565         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1566         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1568         ret_ref = (uintptr_t)ret_var.inner;
1569         if (ret_var.is_owned) {
1570                 ret_ref |= 1;
1571         }
1572         return ret_ref;
1573 }
1574
1575 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1576 CHECK(owner->result_ok);
1577         return *owner->contents.result;
1578 }
1579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1580         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1581         CResult_NoneErrorZ_get_ok(owner_conv);
1582 }
1583
1584 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1585 CHECK(!owner->result_ok);
1586         return *owner->contents.err;
1587 }
1588 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1589         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1590         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
1591         return ret_conv;
1592 }
1593
1594 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1595 CHECK(owner->result_ok);
1596         return RouteHop_clone(&*owner->contents.result);
1597 }
1598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1599         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1600         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1601         int64_t ret_ref = 0;
1602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1605         ret_ref = (uintptr_t)ret_var.inner;
1606         if (ret_var.is_owned) {
1607                 ret_ref |= 1;
1608         }
1609         return ret_ref;
1610 }
1611
1612 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1613 CHECK(!owner->result_ok);
1614         return DecodeError_clone(&*owner->contents.err);
1615 }
1616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1617         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1618         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1619         int64_t ret_ref = 0;
1620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1623         ret_ref = (uintptr_t)ret_var.inner;
1624         if (ret_var.is_owned) {
1625                 ret_ref |= 1;
1626         }
1627         return ret_ref;
1628 }
1629
1630 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1631         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1632         for (size_t i = 0; i < ret.datalen; i++) {
1633                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1634         }
1635         return ret;
1636 }
1637 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1638         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1639         for (size_t i = 0; i < ret.datalen; i++) {
1640                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1641         }
1642         return ret;
1643 }
1644 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1645 CHECK(owner->result_ok);
1646         return Route_clone(&*owner->contents.result);
1647 }
1648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1649         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1650         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1651         int64_t ret_ref = 0;
1652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1655         ret_ref = (uintptr_t)ret_var.inner;
1656         if (ret_var.is_owned) {
1657                 ret_ref |= 1;
1658         }
1659         return ret_ref;
1660 }
1661
1662 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1663 CHECK(!owner->result_ok);
1664         return DecodeError_clone(&*owner->contents.err);
1665 }
1666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1667         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1668         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1669         int64_t ret_ref = 0;
1670         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1671         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1673         ret_ref = (uintptr_t)ret_var.inner;
1674         if (ret_var.is_owned) {
1675                 ret_ref |= 1;
1676         }
1677         return ret_ref;
1678 }
1679
1680 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1681 CHECK(owner->result_ok);
1682         return RouteParameters_clone(&*owner->contents.result);
1683 }
1684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1685         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1686         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1687         int64_t ret_ref = 0;
1688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1691         ret_ref = (uintptr_t)ret_var.inner;
1692         if (ret_var.is_owned) {
1693                 ret_ref |= 1;
1694         }
1695         return ret_ref;
1696 }
1697
1698 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1699 CHECK(!owner->result_ok);
1700         return DecodeError_clone(&*owner->contents.err);
1701 }
1702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1703         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1704         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1705         int64_t ret_ref = 0;
1706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1709         ret_ref = (uintptr_t)ret_var.inner;
1710         if (ret_var.is_owned) {
1711                 ret_ref |= 1;
1712         }
1713         return ret_ref;
1714 }
1715
1716 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1717         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1718         for (size_t i = 0; i < ret.datalen; i++) {
1719                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1720         }
1721         return ret;
1722 }
1723 static jclass LDKCOption_u64Z_Some_class = NULL;
1724 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1725 static jclass LDKCOption_u64Z_None_class = NULL;
1726 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1728         LDKCOption_u64Z_Some_class =
1729                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1730         CHECK(LDKCOption_u64Z_Some_class != NULL);
1731         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1732         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1733         LDKCOption_u64Z_None_class =
1734                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1735         CHECK(LDKCOption_u64Z_None_class != NULL);
1736         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1737         CHECK(LDKCOption_u64Z_None_meth != NULL);
1738 }
1739 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1740         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1741         switch(obj->tag) {
1742                 case LDKCOption_u64Z_Some: {
1743                         int64_t some_conv = obj->some;
1744                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
1745                 }
1746                 case LDKCOption_u64Z_None: {
1747                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1748                 }
1749                 default: abort();
1750         }
1751 }
1752 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1753 CHECK(owner->result_ok);
1754         return PaymentParameters_clone(&*owner->contents.result);
1755 }
1756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1757         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1758         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1759         int64_t ret_ref = 0;
1760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1763         ret_ref = (uintptr_t)ret_var.inner;
1764         if (ret_var.is_owned) {
1765                 ret_ref |= 1;
1766         }
1767         return ret_ref;
1768 }
1769
1770 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1771 CHECK(!owner->result_ok);
1772         return DecodeError_clone(&*owner->contents.err);
1773 }
1774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1775         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1776         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1777         int64_t ret_ref = 0;
1778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1781         ret_ref = (uintptr_t)ret_var.inner;
1782         if (ret_var.is_owned) {
1783                 ret_ref |= 1;
1784         }
1785         return ret_ref;
1786 }
1787
1788 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1789         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1790         for (size_t i = 0; i < ret.datalen; i++) {
1791                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1792         }
1793         return ret;
1794 }
1795 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1796 CHECK(owner->result_ok);
1797         return RouteHint_clone(&*owner->contents.result);
1798 }
1799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1800         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1801         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1802         int64_t ret_ref = 0;
1803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1806         ret_ref = (uintptr_t)ret_var.inner;
1807         if (ret_var.is_owned) {
1808                 ret_ref |= 1;
1809         }
1810         return ret_ref;
1811 }
1812
1813 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1814 CHECK(!owner->result_ok);
1815         return DecodeError_clone(&*owner->contents.err);
1816 }
1817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1818         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1819         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1820         int64_t ret_ref = 0;
1821         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1822         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1824         ret_ref = (uintptr_t)ret_var.inner;
1825         if (ret_var.is_owned) {
1826                 ret_ref |= 1;
1827         }
1828         return ret_ref;
1829 }
1830
1831 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1832 CHECK(owner->result_ok);
1833         return RouteHintHop_clone(&*owner->contents.result);
1834 }
1835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1836         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1837         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1838         int64_t ret_ref = 0;
1839         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1840         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1842         ret_ref = (uintptr_t)ret_var.inner;
1843         if (ret_var.is_owned) {
1844                 ret_ref |= 1;
1845         }
1846         return ret_ref;
1847 }
1848
1849 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1850 CHECK(!owner->result_ok);
1851         return DecodeError_clone(&*owner->contents.err);
1852 }
1853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1854         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1855         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1856         int64_t ret_ref = 0;
1857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1860         ret_ref = (uintptr_t)ret_var.inner;
1861         if (ret_var.is_owned) {
1862                 ret_ref |= 1;
1863         }
1864         return ret_ref;
1865 }
1866
1867 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1868         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1869         for (size_t i = 0; i < ret.datalen; i++) {
1870                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1871         }
1872         return ret;
1873 }
1874 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1875 CHECK(owner->result_ok);
1876         return Route_clone(&*owner->contents.result);
1877 }
1878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1879         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1880         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1881         int64_t ret_ref = 0;
1882         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1883         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1885         ret_ref = (uintptr_t)ret_var.inner;
1886         if (ret_var.is_owned) {
1887                 ret_ref |= 1;
1888         }
1889         return ret_ref;
1890 }
1891
1892 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1893 CHECK(!owner->result_ok);
1894         return LightningError_clone(&*owner->contents.err);
1895 }
1896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1897         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1898         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1899         int64_t ret_ref = 0;
1900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1903         ret_ref = (uintptr_t)ret_var.inner;
1904         if (ret_var.is_owned) {
1905                 ret_ref |= 1;
1906         }
1907         return ret_ref;
1908 }
1909
1910 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
1911 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
1912 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
1913 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
1914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
1915         LDKPaymentPurpose_InvoicePayment_class =
1916                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
1917         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
1918         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
1919         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
1920         LDKPaymentPurpose_SpontaneousPayment_class =
1921                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
1922         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
1923         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
1924         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
1925 }
1926 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1927         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1928         switch(obj->tag) {
1929                 case LDKPaymentPurpose_InvoicePayment: {
1930                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1931                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
1932                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1933                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
1934                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
1935                 }
1936                 case LDKPaymentPurpose_SpontaneousPayment: {
1937                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
1938                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
1939                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
1940                 }
1941                 default: abort();
1942         }
1943 }
1944 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1945 CHECK(owner->result_ok);
1946         return PaymentPurpose_clone(&*owner->contents.result);
1947 }
1948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1949         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1950         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1951         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1952         int64_t ret_ref = (uintptr_t)ret_copy;
1953         return ret_ref;
1954 }
1955
1956 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1957 CHECK(!owner->result_ok);
1958         return DecodeError_clone(&*owner->contents.err);
1959 }
1960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1961         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1962         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1963         int64_t ret_ref = 0;
1964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1967         ret_ref = (uintptr_t)ret_var.inner;
1968         if (ret_var.is_owned) {
1969                 ret_ref |= 1;
1970         }
1971         return ret_ref;
1972 }
1973
1974 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
1975 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
1976 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
1977 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
1978 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
1979 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
1980 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
1981 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
1982 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
1983 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
1984 static jclass LDKClosureReason_ProcessingError_class = NULL;
1985 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
1986 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
1987 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
1988 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
1989 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
1990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
1991         LDKClosureReason_CounterpartyForceClosed_class =
1992                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
1993         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
1994         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
1995         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
1996         LDKClosureReason_HolderForceClosed_class =
1997                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
1998         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
1999         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2000         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2001         LDKClosureReason_CooperativeClosure_class =
2002                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2003         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2004         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2005         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2006         LDKClosureReason_CommitmentTxConfirmed_class =
2007                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2008         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2009         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2010         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2011         LDKClosureReason_FundingTimedOut_class =
2012                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2013         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2014         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2015         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2016         LDKClosureReason_ProcessingError_class =
2017                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2018         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2019         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2020         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2021         LDKClosureReason_DisconnectedPeer_class =
2022                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2023         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2024         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2025         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2026         LDKClosureReason_OutdatedChannelManager_class =
2027                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2028         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2029         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2030         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2031 }
2032 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2033         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
2034         switch(obj->tag) {
2035                 case LDKClosureReason_CounterpartyForceClosed: {
2036                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2037                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2038                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2039                 }
2040                 case LDKClosureReason_HolderForceClosed: {
2041                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2042                 }
2043                 case LDKClosureReason_CooperativeClosure: {
2044                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2045                 }
2046                 case LDKClosureReason_CommitmentTxConfirmed: {
2047                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2048                 }
2049                 case LDKClosureReason_FundingTimedOut: {
2050                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2051                 }
2052                 case LDKClosureReason_ProcessingError: {
2053                         LDKStr err_str = obj->processing_error.err;
2054                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2055                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2056                 }
2057                 case LDKClosureReason_DisconnectedPeer: {
2058                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2059                 }
2060                 case LDKClosureReason_OutdatedChannelManager: {
2061                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2062                 }
2063                 default: abort();
2064         }
2065 }
2066 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2067 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2068 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2069 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2071         LDKCOption_ClosureReasonZ_Some_class =
2072                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2073         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2074         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2075         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2076         LDKCOption_ClosureReasonZ_None_class =
2077                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2078         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2079         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2080         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2081 }
2082 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2083         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
2084         switch(obj->tag) {
2085                 case LDKCOption_ClosureReasonZ_Some: {
2086                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2087                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2088                 }
2089                 case LDKCOption_ClosureReasonZ_None: {
2090                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2091                 }
2092                 default: abort();
2093         }
2094 }
2095 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2096 CHECK(owner->result_ok);
2097         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2098 }
2099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2100         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2101         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2102         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2103         int64_t ret_ref = (uintptr_t)ret_copy;
2104         return ret_ref;
2105 }
2106
2107 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2108 CHECK(!owner->result_ok);
2109         return DecodeError_clone(&*owner->contents.err);
2110 }
2111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2112         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2113         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2114         int64_t ret_ref = 0;
2115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2118         ret_ref = (uintptr_t)ret_var.inner;
2119         if (ret_var.is_owned) {
2120                 ret_ref |= 1;
2121         }
2122         return ret_ref;
2123 }
2124
2125 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2126 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2127 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
2128 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
2129 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2130 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2132         LDKNetworkUpdate_ChannelUpdateMessage_class =
2133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2134         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2135         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2136         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2137         LDKNetworkUpdate_ChannelFailure_class =
2138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
2139         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
2140         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
2141         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
2142         LDKNetworkUpdate_NodeFailure_class =
2143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2144         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2145         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2146         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2147 }
2148 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2149         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
2150         switch(obj->tag) {
2151                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2152                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2153                         int64_t msg_ref = 0;
2154                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2155                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2156                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2157                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2158                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2159                 }
2160                 case LDKNetworkUpdate_ChannelFailure: {
2161                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
2162                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
2163                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
2164                 }
2165                 case LDKNetworkUpdate_NodeFailure: {
2166                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2167                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2168                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2169                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2170                 }
2171                 default: abort();
2172         }
2173 }
2174 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2175 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2176 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2177 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2179         LDKCOption_NetworkUpdateZ_Some_class =
2180                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2181         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2182         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2183         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2184         LDKCOption_NetworkUpdateZ_None_class =
2185                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2186         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2187         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2188         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2189 }
2190 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2191         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
2192         switch(obj->tag) {
2193                 case LDKCOption_NetworkUpdateZ_Some: {
2194                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2195                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2196                 }
2197                 case LDKCOption_NetworkUpdateZ_None: {
2198                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2199                 }
2200                 default: abort();
2201         }
2202 }
2203 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2204 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2205 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2206 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2207 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2208 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2210         LDKSpendableOutputDescriptor_StaticOutput_class =
2211                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2212         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2213         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2214         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2215         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2216                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2217         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2218         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2219         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2220         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2221                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2222         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2223         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2224         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2225 }
2226 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2227         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
2228         switch(obj->tag) {
2229                 case LDKSpendableOutputDescriptor_StaticOutput: {
2230                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2231                         int64_t outpoint_ref = 0;
2232                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2233                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2234                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2235                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
2236                         int64_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
2237                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (int64_t)output_ref);
2238                 }
2239                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2240                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2241                         int64_t delayed_payment_output_ref = 0;
2242                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2243                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2244                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2245                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
2246                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2247                 }
2248                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2249                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2250                         int64_t static_payment_output_ref = 0;
2251                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2252                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2253                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2254                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
2255                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2256                 }
2257                 default: abort();
2258         }
2259 }
2260 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2261         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2262         for (size_t i = 0; i < ret.datalen; i++) {
2263                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2264         }
2265         return ret;
2266 }
2267 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2268 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2269 static jclass LDKEvent_PaymentReceived_class = NULL;
2270 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2271 static jclass LDKEvent_PaymentClaimed_class = NULL;
2272 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
2273 static jclass LDKEvent_PaymentSent_class = NULL;
2274 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2275 static jclass LDKEvent_PaymentFailed_class = NULL;
2276 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2277 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2278 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2279 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2280 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2281 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2282 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2283 static jclass LDKEvent_SpendableOutputs_class = NULL;
2284 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2285 static jclass LDKEvent_PaymentForwarded_class = NULL;
2286 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2287 static jclass LDKEvent_ChannelClosed_class = NULL;
2288 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2289 static jclass LDKEvent_DiscardFunding_class = NULL;
2290 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
2291 static jclass LDKEvent_OpenChannelRequest_class = NULL;
2292 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
2293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
2294         LDKEvent_FundingGenerationReady_class =
2295                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
2296         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
2297         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[BJ)V");
2298         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
2299         LDKEvent_PaymentReceived_class =
2300                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
2301         CHECK(LDKEvent_PaymentReceived_class != NULL);
2302         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
2303         CHECK(LDKEvent_PaymentReceived_meth != NULL);
2304         LDKEvent_PaymentClaimed_class =
2305                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
2306         CHECK(LDKEvent_PaymentClaimed_class != NULL);
2307         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([BJJ)V");
2308         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
2309         LDKEvent_PaymentSent_class =
2310                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
2311         CHECK(LDKEvent_PaymentSent_class != NULL);
2312         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
2313         CHECK(LDKEvent_PaymentSent_meth != NULL);
2314         LDKEvent_PaymentFailed_class =
2315                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
2316         CHECK(LDKEvent_PaymentFailed_class != NULL);
2317         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
2318         CHECK(LDKEvent_PaymentFailed_meth != NULL);
2319         LDKEvent_PaymentPathSuccessful_class =
2320                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
2321         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
2322         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
2323         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
2324         LDKEvent_PaymentPathFailed_class =
2325                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
2326         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
2327         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
2328         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
2329         LDKEvent_PendingHTLCsForwardable_class =
2330                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
2331         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
2332         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
2333         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
2334         LDKEvent_SpendableOutputs_class =
2335                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
2336         CHECK(LDKEvent_SpendableOutputs_class != NULL);
2337         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
2338         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
2339         LDKEvent_PaymentForwarded_class =
2340                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
2341         CHECK(LDKEvent_PaymentForwarded_class != NULL);
2342         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZ)V");
2343         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
2344         LDKEvent_ChannelClosed_class =
2345                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
2346         CHECK(LDKEvent_ChannelClosed_class != NULL);
2347         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
2348         CHECK(LDKEvent_ChannelClosed_meth != NULL);
2349         LDKEvent_DiscardFunding_class =
2350                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
2351         CHECK(LDKEvent_DiscardFunding_class != NULL);
2352         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
2353         CHECK(LDKEvent_DiscardFunding_meth != NULL);
2354         LDKEvent_OpenChannelRequest_class =
2355                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
2356         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
2357         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
2358         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
2359 }
2360 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2361         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2362         switch(obj->tag) {
2363                 case LDKEvent_FundingGenerationReady: {
2364                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2365                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
2366                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2367                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
2368                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
2369                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
2370                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
2371                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2372                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
2373                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, counterparty_node_id_arr, channel_value_satoshis_conv, output_script_arr, user_channel_id_conv);
2374                 }
2375                 case LDKEvent_PaymentReceived: {
2376                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2377                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2378                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
2379                         int64_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
2380                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2381                 }
2382                 case LDKEvent_PaymentClaimed: {
2383                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2384                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
2385                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
2386                         int64_t purpose_ref = ((uintptr_t)&obj->payment_claimed.purpose) | 1;
2387                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2388                 }
2389                 case LDKEvent_PaymentSent: {
2390                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2391                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2392                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2393                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2394                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2395                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2396                         int64_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
2397                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2398                 }
2399                 case LDKEvent_PaymentFailed: {
2400                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2401                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2402                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2403                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2404                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2405                 }
2406                 case LDKEvent_PaymentPathSuccessful: {
2407                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2408                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2409                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2410                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2411                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2412                         int64_tArray path_arr = NULL;
2413                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2414                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2415                         for (size_t k = 0; k < path_var.datalen; k++) {
2416                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2417                                 int64_t path_conv_10_ref = 0;
2418                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2419                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2420                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2421                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2422                                 path_arr_ptr[k] = path_conv_10_ref;
2423                         }
2424                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2425                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2426                 }
2427                 case LDKEvent_PaymentPathFailed: {
2428                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2429                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
2430                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2431                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
2432                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
2433                         int64_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
2434                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
2435                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2436                         int64_tArray path_arr = NULL;
2437                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2438                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2439                         for (size_t k = 0; k < path_var.datalen; k++) {
2440                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2441                                 int64_t path_conv_10_ref = 0;
2442                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2443                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2444                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2445                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2446                                 path_arr_ptr[k] = path_conv_10_ref;
2447                         }
2448                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2449                         int64_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
2450                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2451                         int64_t retry_ref = 0;
2452                         if ((uintptr_t)retry_var.inner > 4096) {
2453                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2454                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2455                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2456                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
2457                         }
2458                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, rejected_by_dest_conv, network_update_ref, all_paths_failed_conv, path_arr, short_channel_id_ref, retry_ref);
2459                 }
2460                 case LDKEvent_PendingHTLCsForwardable: {
2461                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
2462                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
2463                 }
2464                 case LDKEvent_SpendableOutputs: {
2465                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2466                         int64_tArray outputs_arr = NULL;
2467                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2468                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2469                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2470                                 int64_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
2471                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2472                         }
2473                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2474                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2475                 }
2476                 case LDKEvent_PaymentForwarded: {
2477                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
2478                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
2479                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
2480                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
2481                         int64_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
2482                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
2483                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, prev_channel_id_arr, next_channel_id_arr, fee_earned_msat_ref, claim_from_onchain_tx_conv);
2484                 }
2485                 case LDKEvent_ChannelClosed: {
2486                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2487                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2488                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
2489                         int64_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
2490                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_conv, reason_ref);
2491                 }
2492                 case LDKEvent_DiscardFunding: {
2493                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2494                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2495                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2496                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2497                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2498                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2499                 }
2500                 case LDKEvent_OpenChannelRequest: {
2501                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2502                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
2503                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2504                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
2505                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
2506                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
2507                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2508                         int64_t channel_type_ref = 0;
2509                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2510                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2511                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2512                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
2513                         return (*env)->NewObject(env, LDKEvent_OpenChannelRequest_class, LDKEvent_OpenChannelRequest_meth, temporary_channel_id_arr, counterparty_node_id_arr, funding_satoshis_conv, push_msat_conv, channel_type_ref);
2514                 }
2515                 default: abort();
2516         }
2517 }
2518 static jclass LDKCOption_EventZ_Some_class = NULL;
2519 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2520 static jclass LDKCOption_EventZ_None_class = NULL;
2521 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2523         LDKCOption_EventZ_Some_class =
2524                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2525         CHECK(LDKCOption_EventZ_Some_class != NULL);
2526         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2527         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2528         LDKCOption_EventZ_None_class =
2529                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2530         CHECK(LDKCOption_EventZ_None_class != NULL);
2531         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2532         CHECK(LDKCOption_EventZ_None_meth != NULL);
2533 }
2534 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2535         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2536         switch(obj->tag) {
2537                 case LDKCOption_EventZ_Some: {
2538                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2539                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2540                 }
2541                 case LDKCOption_EventZ_None: {
2542                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2543                 }
2544                 default: abort();
2545         }
2546 }
2547 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2548 CHECK(owner->result_ok);
2549         return COption_EventZ_clone(&*owner->contents.result);
2550 }
2551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2552         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2553         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2554         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2555         int64_t ret_ref = (uintptr_t)ret_copy;
2556         return ret_ref;
2557 }
2558
2559 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2560 CHECK(!owner->result_ok);
2561         return DecodeError_clone(&*owner->contents.err);
2562 }
2563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2564         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2565         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2566         int64_t ret_ref = 0;
2567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2570         ret_ref = (uintptr_t)ret_var.inner;
2571         if (ret_var.is_owned) {
2572                 ret_ref |= 1;
2573         }
2574         return ret_ref;
2575 }
2576
2577 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2578 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2579 static jclass LDKErrorAction_IgnoreError_class = NULL;
2580 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2581 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2582 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2583 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2584 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2585 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2586 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2587 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
2588 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
2589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2590         LDKErrorAction_DisconnectPeer_class =
2591                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2592         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2593         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2594         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2595         LDKErrorAction_IgnoreError_class =
2596                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2597         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2598         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2599         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2600         LDKErrorAction_IgnoreAndLog_class =
2601                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2602         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2603         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2604         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2605         LDKErrorAction_IgnoreDuplicateGossip_class =
2606                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2607         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2608         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2609         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2610         LDKErrorAction_SendErrorMessage_class =
2611                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2612         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2613         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2614         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2615         LDKErrorAction_SendWarningMessage_class =
2616                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
2617         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
2618         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
2619         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
2620 }
2621 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2622         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2623         switch(obj->tag) {
2624                 case LDKErrorAction_DisconnectPeer: {
2625                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2626                         int64_t msg_ref = 0;
2627                         if ((uintptr_t)msg_var.inner > 4096) {
2628                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2629                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2630                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2631                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2632                         }
2633                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2634                 }
2635                 case LDKErrorAction_IgnoreError: {
2636                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2637                 }
2638                 case LDKErrorAction_IgnoreAndLog: {
2639                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2640                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2641                 }
2642                 case LDKErrorAction_IgnoreDuplicateGossip: {
2643                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2644                 }
2645                 case LDKErrorAction_SendErrorMessage: {
2646                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2647                         int64_t msg_ref = 0;
2648                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2649                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2650                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2651                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2652                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2653                 }
2654                 case LDKErrorAction_SendWarningMessage: {
2655                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2656                         int64_t msg_ref = 0;
2657                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2658                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2659                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2660                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2661                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
2662                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
2663                 }
2664                 default: abort();
2665         }
2666 }
2667 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2668 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2669 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2670 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2671 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2672 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2673 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2674 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2675 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
2676 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
2677 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2678 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2679 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2680 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2681 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2682 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2683 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2684 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2685 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2686 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2687 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2688 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2689 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2690 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2691 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2692 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2693 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2694 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2695 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2696 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2697 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2698 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2699 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2700 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2701 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2702 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2703 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2704 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2705 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
2706 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
2707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2708         LDKMessageSendEvent_SendAcceptChannel_class =
2709                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2710         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2711         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2712         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2713         LDKMessageSendEvent_SendOpenChannel_class =
2714                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2715         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2716         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2717         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2718         LDKMessageSendEvent_SendFundingCreated_class =
2719                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2720         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2721         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2722         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2723         LDKMessageSendEvent_SendFundingSigned_class =
2724                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2725         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2726         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2727         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2728         LDKMessageSendEvent_SendChannelReady_class =
2729                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
2730         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
2731         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
2732         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
2733         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2734                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2735         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2736         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2737         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2738         LDKMessageSendEvent_UpdateHTLCs_class =
2739                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2740         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2741         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2742         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2743         LDKMessageSendEvent_SendRevokeAndACK_class =
2744                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2745         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2746         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2747         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2748         LDKMessageSendEvent_SendClosingSigned_class =
2749                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2750         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2751         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2752         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2753         LDKMessageSendEvent_SendShutdown_class =
2754                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2755         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2756         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2757         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2758         LDKMessageSendEvent_SendChannelReestablish_class =
2759                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2760         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2761         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2762         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2763         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2764                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2765         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2766         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2767         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2768         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2769                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2770         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2771         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2772         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2773         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2774                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2775         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2776         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2777         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2778         LDKMessageSendEvent_SendChannelUpdate_class =
2779                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2780         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2781         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2782         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2783         LDKMessageSendEvent_HandleError_class =
2784                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2785         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2786         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2787         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2788         LDKMessageSendEvent_SendChannelRangeQuery_class =
2789                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2790         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2791         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2792         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2793         LDKMessageSendEvent_SendShortIdsQuery_class =
2794                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2795         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2796         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2797         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2798         LDKMessageSendEvent_SendReplyChannelRange_class =
2799                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2800         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2801         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2802         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2803         LDKMessageSendEvent_SendGossipTimestampFilter_class =
2804                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
2805         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
2806         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
2807         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
2808 }
2809 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2810         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2811         switch(obj->tag) {
2812                 case LDKMessageSendEvent_SendAcceptChannel: {
2813                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2814                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2815                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2816                         int64_t msg_ref = 0;
2817                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2818                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2819                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2820                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2821                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2822                 }
2823                 case LDKMessageSendEvent_SendOpenChannel: {
2824                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2825                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2826                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2827                         int64_t msg_ref = 0;
2828                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2829                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2830                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2831                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2832                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2833                 }
2834                 case LDKMessageSendEvent_SendFundingCreated: {
2835                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2836                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2837                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2838                         int64_t msg_ref = 0;
2839                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2840                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2841                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2842                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2843                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2844                 }
2845                 case LDKMessageSendEvent_SendFundingSigned: {
2846                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2847                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2848                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2849                         int64_t msg_ref = 0;
2850                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2851                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2852                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2853                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2854                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2855                 }
2856                 case LDKMessageSendEvent_SendChannelReady: {
2857                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2858                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
2859                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
2860                         int64_t msg_ref = 0;
2861                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2862                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2863                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2864                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2865                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
2866                 }
2867                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2868                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2869                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2870                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2871                         int64_t msg_ref = 0;
2872                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2873                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2874                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2875                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2876                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2877                 }
2878                 case LDKMessageSendEvent_UpdateHTLCs: {
2879                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2880                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2881                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2882                         int64_t updates_ref = 0;
2883                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2884                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2885                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2886                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2887                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2888                 }
2889                 case LDKMessageSendEvent_SendRevokeAndACK: {
2890                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2891                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2892                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2893                         int64_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_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
2899                 }
2900                 case LDKMessageSendEvent_SendClosingSigned: {
2901                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2902                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
2903                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2904                         int64_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_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
2910                 }
2911                 case LDKMessageSendEvent_SendShutdown: {
2912                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2913                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
2914                         LDKShutdown msg_var = obj->send_shutdown.msg;
2915                         int64_t msg_ref = 0;
2916                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2917                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2918                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2919                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2920                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
2921                 }
2922                 case LDKMessageSendEvent_SendChannelReestablish: {
2923                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2924                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
2925                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2926                         int64_t msg_ref = 0;
2927                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2928                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2929                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2930                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2931                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
2932                 }
2933                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
2934                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2935                         int64_t msg_ref = 0;
2936                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2937                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2938                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2939                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2940                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2941                         int64_t update_msg_ref = 0;
2942                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2943                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2944                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2945                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2946                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
2947                 }
2948                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
2949                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2950                         int64_t msg_ref = 0;
2951                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2952                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2953                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2954                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2955                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
2956                 }
2957                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
2958                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2959                         int64_t msg_ref = 0;
2960                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2961                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2962                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2963                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2964                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
2965                 }
2966                 case LDKMessageSendEvent_SendChannelUpdate: {
2967                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2968                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
2969                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2970                         int64_t msg_ref = 0;
2971                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2972                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2973                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2974                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2975                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
2976                 }
2977                 case LDKMessageSendEvent_HandleError: {
2978                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2979                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
2980                         int64_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2981                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
2982                 }
2983                 case LDKMessageSendEvent_SendChannelRangeQuery: {
2984                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2985                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
2986                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2987                         int64_t msg_ref = 0;
2988                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2989                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2990                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2991                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2992                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
2993                 }
2994                 case LDKMessageSendEvent_SendShortIdsQuery: {
2995                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2996                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
2997                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2998                         int64_t msg_ref = 0;
2999                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3000                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3001                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3002                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3003                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3004                 }
3005                 case LDKMessageSendEvent_SendReplyChannelRange: {
3006                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3007                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3008                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3009                         int64_t msg_ref = 0;
3010                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3011                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3012                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3013                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3014                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3015                 }
3016                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3017                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3018                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3019                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3020                         int64_t msg_ref = 0;
3021                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3022                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3023                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3024                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3025                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3026                 }
3027                 default: abort();
3028         }
3029 }
3030 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3031         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3032         for (size_t i = 0; i < ret.datalen; i++) {
3033                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3034         }
3035         return ret;
3036 }
3037 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3038 CHECK(owner->result_ok);
3039         return TxOut_clone(&*owner->contents.result);
3040 }
3041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3042         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3043         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3044         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3045         return (int64_t)ret_ref;
3046 }
3047
3048 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3049 CHECK(!owner->result_ok);
3050         return AccessError_clone(&*owner->contents.err);
3051 }
3052 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3053         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3054         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
3055         return ret_conv;
3056 }
3057
3058 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3059         return owner->a;
3060 }
3061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3062         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
3063         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3064         return ret_conv;
3065 }
3066
3067 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3068         return owner->b;
3069 }
3070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3071         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
3072         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3073         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3074         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3075         return ret_arr;
3076 }
3077
3078 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3079         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3080         for (size_t i = 0; i < ret.datalen; i++) {
3081                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3082         }
3083         return ret;
3084 }
3085 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
3086         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
3087         for (size_t i = 0; i < ret.datalen; i++) {
3088                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3089         }
3090         return ret;
3091 }
3092 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3093 CHECK(owner->result_ok);
3094         return *owner->contents.result;
3095 }
3096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3097         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3098         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
3099 }
3100
3101 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3102 CHECK(!owner->result_ok);
3103         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
3104 }
3105 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3106         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3107         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
3108         return ret_conv;
3109 }
3110
3111 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
3112 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
3113 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
3114 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
3115 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
3116 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
3117 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
3118 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
3119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
3120         LDKMonitorEvent_HTLCEvent_class =
3121                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
3122         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
3123         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
3124         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
3125         LDKMonitorEvent_CommitmentTxConfirmed_class =
3126                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
3127         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
3128         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
3129         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
3130         LDKMonitorEvent_UpdateCompleted_class =
3131                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
3132         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
3133         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
3134         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
3135         LDKMonitorEvent_UpdateFailed_class =
3136                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
3137         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
3138         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
3139         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
3140 }
3141 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3142         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
3143         switch(obj->tag) {
3144                 case LDKMonitorEvent_HTLCEvent: {
3145                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3146                         int64_t htlc_event_ref = 0;
3147                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3148                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3149                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3150                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
3151                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
3152                 }
3153                 case LDKMonitorEvent_CommitmentTxConfirmed: {
3154                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
3155                         int64_t commitment_tx_confirmed_ref = 0;
3156                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3157                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3158                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
3159                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
3160                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
3161                 }
3162                 case LDKMonitorEvent_UpdateCompleted: {
3163                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
3164                         int64_t funding_txo_ref = 0;
3165                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3166                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3167                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3168                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
3169                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
3170                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, monitor_update_id_conv);
3171                 }
3172                 case LDKMonitorEvent_UpdateFailed: {
3173                         LDKOutPoint update_failed_var = obj->update_failed;
3174                         int64_t update_failed_ref = 0;
3175                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3176                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3177                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
3178                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
3179                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
3180                 }
3181                 default: abort();
3182         }
3183 }
3184 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3185         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3186         for (size_t i = 0; i < ret.datalen; i++) {
3187                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3188         }
3189         return ret;
3190 }
3191 static inline struct LDKOutPoint C2Tuple_OutPointCVec_MonitorEventZZ_get_a(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR owner){
3192         return OutPoint_clone(&owner->a);
3193 }
3194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3195         LDKC2Tuple_OutPointCVec_MonitorEventZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(owner & ~1);
3196         LDKOutPoint ret_var = C2Tuple_OutPointCVec_MonitorEventZZ_get_a(owner_conv);
3197         int64_t ret_ref = 0;
3198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3201         ret_ref = (uintptr_t)ret_var.inner;
3202         if (ret_var.is_owned) {
3203                 ret_ref |= 1;
3204         }
3205         return ret_ref;
3206 }
3207
3208 static inline struct LDKCVec_MonitorEventZ C2Tuple_OutPointCVec_MonitorEventZZ_get_b(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR owner){
3209         return CVec_MonitorEventZ_clone(&owner->b);
3210 }
3211 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3212         LDKC2Tuple_OutPointCVec_MonitorEventZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(owner & ~1);
3213         LDKCVec_MonitorEventZ ret_var = C2Tuple_OutPointCVec_MonitorEventZZ_get_b(owner_conv);
3214         int64_tArray ret_arr = NULL;
3215         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3216         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3217         for (size_t o = 0; o < ret_var.datalen; o++) {
3218                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3219                 *ret_conv_14_copy = ret_var.data[o];
3220                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
3221                 ret_arr_ptr[o] = ret_conv_14_ref;
3222         }
3223         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3224         FREE(ret_var.data);
3225         return ret_arr;
3226 }
3227
3228 static inline LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_clone(const LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ *orig) {
3229         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ) * orig->datalen, "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ clone bytes"), .datalen = orig->datalen };
3230         for (size_t i = 0; i < ret.datalen; i++) {
3231                 ret.data[i] = C2Tuple_OutPointCVec_MonitorEventZZ_clone(&orig->data[i]);
3232         }
3233         return ret;
3234 }
3235 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
3236 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
3237 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
3238 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
3239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
3240         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
3241                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
3242         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
3243         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
3244         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
3245         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
3246                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
3247         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
3248         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
3249         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
3250 }
3251 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3252         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
3253         switch(obj->tag) {
3254                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
3255                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
3256                         *some_conv = obj->some;
3257                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
3258                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((int64_t)some_conv));
3259                 }
3260                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
3261                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
3262                 }
3263                 default: abort();
3264         }
3265 }
3266 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3267 CHECK(owner->result_ok);
3268         return FixedPenaltyScorer_clone(&*owner->contents.result);
3269 }
3270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3271         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3272         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3273         int64_t ret_ref = 0;
3274         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3275         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3277         ret_ref = (uintptr_t)ret_var.inner;
3278         if (ret_var.is_owned) {
3279                 ret_ref |= 1;
3280         }
3281         return ret_ref;
3282 }
3283
3284 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3285 CHECK(!owner->result_ok);
3286         return DecodeError_clone(&*owner->contents.err);
3287 }
3288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3289         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3290         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3291         int64_t ret_ref = 0;
3292         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3293         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3295         ret_ref = (uintptr_t)ret_var.inner;
3296         if (ret_var.is_owned) {
3297                 ret_ref |= 1;
3298         }
3299         return ret_ref;
3300 }
3301
3302 typedef struct LDKLogger_JCalls {
3303         atomic_size_t refcnt;
3304         JavaVM *vm;
3305         jweak o;
3306         jmethodID log_meth;
3307 } LDKLogger_JCalls;
3308 static void LDKLogger_JCalls_free(void* this_arg) {
3309         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3310         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3311                 JNIEnv *env;
3312                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3313                 if (get_jenv_res == JNI_EDETACHED) {
3314                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3315                 } else {
3316                         DO_ASSERT(get_jenv_res == JNI_OK);
3317                 }
3318                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3319                 if (get_jenv_res == JNI_EDETACHED) {
3320                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3321                 }
3322                 FREE(j_calls);
3323         }
3324 }
3325 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
3326         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3327         JNIEnv *env;
3328         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3329         if (get_jenv_res == JNI_EDETACHED) {
3330                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3331         } else {
3332                 DO_ASSERT(get_jenv_res == JNI_OK);
3333         }
3334         LDKRecord record_var = *record;
3335         int64_t record_ref = 0;
3336         record_var = Record_clone(&record_var);
3337         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3338         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3339         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
3340         record_ref = (uintptr_t)record_var.inner;
3341         if (record_var.is_owned) {
3342                 record_ref |= 1;
3343         }
3344         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3345         CHECK(obj != NULL);
3346         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
3347         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3348                 (*env)->ExceptionDescribe(env);
3349                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
3350         }
3351         if (get_jenv_res == JNI_EDETACHED) {
3352                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3353         }
3354 }
3355 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3356         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3357         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3358 }
3359 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3360         jclass c = (*env)->GetObjectClass(env, o);
3361         CHECK(c != NULL);
3362         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3363         atomic_init(&calls->refcnt, 1);
3364         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3365         calls->o = (*env)->NewWeakGlobalRef(env, o);
3366         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
3367         CHECK(calls->log_meth != NULL);
3368
3369         LDKLogger ret = {
3370                 .this_arg = (void*) calls,
3371                 .log = log_LDKLogger_jcall,
3372                 .free = LDKLogger_JCalls_free,
3373         };
3374         return ret;
3375 }
3376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3377         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3378         *res_ptr = LDKLogger_init(env, clz, o);
3379         return (uint64_t)res_ptr;
3380 }
3381 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3382 CHECK(owner->result_ok);
3383         return &*owner->contents.result;
3384 }
3385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3386         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3387         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3388         int64_t ret_ref = 0;
3389         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3390         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3392         ret_ref = (uintptr_t)ret_var.inner & ~1;
3393         return ret_ref;
3394 }
3395
3396 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3397 CHECK(!owner->result_ok);
3398         return DecodeError_clone(&*owner->contents.err);
3399 }
3400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3401         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3402         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3403         int64_t ret_ref = 0;
3404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3407         ret_ref = (uintptr_t)ret_var.inner;
3408         if (ret_var.is_owned) {
3409                 ret_ref |= 1;
3410         }
3411         return ret_ref;
3412 }
3413
3414 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3415 CHECK(owner->result_ok);
3416         return InitFeatures_clone(&*owner->contents.result);
3417 }
3418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3419         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3420         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3421         int64_t ret_ref = 0;
3422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3425         ret_ref = (uintptr_t)ret_var.inner;
3426         if (ret_var.is_owned) {
3427                 ret_ref |= 1;
3428         }
3429         return ret_ref;
3430 }
3431
3432 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3433 CHECK(!owner->result_ok);
3434         return DecodeError_clone(&*owner->contents.err);
3435 }
3436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3437         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3438         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3439         int64_t ret_ref = 0;
3440         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3441         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3443         ret_ref = (uintptr_t)ret_var.inner;
3444         if (ret_var.is_owned) {
3445                 ret_ref |= 1;
3446         }
3447         return ret_ref;
3448 }
3449
3450 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3451 CHECK(owner->result_ok);
3452         return ChannelFeatures_clone(&*owner->contents.result);
3453 }
3454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3455         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3456         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3457         int64_t ret_ref = 0;
3458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3461         ret_ref = (uintptr_t)ret_var.inner;
3462         if (ret_var.is_owned) {
3463                 ret_ref |= 1;
3464         }
3465         return ret_ref;
3466 }
3467
3468 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3469 CHECK(!owner->result_ok);
3470         return DecodeError_clone(&*owner->contents.err);
3471 }
3472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3473         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3474         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3475         int64_t ret_ref = 0;
3476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3479         ret_ref = (uintptr_t)ret_var.inner;
3480         if (ret_var.is_owned) {
3481                 ret_ref |= 1;
3482         }
3483         return ret_ref;
3484 }
3485
3486 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3487 CHECK(owner->result_ok);
3488         return NodeFeatures_clone(&*owner->contents.result);
3489 }
3490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3491         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3492         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3493         int64_t ret_ref = 0;
3494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3497         ret_ref = (uintptr_t)ret_var.inner;
3498         if (ret_var.is_owned) {
3499                 ret_ref |= 1;
3500         }
3501         return ret_ref;
3502 }
3503
3504 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3505 CHECK(!owner->result_ok);
3506         return DecodeError_clone(&*owner->contents.err);
3507 }
3508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3509         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3510         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3511         int64_t ret_ref = 0;
3512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3515         ret_ref = (uintptr_t)ret_var.inner;
3516         if (ret_var.is_owned) {
3517                 ret_ref |= 1;
3518         }
3519         return ret_ref;
3520 }
3521
3522 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3523 CHECK(owner->result_ok);
3524         return InvoiceFeatures_clone(&*owner->contents.result);
3525 }
3526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3527         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3528         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3529         int64_t ret_ref = 0;
3530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3533         ret_ref = (uintptr_t)ret_var.inner;
3534         if (ret_var.is_owned) {
3535                 ret_ref |= 1;
3536         }
3537         return ret_ref;
3538 }
3539
3540 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3541 CHECK(!owner->result_ok);
3542         return DecodeError_clone(&*owner->contents.err);
3543 }
3544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3545         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3546         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3547         int64_t ret_ref = 0;
3548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3551         ret_ref = (uintptr_t)ret_var.inner;
3552         if (ret_var.is_owned) {
3553                 ret_ref |= 1;
3554         }
3555         return ret_ref;
3556 }
3557
3558 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3559 CHECK(owner->result_ok);
3560         return ChannelTypeFeatures_clone(&*owner->contents.result);
3561 }
3562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3563         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3564         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3565         int64_t ret_ref = 0;
3566         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3567         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3569         ret_ref = (uintptr_t)ret_var.inner;
3570         if (ret_var.is_owned) {
3571                 ret_ref |= 1;
3572         }
3573         return ret_ref;
3574 }
3575
3576 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3577 CHECK(!owner->result_ok);
3578         return DecodeError_clone(&*owner->contents.err);
3579 }
3580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3581         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3582         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3583         int64_t ret_ref = 0;
3584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3587         ret_ref = (uintptr_t)ret_var.inner;
3588         if (ret_var.is_owned) {
3589                 ret_ref |= 1;
3590         }
3591         return ret_ref;
3592 }
3593
3594 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3595 CHECK(owner->result_ok);
3596         return NodeId_clone(&*owner->contents.result);
3597 }
3598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3599         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3600         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3601         int64_t ret_ref = 0;
3602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3605         ret_ref = (uintptr_t)ret_var.inner;
3606         if (ret_var.is_owned) {
3607                 ret_ref |= 1;
3608         }
3609         return ret_ref;
3610 }
3611
3612 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3613 CHECK(!owner->result_ok);
3614         return DecodeError_clone(&*owner->contents.err);
3615 }
3616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3617         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3618         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3619         int64_t ret_ref = 0;
3620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3623         ret_ref = (uintptr_t)ret_var.inner;
3624         if (ret_var.is_owned) {
3625                 ret_ref |= 1;
3626         }
3627         return ret_ref;
3628 }
3629
3630 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3631 CHECK(owner->result_ok);
3632         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3633 }
3634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3635         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3636         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3637         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3638         int64_t ret_ref = (uintptr_t)ret_copy;
3639         return ret_ref;
3640 }
3641
3642 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3643 CHECK(!owner->result_ok);
3644         return DecodeError_clone(&*owner->contents.err);
3645 }
3646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3647         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3648         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3649         int64_t ret_ref = 0;
3650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3653         ret_ref = (uintptr_t)ret_var.inner;
3654         if (ret_var.is_owned) {
3655                 ret_ref |= 1;
3656         }
3657         return ret_ref;
3658 }
3659
3660 typedef struct LDKAccess_JCalls {
3661         atomic_size_t refcnt;
3662         JavaVM *vm;
3663         jweak o;
3664         jmethodID get_utxo_meth;
3665 } LDKAccess_JCalls;
3666 static void LDKAccess_JCalls_free(void* this_arg) {
3667         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3668         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3669                 JNIEnv *env;
3670                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3671                 if (get_jenv_res == JNI_EDETACHED) {
3672                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3673                 } else {
3674                         DO_ASSERT(get_jenv_res == JNI_OK);
3675                 }
3676                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3677                 if (get_jenv_res == JNI_EDETACHED) {
3678                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3679                 }
3680                 FREE(j_calls);
3681         }
3682 }
3683 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3684         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3685         JNIEnv *env;
3686         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3687         if (get_jenv_res == JNI_EDETACHED) {
3688                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3689         } else {
3690                 DO_ASSERT(get_jenv_res == JNI_OK);
3691         }
3692         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
3693         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
3694         int64_t short_channel_id_conv = short_channel_id;
3695         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3696         CHECK(obj != NULL);
3697         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
3698         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3699                 (*env)->ExceptionDescribe(env);
3700                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
3701         }
3702         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3703         CHECK_ACCESS(ret_ptr);
3704         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3705         FREE((void*)ret);
3706         if (get_jenv_res == JNI_EDETACHED) {
3707                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3708         }
3709         return ret_conv;
3710 }
3711 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3712         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3713         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3714 }
3715 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
3716         jclass c = (*env)->GetObjectClass(env, o);
3717         CHECK(c != NULL);
3718         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3719         atomic_init(&calls->refcnt, 1);
3720         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3721         calls->o = (*env)->NewWeakGlobalRef(env, o);
3722         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
3723         CHECK(calls->get_utxo_meth != NULL);
3724
3725         LDKAccess ret = {
3726                 .this_arg = (void*) calls,
3727                 .get_utxo = get_utxo_LDKAccess_jcall,
3728                 .free = LDKAccess_JCalls_free,
3729         };
3730         return ret;
3731 }
3732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
3733         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3734         *res_ptr = LDKAccess_init(env, clz, o);
3735         return (uint64_t)res_ptr;
3736 }
3737 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) {
3738         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3739         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3740         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3741         unsigned char genesis_hash_arr[32];
3742         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
3743         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
3744         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3745         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3746         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3747         return (int64_t)ret_conv;
3748 }
3749
3750 static jclass LDKCOption_AccessZ_Some_class = NULL;
3751 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
3752 static jclass LDKCOption_AccessZ_None_class = NULL;
3753 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
3754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
3755         LDKCOption_AccessZ_Some_class =
3756                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
3757         CHECK(LDKCOption_AccessZ_Some_class != NULL);
3758         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
3759         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
3760         LDKCOption_AccessZ_None_class =
3761                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
3762         CHECK(LDKCOption_AccessZ_None_class != NULL);
3763         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
3764         CHECK(LDKCOption_AccessZ_None_meth != NULL);
3765 }
3766 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3767         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3768         switch(obj->tag) {
3769                 case LDKCOption_AccessZ_Some: {
3770                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3771                         *some_ret = obj->some;
3772                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
3773                         if ((*some_ret).free == LDKAccess_JCalls_free) {
3774                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
3775                                 LDKAccess_JCalls_cloned(&(*some_ret));
3776                         }
3777                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (int64_t)some_ret);
3778                 }
3779                 case LDKCOption_AccessZ_None: {
3780                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
3781                 }
3782                 default: abort();
3783         }
3784 }
3785 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3786 CHECK(owner->result_ok);
3787         return *owner->contents.result;
3788 }
3789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3790         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3791         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
3792         return ret_conv;
3793 }
3794
3795 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3796 CHECK(!owner->result_ok);
3797         return LightningError_clone(&*owner->contents.err);
3798 }
3799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3800         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3801         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3802         int64_t ret_ref = 0;
3803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3806         ret_ref = (uintptr_t)ret_var.inner;
3807         if (ret_var.is_owned) {
3808                 ret_ref |= 1;
3809         }
3810         return ret_ref;
3811 }
3812
3813 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3814         return ChannelAnnouncement_clone(&owner->a);
3815 }
3816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3817         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3818         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3819         int64_t ret_ref = 0;
3820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3823         ret_ref = (uintptr_t)ret_var.inner;
3824         if (ret_var.is_owned) {
3825                 ret_ref |= 1;
3826         }
3827         return ret_ref;
3828 }
3829
3830 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3831         return ChannelUpdate_clone(&owner->b);
3832 }
3833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3834         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3835         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3836         int64_t ret_ref = 0;
3837         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3838         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3840         ret_ref = (uintptr_t)ret_var.inner;
3841         if (ret_var.is_owned) {
3842                 ret_ref |= 1;
3843         }
3844         return ret_ref;
3845 }
3846
3847 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3848         return ChannelUpdate_clone(&owner->c);
3849 }
3850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
3851         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3852         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3853         int64_t ret_ref = 0;
3854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3857         ret_ref = (uintptr_t)ret_var.inner;
3858         if (ret_var.is_owned) {
3859                 ret_ref |= 1;
3860         }
3861         return ret_ref;
3862 }
3863
3864 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3865         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3866         for (size_t i = 0; i < ret.datalen; i++) {
3867                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3868         }
3869         return ret;
3870 }
3871 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3872         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3873         for (size_t i = 0; i < ret.datalen; i++) {
3874                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3875         }
3876         return ret;
3877 }
3878 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3879 CHECK(owner->result_ok);
3880         return *owner->contents.result;
3881 }
3882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3883         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3884         CResult_NoneLightningErrorZ_get_ok(owner_conv);
3885 }
3886
3887 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3888 CHECK(!owner->result_ok);
3889         return LightningError_clone(&*owner->contents.err);
3890 }
3891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3892         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3893         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
3894         int64_t ret_ref = 0;
3895         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3896         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3898         ret_ref = (uintptr_t)ret_var.inner;
3899         if (ret_var.is_owned) {
3900                 ret_ref |= 1;
3901         }
3902         return ret_ref;
3903 }
3904
3905 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3906 CHECK(owner->result_ok);
3907         return ChannelUpdateInfo_clone(&*owner->contents.result);
3908 }
3909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3910         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3911         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
3912         int64_t ret_ref = 0;
3913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3916         ret_ref = (uintptr_t)ret_var.inner;
3917         if (ret_var.is_owned) {
3918                 ret_ref |= 1;
3919         }
3920         return ret_ref;
3921 }
3922
3923 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3924 CHECK(!owner->result_ok);
3925         return DecodeError_clone(&*owner->contents.err);
3926 }
3927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3928         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3929         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
3930         int64_t ret_ref = 0;
3931         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3932         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3934         ret_ref = (uintptr_t)ret_var.inner;
3935         if (ret_var.is_owned) {
3936                 ret_ref |= 1;
3937         }
3938         return ret_ref;
3939 }
3940
3941 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3942 CHECK(owner->result_ok);
3943         return ChannelInfo_clone(&*owner->contents.result);
3944 }
3945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3946         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3947         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
3948         int64_t ret_ref = 0;
3949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3952         ret_ref = (uintptr_t)ret_var.inner;
3953         if (ret_var.is_owned) {
3954                 ret_ref |= 1;
3955         }
3956         return ret_ref;
3957 }
3958
3959 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3960 CHECK(!owner->result_ok);
3961         return DecodeError_clone(&*owner->contents.err);
3962 }
3963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3964         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3965         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
3966         int64_t ret_ref = 0;
3967         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3968         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3970         ret_ref = (uintptr_t)ret_var.inner;
3971         if (ret_var.is_owned) {
3972                 ret_ref |= 1;
3973         }
3974         return ret_ref;
3975 }
3976
3977 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3978 CHECK(owner->result_ok);
3979         return RoutingFees_clone(&*owner->contents.result);
3980 }
3981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3982         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3983         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
3984         int64_t ret_ref = 0;
3985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3988         ret_ref = (uintptr_t)ret_var.inner;
3989         if (ret_var.is_owned) {
3990                 ret_ref |= 1;
3991         }
3992         return ret_ref;
3993 }
3994
3995 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3996 CHECK(!owner->result_ok);
3997         return DecodeError_clone(&*owner->contents.err);
3998 }
3999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4000         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
4001         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
4002         int64_t ret_ref = 0;
4003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4006         ret_ref = (uintptr_t)ret_var.inner;
4007         if (ret_var.is_owned) {
4008                 ret_ref |= 1;
4009         }
4010         return ret_ref;
4011 }
4012
4013 static jclass LDKNetAddress_IPv4_class = NULL;
4014 static jmethodID LDKNetAddress_IPv4_meth = NULL;
4015 static jclass LDKNetAddress_IPv6_class = NULL;
4016 static jmethodID LDKNetAddress_IPv6_meth = NULL;
4017 static jclass LDKNetAddress_OnionV2_class = NULL;
4018 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
4019 static jclass LDKNetAddress_OnionV3_class = NULL;
4020 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
4021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
4022         LDKNetAddress_IPv4_class =
4023                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
4024         CHECK(LDKNetAddress_IPv4_class != NULL);
4025         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
4026         CHECK(LDKNetAddress_IPv4_meth != NULL);
4027         LDKNetAddress_IPv6_class =
4028                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
4029         CHECK(LDKNetAddress_IPv6_class != NULL);
4030         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
4031         CHECK(LDKNetAddress_IPv6_meth != NULL);
4032         LDKNetAddress_OnionV2_class =
4033                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
4034         CHECK(LDKNetAddress_OnionV2_class != NULL);
4035         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
4036         CHECK(LDKNetAddress_OnionV2_meth != NULL);
4037         LDKNetAddress_OnionV3_class =
4038                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
4039         CHECK(LDKNetAddress_OnionV3_class != NULL);
4040         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
4041         CHECK(LDKNetAddress_OnionV3_meth != NULL);
4042 }
4043 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4044         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4045         switch(obj->tag) {
4046                 case LDKNetAddress_IPv4: {
4047                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
4048                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
4049                         int16_t port_conv = obj->i_pv4.port;
4050                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
4051                 }
4052                 case LDKNetAddress_IPv6: {
4053                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
4054                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
4055                         int16_t port_conv = obj->i_pv6.port;
4056                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
4057                 }
4058                 case LDKNetAddress_OnionV2: {
4059                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
4060                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
4061                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
4062                 }
4063                 case LDKNetAddress_OnionV3: {
4064                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
4065                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
4066                         int16_t checksum_conv = obj->onion_v3.checksum;
4067                         int8_t version_conv = obj->onion_v3.version;
4068                         int16_t port_conv = obj->onion_v3.port;
4069                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
4070                 }
4071                 default: abort();
4072         }
4073 }
4074 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4075         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4076         for (size_t i = 0; i < ret.datalen; i++) {
4077                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4078         }
4079         return ret;
4080 }
4081 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4082 CHECK(owner->result_ok);
4083         return NodeAnnouncementInfo_clone(&*owner->contents.result);
4084 }
4085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4086         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
4087         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
4088         int64_t ret_ref = 0;
4089         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4090         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4092         ret_ref = (uintptr_t)ret_var.inner;
4093         if (ret_var.is_owned) {
4094                 ret_ref |= 1;
4095         }
4096         return ret_ref;
4097 }
4098
4099 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4100 CHECK(!owner->result_ok);
4101         return DecodeError_clone(&*owner->contents.err);
4102 }
4103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4104         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
4105         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
4106         int64_t ret_ref = 0;
4107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4110         ret_ref = (uintptr_t)ret_var.inner;
4111         if (ret_var.is_owned) {
4112                 ret_ref |= 1;
4113         }
4114         return ret_ref;
4115 }
4116
4117 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
4118         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
4119         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
4120         return ret;
4121 }
4122 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4123 CHECK(owner->result_ok);
4124         return NodeInfo_clone(&*owner->contents.result);
4125 }
4126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4127         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
4128         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4129         int64_t ret_ref = 0;
4130         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4131         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4133         ret_ref = (uintptr_t)ret_var.inner;
4134         if (ret_var.is_owned) {
4135                 ret_ref |= 1;
4136         }
4137         return ret_ref;
4138 }
4139
4140 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4141 CHECK(!owner->result_ok);
4142         return DecodeError_clone(&*owner->contents.err);
4143 }
4144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4145         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
4146         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
4147         int64_t ret_ref = 0;
4148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4151         ret_ref = (uintptr_t)ret_var.inner;
4152         if (ret_var.is_owned) {
4153                 ret_ref |= 1;
4154         }
4155         return ret_ref;
4156 }
4157
4158 static inline struct LDKNetworkGraph *CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4159 CHECK(owner->result_ok);
4160         return &*owner->contents.result;
4161 }
4162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4163         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
4164         LDKNetworkGraph ret_var = *CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
4165         int64_t ret_ref = 0;
4166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4169         ret_ref = (uintptr_t)ret_var.inner & ~1;
4170         return ret_ref;
4171 }
4172
4173 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4174 CHECK(!owner->result_ok);
4175         return DecodeError_clone(&*owner->contents.err);
4176 }
4177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4178         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
4179         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
4180         int64_t ret_ref = 0;
4181         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4182         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4184         ret_ref = (uintptr_t)ret_var.inner;
4185         if (ret_var.is_owned) {
4186                 ret_ref |= 1;
4187         }
4188         return ret_ref;
4189 }
4190
4191 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
4192 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
4193 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
4194 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
4195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
4196         LDKCOption_CVec_NetAddressZZ_Some_class =
4197                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
4198         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
4199         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
4200         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
4201         LDKCOption_CVec_NetAddressZZ_None_class =
4202                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
4203         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
4204         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
4205         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
4206 }
4207 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4208         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
4209         switch(obj->tag) {
4210                 case LDKCOption_CVec_NetAddressZZ_Some: {
4211                         LDKCVec_NetAddressZ some_var = obj->some;
4212                         int64_tArray some_arr = NULL;
4213                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
4214                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
4215                         for (size_t m = 0; m < some_var.datalen; m++) {
4216                                 int64_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
4217                                 some_arr_ptr[m] = some_conv_12_ref;
4218                         }
4219                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
4220                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
4221                 }
4222                 case LDKCOption_CVec_NetAddressZZ_None: {
4223                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
4224                 }
4225                 default: abort();
4226         }
4227 }
4228 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4229 CHECK(owner->result_ok);
4230         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
4231 }
4232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4233         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4234         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4235         int64_t ret_ref = 0;
4236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4239         ret_ref = (uintptr_t)ret_var.inner;
4240         if (ret_var.is_owned) {
4241                 ret_ref |= 1;
4242         }
4243         return ret_ref;
4244 }
4245
4246 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4247 CHECK(!owner->result_ok);
4248         return DecodeError_clone(&*owner->contents.err);
4249 }
4250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4251         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4252         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4253         int64_t ret_ref = 0;
4254         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4255         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4257         ret_ref = (uintptr_t)ret_var.inner;
4258         if (ret_var.is_owned) {
4259                 ret_ref |= 1;
4260         }
4261         return ret_ref;
4262 }
4263
4264 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4265 CHECK(owner->result_ok);
4266         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
4267 }
4268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4269         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4270         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4271         int64_t ret_ref = 0;
4272         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4273         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4275         ret_ref = (uintptr_t)ret_var.inner;
4276         if (ret_var.is_owned) {
4277                 ret_ref |= 1;
4278         }
4279         return ret_ref;
4280 }
4281
4282 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4283 CHECK(!owner->result_ok);
4284         return DecodeError_clone(&*owner->contents.err);
4285 }
4286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4287         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4288         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4289         int64_t ret_ref = 0;
4290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4293         ret_ref = (uintptr_t)ret_var.inner;
4294         if (ret_var.is_owned) {
4295                 ret_ref |= 1;
4296         }
4297         return ret_ref;
4298 }
4299
4300 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4301 CHECK(owner->result_ok);
4302         return SpendableOutputDescriptor_clone(&*owner->contents.result);
4303 }
4304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4305         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
4306         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
4307         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4308         int64_t ret_ref = (uintptr_t)ret_copy;
4309         return ret_ref;
4310 }
4311
4312 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4313 CHECK(!owner->result_ok);
4314         return DecodeError_clone(&*owner->contents.err);
4315 }
4316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4317         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
4318         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4319         int64_t ret_ref = 0;
4320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4323         ret_ref = (uintptr_t)ret_var.inner;
4324         if (ret_var.is_owned) {
4325                 ret_ref |= 1;
4326         }
4327         return ret_ref;
4328 }
4329
4330 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
4331         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
4332         for (size_t i = 0; i < ret.datalen; i++) {
4333                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4334         }
4335         return ret;
4336 }
4337 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4338         return owner->a;
4339 }
4340 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4341         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
4342         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4343         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
4344         return ret_arr;
4345 }
4346
4347 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4348         return owner->b;
4349 }
4350 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4351         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
4352         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
4353         jobjectArray ret_arr = NULL;
4354         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4355         ;
4356         for (size_t i = 0; i < ret_var.datalen; i++) {
4357                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
4358                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
4359                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4360         }
4361         
4362         return ret_arr;
4363 }
4364
4365 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4366 CHECK(owner->result_ok);
4367         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
4368 }
4369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4370         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
4371         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4372         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
4373         return ((int64_t)ret_conv);
4374 }
4375
4376 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4377 CHECK(!owner->result_ok);
4378         return *owner->contents.err;
4379 }
4380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4381         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
4382         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
4383 }
4384
4385 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4386 CHECK(owner->result_ok);
4387         return *owner->contents.result;
4388 }
4389 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4390         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
4391         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4392         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
4393         return ret_arr;
4394 }
4395
4396 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4397 CHECK(!owner->result_ok);
4398         return *owner->contents.err;
4399 }
4400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4401         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
4402         CResult_SignatureNoneZ_get_err(owner_conv);
4403 }
4404
4405 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4406         return owner->a;
4407 }
4408 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4409         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
4410         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4411         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
4412         return ret_arr;
4413 }
4414
4415 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4416         return owner->b;
4417 }
4418 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4419         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
4420         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4421         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
4422         return ret_arr;
4423 }
4424
4425 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4426 CHECK(owner->result_ok);
4427         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
4428 }
4429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4430         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
4431         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
4432         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
4433         return ((int64_t)ret_conv);
4434 }
4435
4436 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4437 CHECK(!owner->result_ok);
4438         return *owner->contents.err;
4439 }
4440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4441         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
4442         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
4443 }
4444
4445 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4446 CHECK(owner->result_ok);
4447         return *owner->contents.result;
4448 }
4449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4450         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
4451         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4452         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
4453         return ret_arr;
4454 }
4455
4456 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4457 CHECK(!owner->result_ok);
4458         return *owner->contents.err;
4459 }
4460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4461         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
4462         CResult_SecretKeyNoneZ_get_err(owner_conv);
4463 }
4464
4465 typedef struct LDKBaseSign_JCalls {
4466         atomic_size_t refcnt;
4467         JavaVM *vm;
4468         jweak o;
4469         jmethodID get_per_commitment_point_meth;
4470         jmethodID release_commitment_secret_meth;
4471         jmethodID validate_holder_commitment_meth;
4472         jmethodID channel_keys_id_meth;
4473         jmethodID sign_counterparty_commitment_meth;
4474         jmethodID validate_counterparty_revocation_meth;
4475         jmethodID sign_holder_commitment_and_htlcs_meth;
4476         jmethodID sign_justice_revoked_output_meth;
4477         jmethodID sign_justice_revoked_htlc_meth;
4478         jmethodID sign_counterparty_htlc_transaction_meth;
4479         jmethodID sign_closing_transaction_meth;
4480         jmethodID sign_channel_announcement_meth;
4481         jmethodID ready_channel_meth;
4482 } LDKBaseSign_JCalls;
4483 static void LDKBaseSign_JCalls_free(void* this_arg) {
4484         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4485         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4486                 JNIEnv *env;
4487                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4488                 if (get_jenv_res == JNI_EDETACHED) {
4489                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4490                 } else {
4491                         DO_ASSERT(get_jenv_res == JNI_OK);
4492                 }
4493                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4494                 if (get_jenv_res == JNI_EDETACHED) {
4495                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4496                 }
4497                 FREE(j_calls);
4498         }
4499 }
4500 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4501         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4502         JNIEnv *env;
4503         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4504         if (get_jenv_res == JNI_EDETACHED) {
4505                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4506         } else {
4507                 DO_ASSERT(get_jenv_res == JNI_OK);
4508         }
4509         int64_t idx_conv = idx;
4510         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4511         CHECK(obj != NULL);
4512         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
4513         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4514                 (*env)->ExceptionDescribe(env);
4515                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
4516         }
4517         LDKPublicKey ret_ref;
4518         CHECK((*env)->GetArrayLength(env, ret) == 33);
4519         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
4520         if (get_jenv_res == JNI_EDETACHED) {
4521                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4522         }
4523         return ret_ref;
4524 }
4525 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4526         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4527         JNIEnv *env;
4528         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4529         if (get_jenv_res == JNI_EDETACHED) {
4530                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4531         } else {
4532                 DO_ASSERT(get_jenv_res == JNI_OK);
4533         }
4534         int64_t idx_conv = idx;
4535         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4536         CHECK(obj != NULL);
4537         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
4538         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4539                 (*env)->ExceptionDescribe(env);
4540                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
4541         }
4542         LDKThirtyTwoBytes ret_ref;
4543         CHECK((*env)->GetArrayLength(env, ret) == 32);
4544         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4545         if (get_jenv_res == JNI_EDETACHED) {
4546                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4547         }
4548         return ret_ref;
4549 }
4550 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
4551         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4552         JNIEnv *env;
4553         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4554         if (get_jenv_res == JNI_EDETACHED) {
4555                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4556         } else {
4557                 DO_ASSERT(get_jenv_res == JNI_OK);
4558         }
4559         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
4560         int64_t holder_tx_ref = 0;
4561         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
4562         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4563         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4564         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
4565         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
4566         if (holder_tx_var.is_owned) {
4567                 holder_tx_ref |= 1;
4568         }
4569         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4570         jobjectArray preimages_arr = NULL;
4571         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4572         ;
4573         for (size_t i = 0; i < preimages_var.datalen; i++) {
4574                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4575                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4576                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4577         }
4578         
4579         FREE(preimages_var.data);
4580         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4581         CHECK(obj != NULL);
4582         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
4583         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4584                 (*env)->ExceptionDescribe(env);
4585                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
4586         }
4587         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4588         CHECK_ACCESS(ret_ptr);
4589         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4590         FREE((void*)ret);
4591         if (get_jenv_res == JNI_EDETACHED) {
4592                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4593         }
4594         return ret_conv;
4595 }
4596 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
4597         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4598         JNIEnv *env;
4599         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4600         if (get_jenv_res == JNI_EDETACHED) {
4601                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4602         } else {
4603                 DO_ASSERT(get_jenv_res == JNI_OK);
4604         }
4605         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4606         CHECK(obj != NULL);
4607         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
4608         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4609                 (*env)->ExceptionDescribe(env);
4610                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
4611         }
4612         LDKThirtyTwoBytes ret_ref;
4613         CHECK((*env)->GetArrayLength(env, ret) == 32);
4614         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4615         if (get_jenv_res == JNI_EDETACHED) {
4616                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4617         }
4618         return ret_ref;
4619 }
4620 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
4621         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4622         JNIEnv *env;
4623         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4624         if (get_jenv_res == JNI_EDETACHED) {
4625                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4626         } else {
4627                 DO_ASSERT(get_jenv_res == JNI_OK);
4628         }
4629         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
4630         int64_t commitment_tx_ref = 0;
4631         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
4632         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4633         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4634         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4635         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4636         if (commitment_tx_var.is_owned) {
4637                 commitment_tx_ref |= 1;
4638         }
4639         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4640         jobjectArray preimages_arr = NULL;
4641         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4642         ;
4643         for (size_t i = 0; i < preimages_var.datalen; i++) {
4644                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4645                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4646                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4647         }
4648         
4649         FREE(preimages_var.data);
4650         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4651         CHECK(obj != NULL);
4652         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
4653         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4654                 (*env)->ExceptionDescribe(env);
4655                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
4656         }
4657         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4658         CHECK_ACCESS(ret_ptr);
4659         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4660         FREE((void*)ret);
4661         if (get_jenv_res == JNI_EDETACHED) {
4662                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4663         }
4664         return ret_conv;
4665 }
4666 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
4667         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4668         JNIEnv *env;
4669         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4670         if (get_jenv_res == JNI_EDETACHED) {
4671                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4672         } else {
4673                 DO_ASSERT(get_jenv_res == JNI_OK);
4674         }
4675         int64_t idx_conv = idx;
4676         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
4677         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
4678         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4679         CHECK(obj != NULL);
4680         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
4681         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4682                 (*env)->ExceptionDescribe(env);
4683                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
4684         }
4685         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4686         CHECK_ACCESS(ret_ptr);
4687         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4688         FREE((void*)ret);
4689         if (get_jenv_res == JNI_EDETACHED) {
4690                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4691         }
4692         return ret_conv;
4693 }
4694 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
4695         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4696         JNIEnv *env;
4697         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4698         if (get_jenv_res == JNI_EDETACHED) {
4699                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4700         } else {
4701                 DO_ASSERT(get_jenv_res == JNI_OK);
4702         }
4703         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
4704         int64_t commitment_tx_ref = 0;
4705         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
4706         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4707         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4708         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4709         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4710         if (commitment_tx_var.is_owned) {
4711                 commitment_tx_ref |= 1;
4712         }
4713         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4714         CHECK(obj != NULL);
4715         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
4716         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4717                 (*env)->ExceptionDescribe(env);
4718                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
4719         }
4720         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4721         CHECK_ACCESS(ret_ptr);
4722         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4723         FREE((void*)ret);
4724         if (get_jenv_res == JNI_EDETACHED) {
4725                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4726         }
4727         return ret_conv;
4728 }
4729 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]) {
4730         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4731         JNIEnv *env;
4732         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4733         if (get_jenv_res == JNI_EDETACHED) {
4734                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4735         } else {
4736                 DO_ASSERT(get_jenv_res == JNI_OK);
4737         }
4738         LDKTransaction justice_tx_var = justice_tx;
4739         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
4740         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
4741         Transaction_free(justice_tx_var);
4742         int64_t input_conv = input;
4743         int64_t amount_conv = amount;
4744         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
4745         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
4746         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4747         CHECK(obj != NULL);
4748         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input_conv, amount_conv, per_commitment_key_arr);
4749         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4750                 (*env)->ExceptionDescribe(env);
4751                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
4752         }
4753         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4754         CHECK_ACCESS(ret_ptr);
4755         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4756         FREE((void*)ret);
4757         if (get_jenv_res == JNI_EDETACHED) {
4758                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4759         }
4760         return ret_conv;
4761 }
4762 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) {
4763         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4764         JNIEnv *env;
4765         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4766         if (get_jenv_res == JNI_EDETACHED) {
4767                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4768         } else {
4769                 DO_ASSERT(get_jenv_res == JNI_OK);
4770         }
4771         LDKTransaction justice_tx_var = justice_tx;
4772         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
4773         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
4774         Transaction_free(justice_tx_var);
4775         int64_t input_conv = input;
4776         int64_t amount_conv = amount;
4777         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
4778         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
4779         LDKHTLCOutputInCommitment htlc_var = *htlc;
4780         int64_t htlc_ref = 0;
4781         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4782         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4783         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4784         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4785         htlc_ref = (uintptr_t)htlc_var.inner;
4786         if (htlc_var.is_owned) {
4787                 htlc_ref |= 1;
4788         }
4789         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4790         CHECK(obj != NULL);
4791         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input_conv, amount_conv, per_commitment_key_arr, htlc_ref);
4792         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4793                 (*env)->ExceptionDescribe(env);
4794                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
4795         }
4796         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4797         CHECK_ACCESS(ret_ptr);
4798         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4799         FREE((void*)ret);
4800         if (get_jenv_res == JNI_EDETACHED) {
4801                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4802         }
4803         return ret_conv;
4804 }
4805 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) {
4806         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4807         JNIEnv *env;
4808         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4809         if (get_jenv_res == JNI_EDETACHED) {
4810                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4811         } else {
4812                 DO_ASSERT(get_jenv_res == JNI_OK);
4813         }
4814         LDKTransaction htlc_tx_var = htlc_tx;
4815         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
4816         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
4817         Transaction_free(htlc_tx_var);
4818         int64_t input_conv = input;
4819         int64_t amount_conv = amount;
4820         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
4821         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
4822         LDKHTLCOutputInCommitment htlc_var = *htlc;
4823         int64_t htlc_ref = 0;
4824         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4825         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4826         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4827         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4828         htlc_ref = (uintptr_t)htlc_var.inner;
4829         if (htlc_var.is_owned) {
4830                 htlc_ref |= 1;
4831         }
4832         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4833         CHECK(obj != NULL);
4834         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input_conv, amount_conv, per_commitment_point_arr, htlc_ref);
4835         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4836                 (*env)->ExceptionDescribe(env);
4837                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
4838         }
4839         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4840         CHECK_ACCESS(ret_ptr);
4841         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4842         FREE((void*)ret);
4843         if (get_jenv_res == JNI_EDETACHED) {
4844                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4845         }
4846         return ret_conv;
4847 }
4848 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
4849         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4850         JNIEnv *env;
4851         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4852         if (get_jenv_res == JNI_EDETACHED) {
4853                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4854         } else {
4855                 DO_ASSERT(get_jenv_res == JNI_OK);
4856         }
4857         LDKClosingTransaction closing_tx_var = *closing_tx;
4858         int64_t closing_tx_ref = 0;
4859         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
4860         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4861         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4862         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
4863         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
4864         if (closing_tx_var.is_owned) {
4865                 closing_tx_ref |= 1;
4866         }
4867         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4868         CHECK(obj != NULL);
4869         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
4870         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4871                 (*env)->ExceptionDescribe(env);
4872                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
4873         }
4874         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4875         CHECK_ACCESS(ret_ptr);
4876         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4877         FREE((void*)ret);
4878         if (get_jenv_res == JNI_EDETACHED) {
4879                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4880         }
4881         return ret_conv;
4882 }
4883 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
4884         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4885         JNIEnv *env;
4886         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4887         if (get_jenv_res == JNI_EDETACHED) {
4888                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4889         } else {
4890                 DO_ASSERT(get_jenv_res == JNI_OK);
4891         }
4892         LDKUnsignedChannelAnnouncement msg_var = *msg;
4893         int64_t msg_ref = 0;
4894         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
4895         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4896         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4897         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4898         msg_ref = (uintptr_t)msg_var.inner;
4899         if (msg_var.is_owned) {
4900                 msg_ref |= 1;
4901         }
4902         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4903         CHECK(obj != NULL);
4904         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
4905         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4906                 (*env)->ExceptionDescribe(env);
4907                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
4908         }
4909         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4910         CHECK_ACCESS(ret_ptr);
4911         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
4912         FREE((void*)ret);
4913         if (get_jenv_res == JNI_EDETACHED) {
4914                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4915         }
4916         return ret_conv;
4917 }
4918 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
4919         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4920         JNIEnv *env;
4921         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4922         if (get_jenv_res == JNI_EDETACHED) {
4923                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4924         } else {
4925                 DO_ASSERT(get_jenv_res == JNI_OK);
4926         }
4927         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
4928         int64_t channel_parameters_ref = 0;
4929         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
4930         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4931         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4932         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
4933         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
4934         if (channel_parameters_var.is_owned) {
4935                 channel_parameters_ref |= 1;
4936         }
4937         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4938         CHECK(obj != NULL);
4939         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
4940         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4941                 (*env)->ExceptionDescribe(env);
4942                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
4943         }
4944         if (get_jenv_res == JNI_EDETACHED) {
4945                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4946         }
4947 }
4948 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
4949         jclass c = (*env)->GetObjectClass(env, o);
4950         CHECK(c != NULL);
4951         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
4952         atomic_init(&calls->refcnt, 1);
4953         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4954         calls->o = (*env)->NewWeakGlobalRef(env, o);
4955         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
4956         CHECK(calls->get_per_commitment_point_meth != NULL);
4957         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
4958         CHECK(calls->release_commitment_secret_meth != NULL);
4959         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
4960         CHECK(calls->validate_holder_commitment_meth != NULL);
4961         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
4962         CHECK(calls->channel_keys_id_meth != NULL);
4963         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
4964         CHECK(calls->sign_counterparty_commitment_meth != NULL);
4965         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
4966         CHECK(calls->validate_counterparty_revocation_meth != NULL);
4967         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
4968         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
4969         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
4970         CHECK(calls->sign_justice_revoked_output_meth != NULL);
4971         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
4972         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
4973         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
4974         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
4975         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
4976         CHECK(calls->sign_closing_transaction_meth != NULL);
4977         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
4978         CHECK(calls->sign_channel_announcement_meth != NULL);
4979         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
4980         CHECK(calls->ready_channel_meth != NULL);
4981
4982         LDKChannelPublicKeys pubkeys_conv;
4983         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4984         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4985         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4986
4987         LDKBaseSign ret = {
4988                 .this_arg = (void*) calls,
4989                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
4990                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
4991                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
4992                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
4993                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
4994                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
4995                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
4996                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
4997                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
4998                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
4999                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
5000                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
5001                 .ready_channel = ready_channel_LDKBaseSign_jcall,
5002                 .free = LDKBaseSign_JCalls_free,
5003                 .pubkeys = pubkeys_conv,
5004                 .set_pubkeys = NULL,
5005         };
5006         return ret;
5007 }
5008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5009         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
5010         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
5011         return (uint64_t)res_ptr;
5012 }
5013 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) {
5014         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5015         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5016         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5017         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5018         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
5019         return ret_arr;
5020 }
5021
5022 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5023         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5024         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5025         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5026         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5027         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
5028         return ret_arr;
5029 }
5030
5031 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, jobjectArray preimages) {
5032         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5033         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5034         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5035         LDKHolderCommitmentTransaction holder_tx_conv;
5036         holder_tx_conv.inner = (void*)(holder_tx & (~1));
5037         holder_tx_conv.is_owned = false;
5038         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
5039         LDKCVec_PaymentPreimageZ preimages_constr;
5040         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5041         if (preimages_constr.datalen > 0)
5042                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5043         else
5044                 preimages_constr.data = NULL;
5045         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5046                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5047                 LDKThirtyTwoBytes preimages_conv_8_ref;
5048                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5049                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5050                 preimages_constr.data[i] = preimages_conv_8_ref;
5051         }
5052         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5053         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
5054         return (int64_t)ret_conv;
5055 }
5056
5057 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5058         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5059         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5060         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5061         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5062         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
5063         return ret_arr;
5064 }
5065
5066 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, jobjectArray preimages) {
5067         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5068         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5069         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5070         LDKCommitmentTransaction commitment_tx_conv;
5071         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
5072         commitment_tx_conv.is_owned = false;
5073         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5074         LDKCVec_PaymentPreimageZ preimages_constr;
5075         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5076         if (preimages_constr.datalen > 0)
5077                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5078         else
5079                 preimages_constr.data = NULL;
5080         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5081                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5082                 LDKThirtyTwoBytes preimages_conv_8_ref;
5083                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5084                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5085                 preimages_constr.data[i] = preimages_conv_8_ref;
5086         }
5087         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5088         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
5089         return (int64_t)ret_conv;
5090 }
5091
5092 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) {
5093         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5094         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5095         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5096         unsigned char secret_arr[32];
5097         CHECK((*env)->GetArrayLength(env, secret) == 32);
5098         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
5099         unsigned char (*secret_ref)[32] = &secret_arr;
5100         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5101         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
5102         return (int64_t)ret_conv;
5103 }
5104
5105 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) {
5106         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5107         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5108         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5109         LDKHolderCommitmentTransaction commitment_tx_conv;
5110         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
5111         commitment_tx_conv.is_owned = false;
5112         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5113         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5114         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
5115         return (int64_t)ret_conv;
5116 }
5117
5118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1output(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
5119         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5120         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5121         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5122         LDKTransaction justice_tx_ref;
5123         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5124         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5125         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5126         justice_tx_ref.data_is_owned = true;
5127         unsigned char per_commitment_key_arr[32];
5128         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5129         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5130         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5131         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5132         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
5133         return (int64_t)ret_conv;
5134 }
5135
5136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, int64_t htlc) {
5137         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5138         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5139         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5140         LDKTransaction justice_tx_ref;
5141         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5142         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5143         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5144         justice_tx_ref.data_is_owned = true;
5145         unsigned char per_commitment_key_arr[32];
5146         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5147         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5148         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5149         LDKHTLCOutputInCommitment htlc_conv;
5150         htlc_conv.inner = (void*)(htlc & (~1));
5151         htlc_conv.is_owned = false;
5152         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5153         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5154         *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);
5155         return (int64_t)ret_conv;
5156 }
5157
5158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1htlc_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, int64_t htlc) {
5159         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5160         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5161         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5162         LDKTransaction htlc_tx_ref;
5163         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
5164         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
5165         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
5166         htlc_tx_ref.data_is_owned = true;
5167         LDKPublicKey per_commitment_point_ref;
5168         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
5169         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
5170         LDKHTLCOutputInCommitment htlc_conv;
5171         htlc_conv.inner = (void*)(htlc & (~1));
5172         htlc_conv.is_owned = false;
5173         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5174         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5175         *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);
5176         return (int64_t)ret_conv;
5177 }
5178
5179 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) {
5180         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5181         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5182         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5183         LDKClosingTransaction closing_tx_conv;
5184         closing_tx_conv.inner = (void*)(closing_tx & (~1));
5185         closing_tx_conv.is_owned = false;
5186         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
5187         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5188         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
5189         return (int64_t)ret_conv;
5190 }
5191
5192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
5193         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5194         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5195         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5196         LDKUnsignedChannelAnnouncement msg_conv;
5197         msg_conv.inner = (void*)(msg & (~1));
5198         msg_conv.is_owned = false;
5199         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
5200         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
5201         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5202         return (int64_t)ret_conv;
5203 }
5204
5205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
5206         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5207         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5208         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5209         LDKChannelTransactionParameters channel_parameters_conv;
5210         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
5211         channel_parameters_conv.is_owned = false;
5212         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
5213         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
5214 }
5215
5216 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
5217         if (this_arg->set_pubkeys != NULL)
5218                 this_arg->set_pubkeys(this_arg);
5219         return this_arg->pubkeys;
5220 }
5221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
5222         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5223         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5224         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5225         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
5226         int64_t ret_ref = 0;
5227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5230         ret_ref = (uintptr_t)ret_var.inner;
5231         if (ret_var.is_owned) {
5232                 ret_ref |= 1;
5233         }
5234         return ret_ref;
5235 }
5236
5237 typedef struct LDKSign_JCalls {
5238         atomic_size_t refcnt;
5239         JavaVM *vm;
5240         jweak o;
5241         LDKBaseSign_JCalls* BaseSign;
5242         jmethodID write_meth;
5243 } LDKSign_JCalls;
5244 static void LDKSign_JCalls_free(void* this_arg) {
5245         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5246         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5247                 JNIEnv *env;
5248                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5249                 if (get_jenv_res == JNI_EDETACHED) {
5250                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5251                 } else {
5252                         DO_ASSERT(get_jenv_res == JNI_OK);
5253                 }
5254                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5255                 if (get_jenv_res == JNI_EDETACHED) {
5256                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5257                 }
5258                 FREE(j_calls);
5259         }
5260 }
5261 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
5262         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5263         JNIEnv *env;
5264         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5265         if (get_jenv_res == JNI_EDETACHED) {
5266                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5267         } else {
5268                 DO_ASSERT(get_jenv_res == JNI_OK);
5269         }
5270         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5271         CHECK(obj != NULL);
5272         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5273         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5274                 (*env)->ExceptionDescribe(env);
5275                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
5276         }
5277         LDKCVec_u8Z ret_ref;
5278         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5279         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5280         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5281         if (get_jenv_res == JNI_EDETACHED) {
5282                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5283         }
5284         return ret_ref;
5285 }
5286 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
5287         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
5288         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5289         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
5290 }
5291 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5292         jclass c = (*env)->GetObjectClass(env, o);
5293         CHECK(c != NULL);
5294         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
5295         atomic_init(&calls->refcnt, 1);
5296         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5297         calls->o = (*env)->NewWeakGlobalRef(env, o);
5298         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
5299         CHECK(calls->write_meth != NULL);
5300
5301         LDKChannelPublicKeys pubkeys_conv;
5302         pubkeys_conv.inner = (void*)(pubkeys & (~1));
5303         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
5304         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5305
5306         LDKSign ret = {
5307                 .this_arg = (void*) calls,
5308                 .write = write_LDKSign_jcall,
5309                 .cloned = LDKSign_JCalls_cloned,
5310                 .free = LDKSign_JCalls_free,
5311                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
5312         };
5313         calls->BaseSign = ret.BaseSign.this_arg;
5314         return ret;
5315 }
5316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5317         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
5318         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
5319         return (uint64_t)res_ptr;
5320 }
5321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
5322         LDKSign *inp = (LDKSign *)(arg & ~1);
5323         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
5324         DO_ASSERT((res_ptr & 1) == 0);
5325         return (int64_t)(res_ptr | 1);
5326 }
5327 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
5328         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5329         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5330         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
5331         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5332         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5333         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5334         CVec_u8Z_free(ret_var);
5335         return ret_arr;
5336 }
5337
5338 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5339 CHECK(owner->result_ok);
5340         return Sign_clone(&*owner->contents.result);
5341 }
5342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5343         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5344         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5345         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
5346         return (int64_t)ret_ret;
5347 }
5348
5349 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5350 CHECK(!owner->result_ok);
5351         return DecodeError_clone(&*owner->contents.err);
5352 }
5353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5354         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5355         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
5356         int64_t ret_ref = 0;
5357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5360         ret_ref = (uintptr_t)ret_var.inner;
5361         if (ret_var.is_owned) {
5362                 ret_ref |= 1;
5363         }
5364         return ret_ref;
5365 }
5366
5367 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5368 CHECK(owner->result_ok);
5369         return *owner->contents.result;
5370 }
5371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5372         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5373         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
5374         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
5375         return ret_arr;
5376 }
5377
5378 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5379 CHECK(!owner->result_ok);
5380         return *owner->contents.err;
5381 }
5382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5383         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5384         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
5385 }
5386
5387 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
5388         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
5389         for (size_t i = 0; i < ret.datalen; i++) {
5390                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
5391         }
5392         return ret;
5393 }
5394 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5395 CHECK(owner->result_ok);
5396         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
5397 }
5398 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5399         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5400         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
5401         jobjectArray ret_arr = NULL;
5402         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
5403         ;
5404         for (size_t i = 0; i < ret_var.datalen; i++) {
5405                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
5406                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
5407                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
5408                 CVec_u8Z_free(ret_conv_8_var);
5409                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
5410         }
5411         
5412         FREE(ret_var.data);
5413         return ret_arr;
5414 }
5415
5416 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5417 CHECK(!owner->result_ok);
5418         return *owner->contents.err;
5419 }
5420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5421         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5422         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
5423 }
5424
5425 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5426 CHECK(owner->result_ok);
5427         return InMemorySigner_clone(&*owner->contents.result);
5428 }
5429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5430         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5431         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
5432         int64_t ret_ref = 0;
5433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5436         ret_ref = (uintptr_t)ret_var.inner;
5437         if (ret_var.is_owned) {
5438                 ret_ref |= 1;
5439         }
5440         return ret_ref;
5441 }
5442
5443 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5444 CHECK(!owner->result_ok);
5445         return DecodeError_clone(&*owner->contents.err);
5446 }
5447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5448         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5449         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
5450         int64_t ret_ref = 0;
5451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5454         ret_ref = (uintptr_t)ret_var.inner;
5455         if (ret_var.is_owned) {
5456                 ret_ref |= 1;
5457         }
5458         return ret_ref;
5459 }
5460
5461 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
5462         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
5463         for (size_t i = 0; i < ret.datalen; i++) {
5464                 ret.data[i] = TxOut_clone(&orig->data[i]);
5465         }
5466         return ret;
5467 }
5468 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5469 CHECK(owner->result_ok);
5470         return *owner->contents.result;
5471 }
5472 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5473         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5474         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
5475         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5476         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5477         return ret_arr;
5478 }
5479
5480 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5481 CHECK(!owner->result_ok);
5482         return *owner->contents.err;
5483 }
5484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5485         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5486         CResult_TransactionNoneZ_get_err(owner_conv);
5487 }
5488
5489 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5490         return ThirtyTwoBytes_clone(&owner->a);
5491 }
5492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5493         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5494         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5495         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
5496         return ret_arr;
5497 }
5498
5499 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5500         return ChannelMonitor_clone(&owner->b);
5501 }
5502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5503         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5504         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5505         int64_t ret_ref = 0;
5506         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5507         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5509         ret_ref = (uintptr_t)ret_var.inner;
5510         if (ret_var.is_owned) {
5511                 ret_ref |= 1;
5512         }
5513         return ret_ref;
5514 }
5515
5516 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
5517         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
5518         for (size_t i = 0; i < ret.datalen; i++) {
5519                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
5520         }
5521         return ret;
5522 }
5523 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5524 CHECK(owner->result_ok);
5525         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
5526 }
5527 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5528         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
5529         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
5530         int64_tArray ret_arr = NULL;
5531         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5532         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5533         for (size_t j = 0; j < ret_var.datalen; j++) {
5534                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5535                 *ret_conv_35_conv = ret_var.data[j];
5536                 ret_arr_ptr[j] = ((int64_t)ret_conv_35_conv);
5537         }
5538         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5539         FREE(ret_var.data);
5540         return ret_arr;
5541 }
5542
5543 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5544 CHECK(!owner->result_ok);
5545         return *owner->contents.err;
5546 }
5547 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5548         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
5549         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
5550         return ret_conv;
5551 }
5552
5553 static jclass LDKCOption_u16Z_Some_class = NULL;
5554 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
5555 static jclass LDKCOption_u16Z_None_class = NULL;
5556 static jmethodID LDKCOption_u16Z_None_meth = NULL;
5557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
5558         LDKCOption_u16Z_Some_class =
5559                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
5560         CHECK(LDKCOption_u16Z_Some_class != NULL);
5561         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
5562         CHECK(LDKCOption_u16Z_Some_meth != NULL);
5563         LDKCOption_u16Z_None_class =
5564                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
5565         CHECK(LDKCOption_u16Z_None_class != NULL);
5566         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
5567         CHECK(LDKCOption_u16Z_None_meth != NULL);
5568 }
5569 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5570         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
5571         switch(obj->tag) {
5572                 case LDKCOption_u16Z_Some: {
5573                         int16_t some_conv = obj->some;
5574                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
5575                 }
5576                 case LDKCOption_u16Z_None: {
5577                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
5578                 }
5579                 default: abort();
5580         }
5581 }
5582 static jclass LDKAPIError_APIMisuseError_class = NULL;
5583 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
5584 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
5585 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
5586 static jclass LDKAPIError_RouteError_class = NULL;
5587 static jmethodID LDKAPIError_RouteError_meth = NULL;
5588 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
5589 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
5590 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
5591 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
5592 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
5593 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
5594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
5595         LDKAPIError_APIMisuseError_class =
5596                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
5597         CHECK(LDKAPIError_APIMisuseError_class != NULL);
5598         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
5599         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
5600         LDKAPIError_FeeRateTooHigh_class =
5601                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
5602         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
5603         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
5604         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
5605         LDKAPIError_RouteError_class =
5606                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
5607         CHECK(LDKAPIError_RouteError_class != NULL);
5608         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
5609         CHECK(LDKAPIError_RouteError_meth != NULL);
5610         LDKAPIError_ChannelUnavailable_class =
5611                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
5612         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
5613         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
5614         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
5615         LDKAPIError_MonitorUpdateFailed_class =
5616                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
5617         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
5618         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
5619         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
5620         LDKAPIError_IncompatibleShutdownScript_class =
5621                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
5622         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
5623         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
5624         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
5625 }
5626 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5627         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5628         switch(obj->tag) {
5629                 case LDKAPIError_APIMisuseError: {
5630                         LDKStr err_str = obj->api_misuse_error.err;
5631                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5632                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
5633                 }
5634                 case LDKAPIError_FeeRateTooHigh: {
5635                         LDKStr err_str = obj->fee_rate_too_high.err;
5636                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5637                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
5638                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
5639                 }
5640                 case LDKAPIError_RouteError: {
5641                         LDKStr err_str = obj->route_error.err;
5642                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5643                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
5644                 }
5645                 case LDKAPIError_ChannelUnavailable: {
5646                         LDKStr err_str = obj->channel_unavailable.err;
5647                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5648                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
5649                 }
5650                 case LDKAPIError_MonitorUpdateFailed: {
5651                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
5652                 }
5653                 case LDKAPIError_IncompatibleShutdownScript: {
5654                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
5655                         int64_t script_ref = 0;
5656                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5657                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5658                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
5659                         script_ref = (uintptr_t)script_var.inner & ~1;
5660                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
5661                 }
5662                 default: abort();
5663         }
5664 }
5665 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5666 CHECK(owner->result_ok);
5667         return *owner->contents.result;
5668 }
5669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5670         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5671         CResult_NoneAPIErrorZ_get_ok(owner_conv);
5672 }
5673
5674 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5675 CHECK(!owner->result_ok);
5676         return APIError_clone(&*owner->contents.err);
5677 }
5678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5679         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5680         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5681         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
5682         int64_t ret_ref = (uintptr_t)ret_copy;
5683         return ret_ref;
5684 }
5685
5686 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
5687         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
5688         for (size_t i = 0; i < ret.datalen; i++) {
5689                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
5690         }
5691         return ret;
5692 }
5693 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
5694         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
5695         for (size_t i = 0; i < ret.datalen; i++) {
5696                 ret.data[i] = APIError_clone(&orig->data[i]);
5697         }
5698         return ret;
5699 }
5700 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5701 CHECK(owner->result_ok);
5702         return ThirtyTwoBytes_clone(&*owner->contents.result);
5703 }
5704 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5705         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
5706         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5707         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
5708         return ret_arr;
5709 }
5710
5711 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5712 CHECK(!owner->result_ok);
5713         return APIError_clone(&*owner->contents.err);
5714 }
5715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5716         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
5717         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5718         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
5719         int64_t ret_ref = (uintptr_t)ret_copy;
5720         return ret_ref;
5721 }
5722
5723 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
5724 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
5725 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
5726 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
5727 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
5728 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
5729 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
5730 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
5731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
5732         LDKPaymentSendFailure_ParameterError_class =
5733                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
5734         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
5735         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
5736         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
5737         LDKPaymentSendFailure_PathParameterError_class =
5738                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
5739         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
5740         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
5741         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
5742         LDKPaymentSendFailure_AllFailedRetrySafe_class =
5743                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
5744         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
5745         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
5746         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
5747         LDKPaymentSendFailure_PartialFailure_class =
5748                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
5749         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
5750         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
5751         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
5752 }
5753 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5754         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5755         switch(obj->tag) {
5756                 case LDKPaymentSendFailure_ParameterError: {
5757                         int64_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
5758                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
5759                 }
5760                 case LDKPaymentSendFailure_PathParameterError: {
5761                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
5762                         int64_tArray path_parameter_error_arr = NULL;
5763                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
5764                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
5765                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
5766                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5767                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
5768                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
5769                                 path_parameter_error_arr_ptr[w] = (int64_t)path_parameter_error_conv_22_conv;
5770                         }
5771                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
5772                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
5773                 }
5774                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
5775                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
5776                         int64_tArray all_failed_retry_safe_arr = NULL;
5777                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
5778                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
5779                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
5780                                 int64_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
5781                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
5782                         }
5783                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
5784                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
5785                 }
5786                 case LDKPaymentSendFailure_PartialFailure: {
5787                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
5788                         int64_tArray results_arr = NULL;
5789                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
5790                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
5791                         for (size_t w = 0; w < results_var.datalen; w++) {
5792                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5793                                 *results_conv_22_conv = results_var.data[w];
5794                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
5795                                 results_arr_ptr[w] = (int64_t)results_conv_22_conv;
5796                         }
5797                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
5798                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
5799                         int64_t failed_paths_retry_ref = 0;
5800                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
5801                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5802                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5803                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
5804                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
5805                         }
5806                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
5807                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
5808                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
5809                 }
5810                 default: abort();
5811         }
5812 }
5813 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5814 CHECK(owner->result_ok);
5815         return ThirtyTwoBytes_clone(&*owner->contents.result);
5816 }
5817 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5818         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5819         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5820         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
5821         return ret_arr;
5822 }
5823
5824 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5825 CHECK(!owner->result_ok);
5826         return PaymentSendFailure_clone(&*owner->contents.err);
5827 }
5828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5829         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5830         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5831         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
5832         int64_t ret_ref = (uintptr_t)ret_copy;
5833         return ret_ref;
5834 }
5835
5836 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5837 CHECK(owner->result_ok);
5838         return *owner->contents.result;
5839 }
5840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5841         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5842         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
5843 }
5844
5845 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5846 CHECK(!owner->result_ok);
5847         return PaymentSendFailure_clone(&*owner->contents.err);
5848 }
5849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5850         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5851         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5852         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
5853         int64_t ret_ref = (uintptr_t)ret_copy;
5854         return ret_ref;
5855 }
5856
5857 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5858         return ThirtyTwoBytes_clone(&owner->a);
5859 }
5860 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5861         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5862         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5863         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
5864         return ret_arr;
5865 }
5866
5867 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5868         return ThirtyTwoBytes_clone(&owner->b);
5869 }
5870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5871         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5872         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5873         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
5874         return ret_arr;
5875 }
5876
5877 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5878 CHECK(owner->result_ok);
5879         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
5880 }
5881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5882         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5883         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
5884         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
5885         return ((int64_t)ret_conv);
5886 }
5887
5888 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5889 CHECK(!owner->result_ok);
5890         return PaymentSendFailure_clone(&*owner->contents.err);
5891 }
5892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5893         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5894         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5895         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
5896         int64_t ret_ref = (uintptr_t)ret_copy;
5897         return ret_ref;
5898 }
5899
5900 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5901         return ThirtyTwoBytes_clone(&owner->a);
5902 }
5903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5904         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5905         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5906         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
5907         return ret_arr;
5908 }
5909
5910 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5911         return ThirtyTwoBytes_clone(&owner->b);
5912 }
5913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5914         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5915         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5916         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
5917         return ret_arr;
5918 }
5919
5920 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5921 CHECK(owner->result_ok);
5922         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5923 }
5924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5925         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5926         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5927         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
5928         return ((int64_t)ret_conv);
5929 }
5930
5931 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5932 CHECK(!owner->result_ok);
5933         return *owner->contents.err;
5934 }
5935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5936         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5937         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
5938 }
5939
5940 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5941 CHECK(owner->result_ok);
5942         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5943 }
5944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5945         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5946         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5947         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
5948         return ((int64_t)ret_conv);
5949 }
5950
5951 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5952 CHECK(!owner->result_ok);
5953         return APIError_clone(&*owner->contents.err);
5954 }
5955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5956         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5957         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5958         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
5959         int64_t ret_ref = (uintptr_t)ret_copy;
5960         return ret_ref;
5961 }
5962
5963 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5964 CHECK(owner->result_ok);
5965         return ThirtyTwoBytes_clone(&*owner->contents.result);
5966 }
5967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5968         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5969         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5970         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
5971         return ret_arr;
5972 }
5973
5974 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5975 CHECK(!owner->result_ok);
5976         return *owner->contents.err;
5977 }
5978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5979         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5980         CResult_PaymentSecretNoneZ_get_err(owner_conv);
5981 }
5982
5983 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5984 CHECK(owner->result_ok);
5985         return ThirtyTwoBytes_clone(&*owner->contents.result);
5986 }
5987 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5988         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5989         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5990         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
5991         return ret_arr;
5992 }
5993
5994 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5995 CHECK(!owner->result_ok);
5996         return APIError_clone(&*owner->contents.err);
5997 }
5998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5999         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6000         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6001         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6002         int64_t ret_ref = (uintptr_t)ret_copy;
6003         return ret_ref;
6004 }
6005
6006 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6007 CHECK(owner->result_ok);
6008         return ThirtyTwoBytes_clone(&*owner->contents.result);
6009 }
6010 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6011         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6012         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6013         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
6014         return ret_arr;
6015 }
6016
6017 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6018 CHECK(!owner->result_ok);
6019         return APIError_clone(&*owner->contents.err);
6020 }
6021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6022         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6023         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6024         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6025         int64_t ret_ref = (uintptr_t)ret_copy;
6026         return ret_ref;
6027 }
6028
6029 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6030 CHECK(owner->result_ok);
6031         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
6032 }
6033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6034         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
6035         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
6036         int64_t ret_ref = 0;
6037         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6038         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6040         ret_ref = (uintptr_t)ret_var.inner;
6041         if (ret_var.is_owned) {
6042                 ret_ref |= 1;
6043         }
6044         return ret_ref;
6045 }
6046
6047 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6048 CHECK(!owner->result_ok);
6049         return DecodeError_clone(&*owner->contents.err);
6050 }
6051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6052         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
6053         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
6054         int64_t ret_ref = 0;
6055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6058         ret_ref = (uintptr_t)ret_var.inner;
6059         if (ret_var.is_owned) {
6060                 ret_ref |= 1;
6061         }
6062         return ret_ref;
6063 }
6064
6065 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6066 CHECK(owner->result_ok);
6067         return ChannelCounterparty_clone(&*owner->contents.result);
6068 }
6069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6070         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
6071         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
6072         int64_t ret_ref = 0;
6073         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6074         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6076         ret_ref = (uintptr_t)ret_var.inner;
6077         if (ret_var.is_owned) {
6078                 ret_ref |= 1;
6079         }
6080         return ret_ref;
6081 }
6082
6083 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6084 CHECK(!owner->result_ok);
6085         return DecodeError_clone(&*owner->contents.err);
6086 }
6087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6088         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
6089         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
6090         int64_t ret_ref = 0;
6091         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6092         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6094         ret_ref = (uintptr_t)ret_var.inner;
6095         if (ret_var.is_owned) {
6096                 ret_ref |= 1;
6097         }
6098         return ret_ref;
6099 }
6100
6101 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6102 CHECK(owner->result_ok);
6103         return ChannelDetails_clone(&*owner->contents.result);
6104 }
6105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6106         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
6107         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
6108         int64_t ret_ref = 0;
6109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6112         ret_ref = (uintptr_t)ret_var.inner;
6113         if (ret_var.is_owned) {
6114                 ret_ref |= 1;
6115         }
6116         return ret_ref;
6117 }
6118
6119 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6120 CHECK(!owner->result_ok);
6121         return DecodeError_clone(&*owner->contents.err);
6122 }
6123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6124         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
6125         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
6126         int64_t ret_ref = 0;
6127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6130         ret_ref = (uintptr_t)ret_var.inner;
6131         if (ret_var.is_owned) {
6132                 ret_ref |= 1;
6133         }
6134         return ret_ref;
6135 }
6136
6137 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6138 CHECK(owner->result_ok);
6139         return PhantomRouteHints_clone(&*owner->contents.result);
6140 }
6141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6142         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
6143         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
6144         int64_t ret_ref = 0;
6145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6148         ret_ref = (uintptr_t)ret_var.inner;
6149         if (ret_var.is_owned) {
6150                 ret_ref |= 1;
6151         }
6152         return ret_ref;
6153 }
6154
6155 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6156 CHECK(!owner->result_ok);
6157         return DecodeError_clone(&*owner->contents.err);
6158 }
6159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6160         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
6161         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
6162         int64_t ret_ref = 0;
6163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6166         ret_ref = (uintptr_t)ret_var.inner;
6167         if (ret_var.is_owned) {
6168                 ret_ref |= 1;
6169         }
6170         return ret_ref;
6171 }
6172
6173 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6174         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6175         for (size_t i = 0; i < ret.datalen; i++) {
6176                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6177         }
6178         return ret;
6179 }
6180 typedef struct LDKWatch_JCalls {
6181         atomic_size_t refcnt;
6182         JavaVM *vm;
6183         jweak o;
6184         jmethodID watch_channel_meth;
6185         jmethodID update_channel_meth;
6186         jmethodID release_pending_monitor_events_meth;
6187 } LDKWatch_JCalls;
6188 static void LDKWatch_JCalls_free(void* this_arg) {
6189         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6190         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6191                 JNIEnv *env;
6192                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6193                 if (get_jenv_res == JNI_EDETACHED) {
6194                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6195                 } else {
6196                         DO_ASSERT(get_jenv_res == JNI_OK);
6197                 }
6198                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6199                 if (get_jenv_res == JNI_EDETACHED) {
6200                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6201                 }
6202                 FREE(j_calls);
6203         }
6204 }
6205 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6206         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6207         JNIEnv *env;
6208         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6209         if (get_jenv_res == JNI_EDETACHED) {
6210                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6211         } else {
6212                 DO_ASSERT(get_jenv_res == JNI_OK);
6213         }
6214         LDKOutPoint funding_txo_var = funding_txo;
6215         int64_t funding_txo_ref = 0;
6216         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6217         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6218         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6219         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6220         if (funding_txo_var.is_owned) {
6221                 funding_txo_ref |= 1;
6222         }
6223         LDKChannelMonitor monitor_var = monitor;
6224         int64_t monitor_ref = 0;
6225         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6226         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6227         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
6228         monitor_ref = (uintptr_t)monitor_var.inner;
6229         if (monitor_var.is_owned) {
6230                 monitor_ref |= 1;
6231         }
6232         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6233         CHECK(obj != NULL);
6234         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
6235         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6236                 (*env)->ExceptionDescribe(env);
6237                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
6238         }
6239         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6240         CHECK_ACCESS(ret_ptr);
6241         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6242         FREE((void*)ret);
6243         if (get_jenv_res == JNI_EDETACHED) {
6244                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6245         }
6246         return ret_conv;
6247 }
6248 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
6249         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6250         JNIEnv *env;
6251         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6252         if (get_jenv_res == JNI_EDETACHED) {
6253                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6254         } else {
6255                 DO_ASSERT(get_jenv_res == JNI_OK);
6256         }
6257         LDKOutPoint funding_txo_var = funding_txo;
6258         int64_t funding_txo_ref = 0;
6259         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6260         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6261         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6262         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6263         if (funding_txo_var.is_owned) {
6264                 funding_txo_ref |= 1;
6265         }
6266         LDKChannelMonitorUpdate update_var = update;
6267         int64_t update_ref = 0;
6268         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6269         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6270         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
6271         update_ref = (uintptr_t)update_var.inner;
6272         if (update_var.is_owned) {
6273                 update_ref |= 1;
6274         }
6275         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6276         CHECK(obj != NULL);
6277         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
6278         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6279                 (*env)->ExceptionDescribe(env);
6280                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
6281         }
6282         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6283         CHECK_ACCESS(ret_ptr);
6284         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6285         FREE((void*)ret);
6286         if (get_jenv_res == JNI_EDETACHED) {
6287                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6288         }
6289         return ret_conv;
6290 }
6291 LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
6292         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6293         JNIEnv *env;
6294         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6295         if (get_jenv_res == JNI_EDETACHED) {
6296                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6297         } else {
6298                 DO_ASSERT(get_jenv_res == JNI_OK);
6299         }
6300         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6301         CHECK(obj != NULL);
6302         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
6303         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6304                 (*env)->ExceptionDescribe(env);
6305                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
6306         }
6307         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret_constr;
6308         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6309         if (ret_constr.datalen > 0)
6310                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ Elements");
6311         else
6312                 ret_constr.data = NULL;
6313         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6314         for (size_t m = 0; m < ret_constr.datalen; m++) {
6315                 int64_t ret_conv_38 = ret_vals[m];
6316                 void* ret_conv_38_ptr = (void*)(((uintptr_t)ret_conv_38) & ~1);
6317                 CHECK_ACCESS(ret_conv_38_ptr);
6318                 LDKC2Tuple_OutPointCVec_MonitorEventZZ ret_conv_38_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(ret_conv_38_ptr);
6319                 FREE((void*)ret_conv_38);
6320                 ret_constr.data[m] = ret_conv_38_conv;
6321         }
6322         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6323         if (get_jenv_res == JNI_EDETACHED) {
6324                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6325         }
6326         return ret_constr;
6327 }
6328 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
6329         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
6330         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6331 }
6332 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
6333         jclass c = (*env)->GetObjectClass(env, o);
6334         CHECK(c != NULL);
6335         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
6336         atomic_init(&calls->refcnt, 1);
6337         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6338         calls->o = (*env)->NewWeakGlobalRef(env, o);
6339         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
6340         CHECK(calls->watch_channel_meth != NULL);
6341         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
6342         CHECK(calls->update_channel_meth != NULL);
6343         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
6344         CHECK(calls->release_pending_monitor_events_meth != NULL);
6345
6346         LDKWatch ret = {
6347                 .this_arg = (void*) calls,
6348                 .watch_channel = watch_channel_LDKWatch_jcall,
6349                 .update_channel = update_channel_LDKWatch_jcall,
6350                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
6351                 .free = LDKWatch_JCalls_free,
6352         };
6353         return ret;
6354 }
6355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
6356         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
6357         *res_ptr = LDKWatch_init(env, clz, o);
6358         return (uint64_t)res_ptr;
6359 }
6360 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) {
6361         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6362         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6363         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6364         LDKOutPoint funding_txo_conv;
6365         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6366         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6367         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6368         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6369         LDKChannelMonitor monitor_conv;
6370         monitor_conv.inner = (void*)(monitor & (~1));
6371         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
6372         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
6373         monitor_conv = ChannelMonitor_clone(&monitor_conv);
6374         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6375         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
6376         return (int64_t)ret_conv;
6377 }
6378
6379 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) {
6380         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6381         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6382         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6383         LDKOutPoint funding_txo_conv;
6384         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6385         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6386         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6387         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6388         LDKChannelMonitorUpdate update_conv;
6389         update_conv.inner = (void*)(update & (~1));
6390         update_conv.is_owned = (update & 1) || (update == 0);
6391         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
6392         update_conv = ChannelMonitorUpdate_clone(&update_conv);
6393         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6394         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
6395         return (int64_t)ret_conv;
6396 }
6397
6398 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6399         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6400         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6401         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6402         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
6403         int64_tArray ret_arr = NULL;
6404         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6405         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6406         for (size_t m = 0; m < ret_var.datalen; m++) {
6407                 LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv_38_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
6408                 *ret_conv_38_conv = ret_var.data[m];
6409                 ret_arr_ptr[m] = ((int64_t)ret_conv_38_conv);
6410         }
6411         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6412         FREE(ret_var.data);
6413         return ret_arr;
6414 }
6415
6416 typedef struct LDKBroadcasterInterface_JCalls {
6417         atomic_size_t refcnt;
6418         JavaVM *vm;
6419         jweak o;
6420         jmethodID broadcast_transaction_meth;
6421 } LDKBroadcasterInterface_JCalls;
6422 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
6423         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6424         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6425                 JNIEnv *env;
6426                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6427                 if (get_jenv_res == JNI_EDETACHED) {
6428                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6429                 } else {
6430                         DO_ASSERT(get_jenv_res == JNI_OK);
6431                 }
6432                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6433                 if (get_jenv_res == JNI_EDETACHED) {
6434                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6435                 }
6436                 FREE(j_calls);
6437         }
6438 }
6439 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
6440         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6441         JNIEnv *env;
6442         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6443         if (get_jenv_res == JNI_EDETACHED) {
6444                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6445         } else {
6446                 DO_ASSERT(get_jenv_res == JNI_OK);
6447         }
6448         LDKTransaction tx_var = tx;
6449         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
6450         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
6451         Transaction_free(tx_var);
6452         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6453         CHECK(obj != NULL);
6454         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
6455         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6456                 (*env)->ExceptionDescribe(env);
6457                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
6458         }
6459         if (get_jenv_res == JNI_EDETACHED) {
6460                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6461         }
6462 }
6463 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
6464         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
6465         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6466 }
6467 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
6468         jclass c = (*env)->GetObjectClass(env, o);
6469         CHECK(c != NULL);
6470         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
6471         atomic_init(&calls->refcnt, 1);
6472         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6473         calls->o = (*env)->NewWeakGlobalRef(env, o);
6474         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
6475         CHECK(calls->broadcast_transaction_meth != NULL);
6476
6477         LDKBroadcasterInterface ret = {
6478                 .this_arg = (void*) calls,
6479                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
6480                 .free = LDKBroadcasterInterface_JCalls_free,
6481         };
6482         return ret;
6483 }
6484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6485         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
6486         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
6487         return (uint64_t)res_ptr;
6488 }
6489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
6490         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6491         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6492         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
6493         LDKTransaction tx_ref;
6494         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
6495         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
6496         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
6497         tx_ref.data_is_owned = true;
6498         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
6499 }
6500
6501 typedef struct LDKKeysInterface_JCalls {
6502         atomic_size_t refcnt;
6503         JavaVM *vm;
6504         jweak o;
6505         jmethodID get_node_secret_meth;
6506         jmethodID get_destination_script_meth;
6507         jmethodID get_shutdown_scriptpubkey_meth;
6508         jmethodID get_channel_signer_meth;
6509         jmethodID get_secure_random_bytes_meth;
6510         jmethodID read_chan_signer_meth;
6511         jmethodID sign_invoice_meth;
6512         jmethodID get_inbound_payment_key_material_meth;
6513 } LDKKeysInterface_JCalls;
6514 static void LDKKeysInterface_JCalls_free(void* this_arg) {
6515         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6516         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6517                 JNIEnv *env;
6518                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6519                 if (get_jenv_res == JNI_EDETACHED) {
6520                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6521                 } else {
6522                         DO_ASSERT(get_jenv_res == JNI_OK);
6523                 }
6524                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6525                 if (get_jenv_res == JNI_EDETACHED) {
6526                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6527                 }
6528                 FREE(j_calls);
6529         }
6530 }
6531 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
6532         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6533         JNIEnv *env;
6534         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6535         if (get_jenv_res == JNI_EDETACHED) {
6536                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6537         } else {
6538                 DO_ASSERT(get_jenv_res == JNI_OK);
6539         }
6540         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
6541         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6542         CHECK(obj != NULL);
6543         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
6544         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6545                 (*env)->ExceptionDescribe(env);
6546                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
6547         }
6548         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6549         CHECK_ACCESS(ret_ptr);
6550         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
6551         FREE((void*)ret);
6552         if (get_jenv_res == JNI_EDETACHED) {
6553                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6554         }
6555         return ret_conv;
6556 }
6557 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
6558         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6559         JNIEnv *env;
6560         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6561         if (get_jenv_res == JNI_EDETACHED) {
6562                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6563         } else {
6564                 DO_ASSERT(get_jenv_res == JNI_OK);
6565         }
6566         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6567         CHECK(obj != NULL);
6568         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
6569         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6570                 (*env)->ExceptionDescribe(env);
6571                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
6572         }
6573         LDKCVec_u8Z ret_ref;
6574         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6575         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6576         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6577         if (get_jenv_res == JNI_EDETACHED) {
6578                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6579         }
6580         return ret_ref;
6581 }
6582 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
6583         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6584         JNIEnv *env;
6585         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6586         if (get_jenv_res == JNI_EDETACHED) {
6587                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6588         } else {
6589                 DO_ASSERT(get_jenv_res == JNI_OK);
6590         }
6591         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6592         CHECK(obj != NULL);
6593         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
6594         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6595                 (*env)->ExceptionDescribe(env);
6596                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
6597         }
6598         LDKShutdownScript ret_conv;
6599         ret_conv.inner = (void*)(ret & (~1));
6600         ret_conv.is_owned = (ret & 1) || (ret == 0);
6601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
6602         if (get_jenv_res == JNI_EDETACHED) {
6603                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6604         }
6605         return ret_conv;
6606 }
6607 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
6608         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6609         JNIEnv *env;
6610         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6611         if (get_jenv_res == JNI_EDETACHED) {
6612                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6613         } else {
6614                 DO_ASSERT(get_jenv_res == JNI_OK);
6615         }
6616         jboolean inbound_conv = inbound;
6617         int64_t channel_value_satoshis_conv = channel_value_satoshis;
6618         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6619         CHECK(obj != NULL);
6620         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound_conv, channel_value_satoshis_conv);
6621         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6622                 (*env)->ExceptionDescribe(env);
6623                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
6624         }
6625         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6626         CHECK_ACCESS(ret_ptr);
6627         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
6628         FREE((void*)ret);
6629         if (get_jenv_res == JNI_EDETACHED) {
6630                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6631         }
6632         return ret_conv;
6633 }
6634 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
6635         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6636         JNIEnv *env;
6637         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6638         if (get_jenv_res == JNI_EDETACHED) {
6639                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6640         } else {
6641                 DO_ASSERT(get_jenv_res == JNI_OK);
6642         }
6643         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6644         CHECK(obj != NULL);
6645         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
6646         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6647                 (*env)->ExceptionDescribe(env);
6648                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
6649         }
6650         LDKThirtyTwoBytes ret_ref;
6651         CHECK((*env)->GetArrayLength(env, ret) == 32);
6652         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6653         if (get_jenv_res == JNI_EDETACHED) {
6654                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6655         }
6656         return ret_ref;
6657 }
6658 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
6659         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6660         JNIEnv *env;
6661         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6662         if (get_jenv_res == JNI_EDETACHED) {
6663                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6664         } else {
6665                 DO_ASSERT(get_jenv_res == JNI_OK);
6666         }
6667         LDKu8slice reader_var = reader;
6668         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
6669         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
6670         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6671         CHECK(obj != NULL);
6672         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
6673         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6674                 (*env)->ExceptionDescribe(env);
6675                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
6676         }
6677         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6678         CHECK_ACCESS(ret_ptr);
6679         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
6680         FREE((void*)ret);
6681         if (get_jenv_res == JNI_EDETACHED) {
6682                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6683         }
6684         return ret_conv;
6685 }
6686 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
6687         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6688         JNIEnv *env;
6689         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6690         if (get_jenv_res == JNI_EDETACHED) {
6691                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6692         } else {
6693                 DO_ASSERT(get_jenv_res == JNI_OK);
6694         }
6695         LDKu8slice hrp_bytes_var = hrp_bytes;
6696         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
6697         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
6698         LDKCVec_u5Z invoice_data_var = invoice_data;
6699         jobjectArray invoice_data_arr = NULL;
6700         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
6701         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
6702         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
6703                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
6704                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
6705         }
6706         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
6707         FREE(invoice_data_var.data);
6708         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
6709         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6710         CHECK(obj != NULL);
6711         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
6712         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6713                 (*env)->ExceptionDescribe(env);
6714                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
6715         }
6716         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6717         CHECK_ACCESS(ret_ptr);
6718         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
6719         FREE((void*)ret);
6720         if (get_jenv_res == JNI_EDETACHED) {
6721                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6722         }
6723         return ret_conv;
6724 }
6725 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
6726         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6727         JNIEnv *env;
6728         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6729         if (get_jenv_res == JNI_EDETACHED) {
6730                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6731         } else {
6732                 DO_ASSERT(get_jenv_res == JNI_OK);
6733         }
6734         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6735         CHECK(obj != NULL);
6736         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
6737         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6738                 (*env)->ExceptionDescribe(env);
6739                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
6740         }
6741         LDKThirtyTwoBytes ret_ref;
6742         CHECK((*env)->GetArrayLength(env, ret) == 32);
6743         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6744         if (get_jenv_res == JNI_EDETACHED) {
6745                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6746         }
6747         return ret_ref;
6748 }
6749 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
6750         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
6751         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6752 }
6753 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
6754         jclass c = (*env)->GetObjectClass(env, o);
6755         CHECK(c != NULL);
6756         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
6757         atomic_init(&calls->refcnt, 1);
6758         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6759         calls->o = (*env)->NewWeakGlobalRef(env, o);
6760         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
6761         CHECK(calls->get_node_secret_meth != NULL);
6762         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
6763         CHECK(calls->get_destination_script_meth != NULL);
6764         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
6765         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
6766         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
6767         CHECK(calls->get_channel_signer_meth != NULL);
6768         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
6769         CHECK(calls->get_secure_random_bytes_meth != NULL);
6770         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
6771         CHECK(calls->read_chan_signer_meth != NULL);
6772         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
6773         CHECK(calls->sign_invoice_meth != NULL);
6774         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
6775         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
6776
6777         LDKKeysInterface ret = {
6778                 .this_arg = (void*) calls,
6779                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
6780                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
6781                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
6782                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
6783                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
6784                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
6785                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
6786                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
6787                 .free = LDKKeysInterface_JCalls_free,
6788         };
6789         return ret;
6790 }
6791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6792         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6793         *res_ptr = LDKKeysInterface_init(env, clz, o);
6794         return (uint64_t)res_ptr;
6795 }
6796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
6797         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6798         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6799         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6800         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
6801         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
6802         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
6803         return (int64_t)ret_conv;
6804 }
6805
6806 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
6807         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6808         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6809         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6810         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
6811         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6812         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6813         CVec_u8Z_free(ret_var);
6814         return ret_arr;
6815 }
6816
6817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
6818         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6819         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6820         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6821         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6822         int64_t ret_ref = 0;
6823         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6824         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6826         ret_ref = (uintptr_t)ret_var.inner;
6827         if (ret_var.is_owned) {
6828                 ret_ref |= 1;
6829         }
6830         return ret_ref;
6831 }
6832
6833 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) {
6834         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6835         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6836         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6837         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6838         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
6839         return (int64_t)ret_ret;
6840 }
6841
6842 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
6843         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6844         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6845         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6846         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6847         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
6848         return ret_arr;
6849 }
6850
6851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
6852         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6853         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6854         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6855         LDKu8slice reader_ref;
6856         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
6857         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
6858         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
6859         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6860         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
6861         return (int64_t)ret_conv;
6862 }
6863
6864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray hrp_bytes, jobjectArray invoice_data, jclass receipient) {
6865         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6866         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6867         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6868         LDKu8slice hrp_bytes_ref;
6869         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
6870         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
6871         LDKCVec_u5Z invoice_data_constr;
6872         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
6873         if (invoice_data_constr.datalen > 0)
6874                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
6875         else
6876                 invoice_data_constr.data = NULL;
6877         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
6878         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
6879                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
6880                 
6881                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
6882         }
6883         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
6884         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
6885         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6886         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
6887         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
6888         return (int64_t)ret_conv;
6889 }
6890
6891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
6892         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6893         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6894         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6895         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6896         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
6897         return ret_arr;
6898 }
6899
6900 typedef struct LDKFeeEstimator_JCalls {
6901         atomic_size_t refcnt;
6902         JavaVM *vm;
6903         jweak o;
6904         jmethodID get_est_sat_per_1000_weight_meth;
6905 } LDKFeeEstimator_JCalls;
6906 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
6907         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6908         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6909                 JNIEnv *env;
6910                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6911                 if (get_jenv_res == JNI_EDETACHED) {
6912                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6913                 } else {
6914                         DO_ASSERT(get_jenv_res == JNI_OK);
6915                 }
6916                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6917                 if (get_jenv_res == JNI_EDETACHED) {
6918                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6919                 }
6920                 FREE(j_calls);
6921         }
6922 }
6923 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
6924         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6925         JNIEnv *env;
6926         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6927         if (get_jenv_res == JNI_EDETACHED) {
6928                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6929         } else {
6930                 DO_ASSERT(get_jenv_res == JNI_OK);
6931         }
6932         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
6933         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6934         CHECK(obj != NULL);
6935         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
6936         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6937                 (*env)->ExceptionDescribe(env);
6938                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
6939         }
6940         if (get_jenv_res == JNI_EDETACHED) {
6941                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6942         }
6943         return ret;
6944 }
6945 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
6946         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
6947         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6948 }
6949 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
6950         jclass c = (*env)->GetObjectClass(env, o);
6951         CHECK(c != NULL);
6952         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
6953         atomic_init(&calls->refcnt, 1);
6954         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6955         calls->o = (*env)->NewWeakGlobalRef(env, o);
6956         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
6957         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
6958
6959         LDKFeeEstimator ret = {
6960                 .this_arg = (void*) calls,
6961                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
6962                 .free = LDKFeeEstimator_JCalls_free,
6963         };
6964         return ret;
6965 }
6966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
6967         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
6968         *res_ptr = LDKFeeEstimator_init(env, clz, o);
6969         return (uint64_t)res_ptr;
6970 }
6971 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) {
6972         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6973         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6974         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
6975         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
6976         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
6977         return ret_conv;
6978 }
6979
6980 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6981         return ThirtyTwoBytes_clone(&owner->a);
6982 }
6983 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6984         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6985         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6986         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
6987         return ret_arr;
6988 }
6989
6990 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6991         return &owner->b;
6992 }
6993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6994         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6995         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
6996         int64_t ret_ref = 0;
6997         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6998         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7000         ret_ref = (uintptr_t)ret_var.inner & ~1;
7001         return ret_ref;
7002 }
7003
7004 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7005 CHECK(owner->result_ok);
7006         return &*owner->contents.result;
7007 }
7008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7009         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
7010         int64_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
7011         return ret_ret;
7012 }
7013
7014 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7015 CHECK(!owner->result_ok);
7016         return DecodeError_clone(&*owner->contents.err);
7017 }
7018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7019         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
7020         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
7021         int64_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 struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7033 CHECK(owner->result_ok);
7034         return ChannelConfig_clone(&*owner->contents.result);
7035 }
7036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7037         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
7038         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
7039         int64_t ret_ref = 0;
7040         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7041         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7043         ret_ref = (uintptr_t)ret_var.inner;
7044         if (ret_var.is_owned) {
7045                 ret_ref |= 1;
7046         }
7047         return ret_ref;
7048 }
7049
7050 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7051 CHECK(!owner->result_ok);
7052         return DecodeError_clone(&*owner->contents.err);
7053 }
7054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7055         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
7056         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
7057         int64_t ret_ref = 0;
7058         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7059         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7061         ret_ref = (uintptr_t)ret_var.inner;
7062         if (ret_var.is_owned) {
7063                 ret_ref |= 1;
7064         }
7065         return ret_ref;
7066 }
7067
7068 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7069 CHECK(owner->result_ok);
7070         return OutPoint_clone(&*owner->contents.result);
7071 }
7072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7073         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
7074         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
7075         int64_t ret_ref = 0;
7076         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7077         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7079         ret_ref = (uintptr_t)ret_var.inner;
7080         if (ret_var.is_owned) {
7081                 ret_ref |= 1;
7082         }
7083         return ret_ref;
7084 }
7085
7086 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7087 CHECK(!owner->result_ok);
7088         return DecodeError_clone(&*owner->contents.err);
7089 }
7090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7091         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
7092         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
7093         int64_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 typedef struct LDKType_JCalls {
7105         atomic_size_t refcnt;
7106         JavaVM *vm;
7107         jweak o;
7108         jmethodID type_id_meth;
7109         jmethodID debug_str_meth;
7110         jmethodID write_meth;
7111 } LDKType_JCalls;
7112 static void LDKType_JCalls_free(void* this_arg) {
7113         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7114         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7115                 JNIEnv *env;
7116                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7117                 if (get_jenv_res == JNI_EDETACHED) {
7118                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7119                 } else {
7120                         DO_ASSERT(get_jenv_res == JNI_OK);
7121                 }
7122                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7123                 if (get_jenv_res == JNI_EDETACHED) {
7124                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7125                 }
7126                 FREE(j_calls);
7127         }
7128 }
7129 uint16_t type_id_LDKType_jcall(const void* this_arg) {
7130         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7131         JNIEnv *env;
7132         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7133         if (get_jenv_res == JNI_EDETACHED) {
7134                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7135         } else {
7136                 DO_ASSERT(get_jenv_res == JNI_OK);
7137         }
7138         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7139         CHECK(obj != NULL);
7140         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
7141         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7142                 (*env)->ExceptionDescribe(env);
7143                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
7144         }
7145         if (get_jenv_res == JNI_EDETACHED) {
7146                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7147         }
7148         return ret;
7149 }
7150 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
7151         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7152         JNIEnv *env;
7153         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7154         if (get_jenv_res == JNI_EDETACHED) {
7155                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7156         } else {
7157                 DO_ASSERT(get_jenv_res == JNI_OK);
7158         }
7159         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7160         CHECK(obj != NULL);
7161         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
7162         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7163                 (*env)->ExceptionDescribe(env);
7164                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
7165         }
7166         LDKStr ret_conv = java_to_owned_str(env, ret);
7167         if (get_jenv_res == JNI_EDETACHED) {
7168                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7169         }
7170         return ret_conv;
7171 }
7172 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
7173         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7174         JNIEnv *env;
7175         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7176         if (get_jenv_res == JNI_EDETACHED) {
7177                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7178         } else {
7179                 DO_ASSERT(get_jenv_res == JNI_OK);
7180         }
7181         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7182         CHECK(obj != NULL);
7183         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
7184         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7185                 (*env)->ExceptionDescribe(env);
7186                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
7187         }
7188         LDKCVec_u8Z ret_ref;
7189         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7190         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7191         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7192         if (get_jenv_res == JNI_EDETACHED) {
7193                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7194         }
7195         return ret_ref;
7196 }
7197 static void LDKType_JCalls_cloned(LDKType* new_obj) {
7198         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
7199         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7200 }
7201 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
7202         jclass c = (*env)->GetObjectClass(env, o);
7203         CHECK(c != NULL);
7204         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
7205         atomic_init(&calls->refcnt, 1);
7206         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7207         calls->o = (*env)->NewWeakGlobalRef(env, o);
7208         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
7209         CHECK(calls->type_id_meth != NULL);
7210         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
7211         CHECK(calls->debug_str_meth != NULL);
7212         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
7213         CHECK(calls->write_meth != NULL);
7214
7215         LDKType ret = {
7216                 .this_arg = (void*) calls,
7217                 .type_id = type_id_LDKType_jcall,
7218                 .debug_str = debug_str_LDKType_jcall,
7219                 .write = write_LDKType_jcall,
7220                 .cloned = LDKType_JCalls_cloned,
7221                 .free = LDKType_JCalls_free,
7222         };
7223         return ret;
7224 }
7225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
7226         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
7227         *res_ptr = LDKType_init(env, clz, o);
7228         return (uint64_t)res_ptr;
7229 }
7230 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
7231         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7232         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7233         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7234         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
7235         return ret_conv;
7236 }
7237
7238 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
7239         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7240         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7241         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7242         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
7243         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7244         Str_free(ret_str);
7245         return ret_conv;
7246 }
7247
7248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
7249         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7250         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7251         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7252         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7253         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7254         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7255         CVec_u8Z_free(ret_var);
7256         return ret_arr;
7257 }
7258
7259 static jclass LDKCOption_TypeZ_Some_class = NULL;
7260 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
7261 static jclass LDKCOption_TypeZ_None_class = NULL;
7262 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
7263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
7264         LDKCOption_TypeZ_Some_class =
7265                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
7266         CHECK(LDKCOption_TypeZ_Some_class != NULL);
7267         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
7268         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
7269         LDKCOption_TypeZ_None_class =
7270                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
7271         CHECK(LDKCOption_TypeZ_None_class != NULL);
7272         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
7273         CHECK(LDKCOption_TypeZ_None_meth != NULL);
7274 }
7275 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7276         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
7277         switch(obj->tag) {
7278                 case LDKCOption_TypeZ_Some: {
7279                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
7280                         *some_ret = Type_clone(&obj->some);
7281                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (int64_t)some_ret);
7282                 }
7283                 case LDKCOption_TypeZ_None: {
7284                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
7285                 }
7286                 default: abort();
7287         }
7288 }
7289 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7290 CHECK(owner->result_ok);
7291         return COption_TypeZ_clone(&*owner->contents.result);
7292 }
7293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7294         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
7295         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
7296         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
7297         int64_t ret_ref = (uintptr_t)ret_copy;
7298         return ret_ref;
7299 }
7300
7301 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7302 CHECK(!owner->result_ok);
7303         return DecodeError_clone(&*owner->contents.err);
7304 }
7305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7306         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
7307         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
7308         int64_t ret_ref = 0;
7309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7312         ret_ref = (uintptr_t)ret_var.inner;
7313         if (ret_var.is_owned) {
7314                 ret_ref |= 1;
7315         }
7316         return ret_ref;
7317 }
7318
7319 static jclass LDKPaymentError_Invoice_class = NULL;
7320 static jmethodID LDKPaymentError_Invoice_meth = NULL;
7321 static jclass LDKPaymentError_Routing_class = NULL;
7322 static jmethodID LDKPaymentError_Routing_meth = NULL;
7323 static jclass LDKPaymentError_Sending_class = NULL;
7324 static jmethodID LDKPaymentError_Sending_meth = NULL;
7325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
7326         LDKPaymentError_Invoice_class =
7327                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
7328         CHECK(LDKPaymentError_Invoice_class != NULL);
7329         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
7330         CHECK(LDKPaymentError_Invoice_meth != NULL);
7331         LDKPaymentError_Routing_class =
7332                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
7333         CHECK(LDKPaymentError_Routing_class != NULL);
7334         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
7335         CHECK(LDKPaymentError_Routing_meth != NULL);
7336         LDKPaymentError_Sending_class =
7337                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
7338         CHECK(LDKPaymentError_Sending_class != NULL);
7339         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
7340         CHECK(LDKPaymentError_Sending_meth != NULL);
7341 }
7342 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7343         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
7344         switch(obj->tag) {
7345                 case LDKPaymentError_Invoice: {
7346                         LDKStr invoice_str = obj->invoice;
7347                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
7348                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
7349                 }
7350                 case LDKPaymentError_Routing: {
7351                         LDKLightningError routing_var = obj->routing;
7352                         int64_t routing_ref = 0;
7353                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7354                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7355                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
7356                         routing_ref = (uintptr_t)routing_var.inner & ~1;
7357                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
7358                 }
7359                 case LDKPaymentError_Sending: {
7360                         int64_t sending_ref = ((uintptr_t)&obj->sending) | 1;
7361                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
7362                 }
7363                 default: abort();
7364         }
7365 }
7366 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7367 CHECK(owner->result_ok);
7368         return ThirtyTwoBytes_clone(&*owner->contents.result);
7369 }
7370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7371         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
7372         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7373         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
7374         return ret_arr;
7375 }
7376
7377 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7378 CHECK(!owner->result_ok);
7379         return PaymentError_clone(&*owner->contents.err);
7380 }
7381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7382         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
7383         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
7384         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
7385         int64_t ret_ref = (uintptr_t)ret_copy;
7386         return ret_ref;
7387 }
7388
7389 static jclass LDKParseError_Bech32Error_class = NULL;
7390 static jmethodID LDKParseError_Bech32Error_meth = NULL;
7391 static jclass LDKParseError_ParseAmountError_class = NULL;
7392 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
7393 static jclass LDKParseError_MalformedSignature_class = NULL;
7394 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
7395 static jclass LDKParseError_BadPrefix_class = NULL;
7396 static jmethodID LDKParseError_BadPrefix_meth = NULL;
7397 static jclass LDKParseError_UnknownCurrency_class = NULL;
7398 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
7399 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
7400 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
7401 static jclass LDKParseError_MalformedHRP_class = NULL;
7402 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
7403 static jclass LDKParseError_TooShortDataPart_class = NULL;
7404 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
7405 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
7406 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
7407 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
7408 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
7409 static jclass LDKParseError_PaddingError_class = NULL;
7410 static jmethodID LDKParseError_PaddingError_meth = NULL;
7411 static jclass LDKParseError_IntegerOverflowError_class = NULL;
7412 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
7413 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
7414 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
7415 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
7416 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
7417 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
7418 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
7419 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
7420 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
7421 static jclass LDKParseError_InvalidSliceLength_class = NULL;
7422 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
7423 static jclass LDKParseError_Skip_class = NULL;
7424 static jmethodID LDKParseError_Skip_meth = NULL;
7425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
7426         LDKParseError_Bech32Error_class =
7427                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
7428         CHECK(LDKParseError_Bech32Error_class != NULL);
7429         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
7430         CHECK(LDKParseError_Bech32Error_meth != NULL);
7431         LDKParseError_ParseAmountError_class =
7432                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
7433         CHECK(LDKParseError_ParseAmountError_class != NULL);
7434         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
7435         CHECK(LDKParseError_ParseAmountError_meth != NULL);
7436         LDKParseError_MalformedSignature_class =
7437                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
7438         CHECK(LDKParseError_MalformedSignature_class != NULL);
7439         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
7440         CHECK(LDKParseError_MalformedSignature_meth != NULL);
7441         LDKParseError_BadPrefix_class =
7442                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
7443         CHECK(LDKParseError_BadPrefix_class != NULL);
7444         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
7445         CHECK(LDKParseError_BadPrefix_meth != NULL);
7446         LDKParseError_UnknownCurrency_class =
7447                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
7448         CHECK(LDKParseError_UnknownCurrency_class != NULL);
7449         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
7450         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
7451         LDKParseError_UnknownSiPrefix_class =
7452                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
7453         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
7454         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
7455         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
7456         LDKParseError_MalformedHRP_class =
7457                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
7458         CHECK(LDKParseError_MalformedHRP_class != NULL);
7459         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
7460         CHECK(LDKParseError_MalformedHRP_meth != NULL);
7461         LDKParseError_TooShortDataPart_class =
7462                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
7463         CHECK(LDKParseError_TooShortDataPart_class != NULL);
7464         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
7465         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
7466         LDKParseError_UnexpectedEndOfTaggedFields_class =
7467                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
7468         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
7469         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
7470         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
7471         LDKParseError_DescriptionDecodeError_class =
7472                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
7473         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
7474         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
7475         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
7476         LDKParseError_PaddingError_class =
7477                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
7478         CHECK(LDKParseError_PaddingError_class != NULL);
7479         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
7480         CHECK(LDKParseError_PaddingError_meth != NULL);
7481         LDKParseError_IntegerOverflowError_class =
7482                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
7483         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
7484         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
7485         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
7486         LDKParseError_InvalidSegWitProgramLength_class =
7487                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
7488         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
7489         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
7490         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
7491         LDKParseError_InvalidPubKeyHashLength_class =
7492                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
7493         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
7494         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
7495         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
7496         LDKParseError_InvalidScriptHashLength_class =
7497                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
7498         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
7499         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
7500         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
7501         LDKParseError_InvalidRecoveryId_class =
7502                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
7503         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
7504         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
7505         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
7506         LDKParseError_InvalidSliceLength_class =
7507                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
7508         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
7509         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
7510         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
7511         LDKParseError_Skip_class =
7512                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
7513         CHECK(LDKParseError_Skip_class != NULL);
7514         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
7515         CHECK(LDKParseError_Skip_meth != NULL);
7516 }
7517 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7518         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
7519         switch(obj->tag) {
7520                 case LDKParseError_Bech32Error: {
7521                         int64_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
7522                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
7523                 }
7524                 case LDKParseError_ParseAmountError: {
7525                         /*obj->parse_amount_error*/
7526                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
7527                 }
7528                 case LDKParseError_MalformedSignature: {
7529                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
7530                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
7531                 }
7532                 case LDKParseError_BadPrefix: {
7533                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
7534                 }
7535                 case LDKParseError_UnknownCurrency: {
7536                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
7537                 }
7538                 case LDKParseError_UnknownSiPrefix: {
7539                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
7540                 }
7541                 case LDKParseError_MalformedHRP: {
7542                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
7543                 }
7544                 case LDKParseError_TooShortDataPart: {
7545                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
7546                 }
7547                 case LDKParseError_UnexpectedEndOfTaggedFields: {
7548                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
7549                 }
7550                 case LDKParseError_DescriptionDecodeError: {
7551                         /*obj->description_decode_error*/
7552                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
7553                 }
7554                 case LDKParseError_PaddingError: {
7555                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
7556                 }
7557                 case LDKParseError_IntegerOverflowError: {
7558                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
7559                 }
7560                 case LDKParseError_InvalidSegWitProgramLength: {
7561                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
7562                 }
7563                 case LDKParseError_InvalidPubKeyHashLength: {
7564                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
7565                 }
7566                 case LDKParseError_InvalidScriptHashLength: {
7567                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
7568                 }
7569                 case LDKParseError_InvalidRecoveryId: {
7570                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
7571                 }
7572                 case LDKParseError_InvalidSliceLength: {
7573                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
7574                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
7575                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
7576                 }
7577                 case LDKParseError_Skip: {
7578                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
7579                 }
7580                 default: abort();
7581         }
7582 }
7583 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7584 CHECK(owner->result_ok);
7585         return SiPrefix_clone(&*owner->contents.result);
7586 }
7587 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7588         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
7589         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
7590         return ret_conv;
7591 }
7592
7593 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7594 CHECK(!owner->result_ok);
7595         return ParseError_clone(&*owner->contents.err);
7596 }
7597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7598         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
7599         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7600         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
7601         int64_t ret_ref = (uintptr_t)ret_copy;
7602         return ret_ref;
7603 }
7604
7605 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
7606 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
7607 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
7608 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
7609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
7610         LDKParseOrSemanticError_ParseError_class =
7611                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
7612         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
7613         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
7614         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
7615         LDKParseOrSemanticError_SemanticError_class =
7616                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
7617         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
7618         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
7619         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
7620 }
7621 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7622         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
7623         switch(obj->tag) {
7624                 case LDKParseOrSemanticError_ParseError: {
7625                         int64_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
7626                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
7627                 }
7628                 case LDKParseOrSemanticError_SemanticError: {
7629                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
7630                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
7631                 }
7632                 default: abort();
7633         }
7634 }
7635 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7636 CHECK(owner->result_ok);
7637         return Invoice_clone(&*owner->contents.result);
7638 }
7639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7640         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7641         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
7642         int64_t ret_ref = 0;
7643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7646         ret_ref = (uintptr_t)ret_var.inner;
7647         if (ret_var.is_owned) {
7648                 ret_ref |= 1;
7649         }
7650         return ret_ref;
7651 }
7652
7653 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7654 CHECK(!owner->result_ok);
7655         return ParseOrSemanticError_clone(&*owner->contents.err);
7656 }
7657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7658         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7659         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
7660         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
7661         int64_t ret_ref = (uintptr_t)ret_copy;
7662         return ret_ref;
7663 }
7664
7665 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7666 CHECK(owner->result_ok);
7667         return SignedRawInvoice_clone(&*owner->contents.result);
7668 }
7669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7670         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7671         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
7672         int64_t ret_ref = 0;
7673         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7674         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7676         ret_ref = (uintptr_t)ret_var.inner;
7677         if (ret_var.is_owned) {
7678                 ret_ref |= 1;
7679         }
7680         return ret_ref;
7681 }
7682
7683 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7684 CHECK(!owner->result_ok);
7685         return ParseError_clone(&*owner->contents.err);
7686 }
7687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7688         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7689         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7690         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
7691         int64_t ret_ref = (uintptr_t)ret_copy;
7692         return ret_ref;
7693 }
7694
7695 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7696         return RawInvoice_clone(&owner->a);
7697 }
7698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7699         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7700         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
7701         int64_t ret_ref = 0;
7702         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7703         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7705         ret_ref = (uintptr_t)ret_var.inner;
7706         if (ret_var.is_owned) {
7707                 ret_ref |= 1;
7708         }
7709         return ret_ref;
7710 }
7711
7712 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7713         return ThirtyTwoBytes_clone(&owner->b);
7714 }
7715 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7716         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7717         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7718         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
7719         return ret_arr;
7720 }
7721
7722 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7723         return InvoiceSignature_clone(&owner->c);
7724 }
7725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
7726         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7727         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
7728         int64_t ret_ref = 0;
7729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7732         ret_ref = (uintptr_t)ret_var.inner;
7733         if (ret_var.is_owned) {
7734                 ret_ref |= 1;
7735         }
7736         return ret_ref;
7737 }
7738
7739 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7740 CHECK(owner->result_ok);
7741         return PayeePubKey_clone(&*owner->contents.result);
7742 }
7743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7744         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
7745         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
7746         int64_t ret_ref = 0;
7747         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7748         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7750         ret_ref = (uintptr_t)ret_var.inner;
7751         if (ret_var.is_owned) {
7752                 ret_ref |= 1;
7753         }
7754         return ret_ref;
7755 }
7756
7757 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7758 CHECK(!owner->result_ok);
7759         return *owner->contents.err;
7760 }
7761 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7762         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
7763         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
7764         return ret_conv;
7765 }
7766
7767 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
7768         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
7769         for (size_t i = 0; i < ret.datalen; i++) {
7770                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
7771         }
7772         return ret;
7773 }
7774 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7775 CHECK(owner->result_ok);
7776         return PositiveTimestamp_clone(&*owner->contents.result);
7777 }
7778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7779         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
7780         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
7781         int64_t ret_ref = 0;
7782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7785         ret_ref = (uintptr_t)ret_var.inner;
7786         if (ret_var.is_owned) {
7787                 ret_ref |= 1;
7788         }
7789         return ret_ref;
7790 }
7791
7792 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7793 CHECK(!owner->result_ok);
7794         return CreationError_clone(&*owner->contents.err);
7795 }
7796 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7797         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
7798         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
7799         return ret_conv;
7800 }
7801
7802 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7803 CHECK(owner->result_ok);
7804         return *owner->contents.result;
7805 }
7806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7807         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
7808         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
7809 }
7810
7811 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7812 CHECK(!owner->result_ok);
7813         return SemanticError_clone(&*owner->contents.err);
7814 }
7815 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7816         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
7817         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
7818         return ret_conv;
7819 }
7820
7821 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7822 CHECK(owner->result_ok);
7823         return Invoice_clone(&*owner->contents.result);
7824 }
7825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7826         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
7827         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
7828         int64_t ret_ref = 0;
7829         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7830         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7832         ret_ref = (uintptr_t)ret_var.inner;
7833         if (ret_var.is_owned) {
7834                 ret_ref |= 1;
7835         }
7836         return ret_ref;
7837 }
7838
7839 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7840 CHECK(!owner->result_ok);
7841         return SemanticError_clone(&*owner->contents.err);
7842 }
7843 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7844         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
7845         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
7846         return ret_conv;
7847 }
7848
7849 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7850 CHECK(owner->result_ok);
7851         return Description_clone(&*owner->contents.result);
7852 }
7853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7854         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
7855         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
7856         int64_t ret_ref = 0;
7857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7860         ret_ref = (uintptr_t)ret_var.inner;
7861         if (ret_var.is_owned) {
7862                 ret_ref |= 1;
7863         }
7864         return ret_ref;
7865 }
7866
7867 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7868 CHECK(!owner->result_ok);
7869         return CreationError_clone(&*owner->contents.err);
7870 }
7871 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7872         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
7873         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
7874         return ret_conv;
7875 }
7876
7877 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7878 CHECK(owner->result_ok);
7879         return PrivateRoute_clone(&*owner->contents.result);
7880 }
7881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7882         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
7883         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
7884         int64_t ret_ref = 0;
7885         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7886         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7888         ret_ref = (uintptr_t)ret_var.inner;
7889         if (ret_var.is_owned) {
7890                 ret_ref |= 1;
7891         }
7892         return ret_ref;
7893 }
7894
7895 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7896 CHECK(!owner->result_ok);
7897         return CreationError_clone(&*owner->contents.err);
7898 }
7899 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7900         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
7901         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
7902         return ret_conv;
7903 }
7904
7905 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
7906 CHECK(owner->result_ok);
7907         return *owner->contents.result;
7908 }
7909 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7910         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
7911         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
7912         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7913         return ret_conv;
7914 }
7915
7916 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
7917 CHECK(!owner->result_ok);
7918         return *owner->contents.err;
7919 }
7920 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7921         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
7922         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
7923         return ret_conv;
7924 }
7925
7926 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
7927 CHECK(owner->result_ok);
7928         return ChannelMonitorUpdate_clone(&*owner->contents.result);
7929 }
7930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7931         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
7932         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
7933         int64_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_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *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_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7949         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
7950         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
7951         int64_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 jclass LDKCOption_MonitorEventZ_Some_class = NULL;
7963 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
7964 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
7965 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
7966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
7967         LDKCOption_MonitorEventZ_Some_class =
7968                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
7969         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
7970         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
7971         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
7972         LDKCOption_MonitorEventZ_None_class =
7973                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
7974         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
7975         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
7976         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
7977 }
7978 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7979         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
7980         switch(obj->tag) {
7981                 case LDKCOption_MonitorEventZ_Some: {
7982                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
7983                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
7984                 }
7985                 case LDKCOption_MonitorEventZ_None: {
7986                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
7987                 }
7988                 default: abort();
7989         }
7990 }
7991 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7992 CHECK(owner->result_ok);
7993         return COption_MonitorEventZ_clone(&*owner->contents.result);
7994 }
7995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7996         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
7997         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
7998         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
7999         int64_t ret_ref = (uintptr_t)ret_copy;
8000         return ret_ref;
8001 }
8002
8003 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8004 CHECK(!owner->result_ok);
8005         return DecodeError_clone(&*owner->contents.err);
8006 }
8007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8008         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
8009         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
8010         int64_t ret_ref = 0;
8011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8014         ret_ref = (uintptr_t)ret_var.inner;
8015         if (ret_var.is_owned) {
8016                 ret_ref |= 1;
8017         }
8018         return ret_ref;
8019 }
8020
8021 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8022 CHECK(owner->result_ok);
8023         return HTLCUpdate_clone(&*owner->contents.result);
8024 }
8025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8026         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
8027         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
8028         int64_t ret_ref = 0;
8029         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8030         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8031         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8032         ret_ref = (uintptr_t)ret_var.inner;
8033         if (ret_var.is_owned) {
8034                 ret_ref |= 1;
8035         }
8036         return ret_ref;
8037 }
8038
8039 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8040 CHECK(!owner->result_ok);
8041         return DecodeError_clone(&*owner->contents.err);
8042 }
8043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8044         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
8045         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
8046         int64_t ret_ref = 0;
8047         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8048         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8049         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8050         ret_ref = (uintptr_t)ret_var.inner;
8051         if (ret_var.is_owned) {
8052                 ret_ref |= 1;
8053         }
8054         return ret_ref;
8055 }
8056
8057 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8058         return OutPoint_clone(&owner->a);
8059 }
8060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8061         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
8062         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
8063         int64_t ret_ref = 0;
8064         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8065         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8067         ret_ref = (uintptr_t)ret_var.inner;
8068         if (ret_var.is_owned) {
8069                 ret_ref |= 1;
8070         }
8071         return ret_ref;
8072 }
8073
8074 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8075         return CVec_u8Z_clone(&owner->b);
8076 }
8077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8078         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
8079         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
8080         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8081         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8082         CVec_u8Z_free(ret_var);
8083         return ret_arr;
8084 }
8085
8086 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8087         return owner->a;
8088 }
8089 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8090         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
8091         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
8092         return ret_conv;
8093 }
8094
8095 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8096         return CVec_u8Z_clone(&owner->b);
8097 }
8098 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8099         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
8100         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
8101         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8102         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8103         CVec_u8Z_free(ret_var);
8104         return ret_arr;
8105 }
8106
8107 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
8108         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
8109         for (size_t i = 0; i < ret.datalen; i++) {
8110                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
8111         }
8112         return ret;
8113 }
8114 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8115         return ThirtyTwoBytes_clone(&owner->a);
8116 }
8117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8118         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
8119         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8120         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
8121         return ret_arr;
8122 }
8123
8124 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8125         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
8126 }
8127 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8128         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
8129         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
8130         int64_tArray ret_arr = NULL;
8131         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8132         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8133         for (size_t v = 0; v < ret_var.datalen; v++) {
8134                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8135                 *ret_conv_21_conv = ret_var.data[v];
8136                 ret_arr_ptr[v] = ((int64_t)ret_conv_21_conv);
8137         }
8138         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8139         FREE(ret_var.data);
8140         return ret_arr;
8141 }
8142
8143 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
8144         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 };
8145         for (size_t i = 0; i < ret.datalen; i++) {
8146                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
8147         }
8148         return ret;
8149 }
8150 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
8151         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
8152         for (size_t i = 0; i < ret.datalen; i++) {
8153                 ret.data[i] = Event_clone(&orig->data[i]);
8154         }
8155         return ret;
8156 }
8157 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8158         return owner->a;
8159 }
8160 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8161         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
8162         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
8163         return ret_conv;
8164 }
8165
8166 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8167         return TxOut_clone(&owner->b);
8168 }
8169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8170         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
8171         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8172         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
8173         return (int64_t)ret_ref;
8174 }
8175
8176 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
8177         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
8178         for (size_t i = 0; i < ret.datalen; i++) {
8179                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
8180         }
8181         return ret;
8182 }
8183 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8184         return ThirtyTwoBytes_clone(&owner->a);
8185 }
8186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8187         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
8188         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8189         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
8190         return ret_arr;
8191 }
8192
8193 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8194         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
8195 }
8196 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8197         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
8198         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
8199         int64_tArray ret_arr = NULL;
8200         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8201         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8202         for (size_t u = 0; u < ret_var.datalen; u++) {
8203                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8204                 *ret_conv_20_conv = ret_var.data[u];
8205                 ret_arr_ptr[u] = ((int64_t)ret_conv_20_conv);
8206         }
8207         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8208         FREE(ret_var.data);
8209         return ret_arr;
8210 }
8211
8212 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
8213         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 };
8214         for (size_t i = 0; i < ret.datalen; i++) {
8215                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
8216         }
8217         return ret;
8218 }
8219 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
8220 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
8221 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
8222 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
8223 static jclass LDKBalance_ContentiousClaimable_class = NULL;
8224 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
8225 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
8226 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
8227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
8228         LDKBalance_ClaimableOnChannelClose_class =
8229                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
8230         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
8231         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
8232         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
8233         LDKBalance_ClaimableAwaitingConfirmations_class =
8234                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
8235         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
8236         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
8237         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
8238         LDKBalance_ContentiousClaimable_class =
8239                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
8240         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
8241         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
8242         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
8243         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
8244                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
8245         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
8246         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
8247         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
8248 }
8249 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8250         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
8251         switch(obj->tag) {
8252                 case LDKBalance_ClaimableOnChannelClose: {
8253                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
8254                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
8255                 }
8256                 case LDKBalance_ClaimableAwaitingConfirmations: {
8257                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
8258                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
8259                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
8260                 }
8261                 case LDKBalance_ContentiousClaimable: {
8262                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
8263                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
8264                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
8265                 }
8266                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
8267                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
8268                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
8269                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, claimable_amount_satoshis_conv, claimable_height_conv);
8270                 }
8271                 default: abort();
8272         }
8273 }
8274 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
8275         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
8276         for (size_t i = 0; i < ret.datalen; i++) {
8277                 ret.data[i] = Balance_clone(&orig->data[i]);
8278         }
8279         return ret;
8280 }
8281 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8282 CHECK(owner->result_ok);
8283         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
8284 }
8285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8286         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
8287         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8288         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
8289         return ((int64_t)ret_conv);
8290 }
8291
8292 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8293 CHECK(!owner->result_ok);
8294         return DecodeError_clone(&*owner->contents.err);
8295 }
8296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8297         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
8298         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
8299         int64_t ret_ref = 0;
8300         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8301         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8303         ret_ref = (uintptr_t)ret_var.inner;
8304         if (ret_var.is_owned) {
8305                 ret_ref |= 1;
8306         }
8307         return ret_ref;
8308 }
8309
8310 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8311         return owner->a;
8312 }
8313 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8314         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
8315         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
8316         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
8317         return ret_arr;
8318 }
8319
8320 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8321         return Type_clone(&owner->b);
8322 }
8323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8324         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
8325         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
8326         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
8327         return (int64_t)ret_ret;
8328 }
8329
8330 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
8331         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
8332         for (size_t i = 0; i < ret.datalen; i++) {
8333                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
8334         }
8335         return ret;
8336 }
8337 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
8338 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
8339 static jclass LDKCOption_NetAddressZ_None_class = NULL;
8340 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
8341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
8342         LDKCOption_NetAddressZ_Some_class =
8343                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
8344         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
8345         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
8346         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
8347         LDKCOption_NetAddressZ_None_class =
8348                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
8349         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
8350         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
8351         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
8352 }
8353 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8354         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
8355         switch(obj->tag) {
8356                 case LDKCOption_NetAddressZ_Some: {
8357                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
8358                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
8359                 }
8360                 case LDKCOption_NetAddressZ_None: {
8361                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
8362                 }
8363                 default: abort();
8364         }
8365 }
8366 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8367 CHECK(owner->result_ok);
8368         return CVec_u8Z_clone(&*owner->contents.result);
8369 }
8370 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8371         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
8372         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
8373         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8374         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8375         CVec_u8Z_free(ret_var);
8376         return ret_arr;
8377 }
8378
8379 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8380 CHECK(!owner->result_ok);
8381         return PeerHandleError_clone(&*owner->contents.err);
8382 }
8383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8384         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
8385         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
8386         int64_t ret_ref = 0;
8387         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8388         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8390         ret_ref = (uintptr_t)ret_var.inner;
8391         if (ret_var.is_owned) {
8392                 ret_ref |= 1;
8393         }
8394         return ret_ref;
8395 }
8396
8397 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8398 CHECK(owner->result_ok);
8399         return *owner->contents.result;
8400 }
8401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8402         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
8403         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
8404 }
8405
8406 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8407 CHECK(!owner->result_ok);
8408         return PeerHandleError_clone(&*owner->contents.err);
8409 }
8410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8411         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
8412         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
8413         int64_t ret_ref = 0;
8414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8417         ret_ref = (uintptr_t)ret_var.inner;
8418         if (ret_var.is_owned) {
8419                 ret_ref |= 1;
8420         }
8421         return ret_ref;
8422 }
8423
8424 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8425 CHECK(owner->result_ok);
8426         return *owner->contents.result;
8427 }
8428 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8429         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
8430         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
8431         return ret_conv;
8432 }
8433
8434 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8435 CHECK(!owner->result_ok);
8436         return PeerHandleError_clone(&*owner->contents.err);
8437 }
8438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8439         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
8440         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
8441         int64_t ret_ref = 0;
8442         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8443         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8445         ret_ref = (uintptr_t)ret_var.inner;
8446         if (ret_var.is_owned) {
8447                 ret_ref |= 1;
8448         }
8449         return ret_ref;
8450 }
8451
8452 static jclass LDKGraphSyncError_DecodeError_class = NULL;
8453 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
8454 static jclass LDKGraphSyncError_LightningError_class = NULL;
8455 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
8456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
8457         LDKGraphSyncError_DecodeError_class =
8458                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
8459         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
8460         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
8461         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
8462         LDKGraphSyncError_LightningError_class =
8463                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
8464         CHECK(LDKGraphSyncError_LightningError_class != NULL);
8465         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
8466         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
8467 }
8468 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8469         LDKGraphSyncError *obj = (LDKGraphSyncError*)(ptr & ~1);
8470         switch(obj->tag) {
8471                 case LDKGraphSyncError_DecodeError: {
8472                         LDKDecodeError decode_error_var = obj->decode_error;
8473                         int64_t decode_error_ref = 0;
8474                         CHECK((((uintptr_t)decode_error_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8475                         CHECK((((uintptr_t)&decode_error_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8476                         CHECK_INNER_FIELD_ACCESS_OR_NULL(decode_error_var);
8477                         decode_error_ref = (uintptr_t)decode_error_var.inner & ~1;
8478                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
8479                 }
8480                 case LDKGraphSyncError_LightningError: {
8481                         LDKLightningError lightning_error_var = obj->lightning_error;
8482                         int64_t lightning_error_ref = 0;
8483                         CHECK((((uintptr_t)lightning_error_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8484                         CHECK((((uintptr_t)&lightning_error_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8485                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
8486                         lightning_error_ref = (uintptr_t)lightning_error_var.inner & ~1;
8487                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
8488                 }
8489                 default: abort();
8490         }
8491 }
8492 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8493 CHECK(owner->result_ok);
8494         return *owner->contents.result;
8495 }
8496 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8497         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)(owner & ~1);
8498         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
8499         return ret_conv;
8500 }
8501
8502 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8503 CHECK(!owner->result_ok);
8504         return GraphSyncError_clone(&*owner->contents.err);
8505 }
8506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8507         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)(owner & ~1);
8508         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
8509         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
8510         int64_t ret_ref = (uintptr_t)ret_copy;
8511         return ret_ref;
8512 }
8513
8514 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8515 CHECK(owner->result_ok);
8516         return NetAddress_clone(&*owner->contents.result);
8517 }
8518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8519         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8520         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
8521         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
8522         int64_t ret_ref = (uintptr_t)ret_copy;
8523         return ret_ref;
8524 }
8525
8526 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8527 CHECK(!owner->result_ok);
8528         return DecodeError_clone(&*owner->contents.err);
8529 }
8530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8531         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8532         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
8533         int64_t ret_ref = 0;
8534         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8535         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8537         ret_ref = (uintptr_t)ret_var.inner;
8538         if (ret_var.is_owned) {
8539                 ret_ref |= 1;
8540         }
8541         return ret_ref;
8542 }
8543
8544 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8545         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8546         for (size_t i = 0; i < ret.datalen; i++) {
8547                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8548         }
8549         return ret;
8550 }
8551 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8552         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8553         for (size_t i = 0; i < ret.datalen; i++) {
8554                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8555         }
8556         return ret;
8557 }
8558 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8559         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8560         for (size_t i = 0; i < ret.datalen; i++) {
8561                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8562         }
8563         return ret;
8564 }
8565 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8566         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8567         for (size_t i = 0; i < ret.datalen; i++) {
8568                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8569         }
8570         return ret;
8571 }
8572 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8573 CHECK(owner->result_ok);
8574         return AcceptChannel_clone(&*owner->contents.result);
8575 }
8576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8577         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8578         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8579         int64_t ret_ref = 0;
8580         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8581         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8583         ret_ref = (uintptr_t)ret_var.inner;
8584         if (ret_var.is_owned) {
8585                 ret_ref |= 1;
8586         }
8587         return ret_ref;
8588 }
8589
8590 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8591 CHECK(!owner->result_ok);
8592         return DecodeError_clone(&*owner->contents.err);
8593 }
8594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8595         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8596         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8597         int64_t ret_ref = 0;
8598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8601         ret_ref = (uintptr_t)ret_var.inner;
8602         if (ret_var.is_owned) {
8603                 ret_ref |= 1;
8604         }
8605         return ret_ref;
8606 }
8607
8608 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8609 CHECK(owner->result_ok);
8610         return AnnouncementSignatures_clone(&*owner->contents.result);
8611 }
8612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8613         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8614         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8615         int64_t ret_ref = 0;
8616         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8617         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8619         ret_ref = (uintptr_t)ret_var.inner;
8620         if (ret_var.is_owned) {
8621                 ret_ref |= 1;
8622         }
8623         return ret_ref;
8624 }
8625
8626 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8627 CHECK(!owner->result_ok);
8628         return DecodeError_clone(&*owner->contents.err);
8629 }
8630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8631         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8632         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8633         int64_t ret_ref = 0;
8634         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8635         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8637         ret_ref = (uintptr_t)ret_var.inner;
8638         if (ret_var.is_owned) {
8639                 ret_ref |= 1;
8640         }
8641         return ret_ref;
8642 }
8643
8644 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8645 CHECK(owner->result_ok);
8646         return ChannelReestablish_clone(&*owner->contents.result);
8647 }
8648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8649         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8650         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
8651         int64_t ret_ref = 0;
8652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8655         ret_ref = (uintptr_t)ret_var.inner;
8656         if (ret_var.is_owned) {
8657                 ret_ref |= 1;
8658         }
8659         return ret_ref;
8660 }
8661
8662 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8663 CHECK(!owner->result_ok);
8664         return DecodeError_clone(&*owner->contents.err);
8665 }
8666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8667         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8668         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8669         int64_t ret_ref = 0;
8670         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8671         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8673         ret_ref = (uintptr_t)ret_var.inner;
8674         if (ret_var.is_owned) {
8675                 ret_ref |= 1;
8676         }
8677         return ret_ref;
8678 }
8679
8680 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8681 CHECK(owner->result_ok);
8682         return ClosingSigned_clone(&*owner->contents.result);
8683 }
8684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8685         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8686         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8687         int64_t ret_ref = 0;
8688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8691         ret_ref = (uintptr_t)ret_var.inner;
8692         if (ret_var.is_owned) {
8693                 ret_ref |= 1;
8694         }
8695         return ret_ref;
8696 }
8697
8698 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8699 CHECK(!owner->result_ok);
8700         return DecodeError_clone(&*owner->contents.err);
8701 }
8702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8703         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8704         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
8705         int64_t ret_ref = 0;
8706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8709         ret_ref = (uintptr_t)ret_var.inner;
8710         if (ret_var.is_owned) {
8711                 ret_ref |= 1;
8712         }
8713         return ret_ref;
8714 }
8715
8716 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8717 CHECK(owner->result_ok);
8718         return ClosingSignedFeeRange_clone(&*owner->contents.result);
8719 }
8720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8721         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8722         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
8723         int64_t ret_ref = 0;
8724         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8725         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8727         ret_ref = (uintptr_t)ret_var.inner;
8728         if (ret_var.is_owned) {
8729                 ret_ref |= 1;
8730         }
8731         return ret_ref;
8732 }
8733
8734 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8735 CHECK(!owner->result_ok);
8736         return DecodeError_clone(&*owner->contents.err);
8737 }
8738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8739         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8740         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
8741         int64_t ret_ref = 0;
8742         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8743         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8745         ret_ref = (uintptr_t)ret_var.inner;
8746         if (ret_var.is_owned) {
8747                 ret_ref |= 1;
8748         }
8749         return ret_ref;
8750 }
8751
8752 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8753 CHECK(owner->result_ok);
8754         return CommitmentSigned_clone(&*owner->contents.result);
8755 }
8756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8757         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8758         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
8759         int64_t ret_ref = 0;
8760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8763         ret_ref = (uintptr_t)ret_var.inner;
8764         if (ret_var.is_owned) {
8765                 ret_ref |= 1;
8766         }
8767         return ret_ref;
8768 }
8769
8770 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8771 CHECK(!owner->result_ok);
8772         return DecodeError_clone(&*owner->contents.err);
8773 }
8774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8775         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8776         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
8777         int64_t ret_ref = 0;
8778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8781         ret_ref = (uintptr_t)ret_var.inner;
8782         if (ret_var.is_owned) {
8783                 ret_ref |= 1;
8784         }
8785         return ret_ref;
8786 }
8787
8788 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8789 CHECK(owner->result_ok);
8790         return FundingCreated_clone(&*owner->contents.result);
8791 }
8792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8793         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8794         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
8795         int64_t ret_ref = 0;
8796         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8797         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8799         ret_ref = (uintptr_t)ret_var.inner;
8800         if (ret_var.is_owned) {
8801                 ret_ref |= 1;
8802         }
8803         return ret_ref;
8804 }
8805
8806 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8807 CHECK(!owner->result_ok);
8808         return DecodeError_clone(&*owner->contents.err);
8809 }
8810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8811         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8812         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
8813         int64_t ret_ref = 0;
8814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8817         ret_ref = (uintptr_t)ret_var.inner;
8818         if (ret_var.is_owned) {
8819                 ret_ref |= 1;
8820         }
8821         return ret_ref;
8822 }
8823
8824 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8825 CHECK(owner->result_ok);
8826         return FundingSigned_clone(&*owner->contents.result);
8827 }
8828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8829         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8830         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
8831         int64_t ret_ref = 0;
8832         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8833         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8835         ret_ref = (uintptr_t)ret_var.inner;
8836         if (ret_var.is_owned) {
8837                 ret_ref |= 1;
8838         }
8839         return ret_ref;
8840 }
8841
8842 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8843 CHECK(!owner->result_ok);
8844         return DecodeError_clone(&*owner->contents.err);
8845 }
8846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8847         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8848         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
8849         int64_t ret_ref = 0;
8850         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8851         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8853         ret_ref = (uintptr_t)ret_var.inner;
8854         if (ret_var.is_owned) {
8855                 ret_ref |= 1;
8856         }
8857         return ret_ref;
8858 }
8859
8860 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
8861 CHECK(owner->result_ok);
8862         return ChannelReady_clone(&*owner->contents.result);
8863 }
8864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8865         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
8866         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
8867         int64_t ret_ref = 0;
8868         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8869         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8871         ret_ref = (uintptr_t)ret_var.inner;
8872         if (ret_var.is_owned) {
8873                 ret_ref |= 1;
8874         }
8875         return ret_ref;
8876 }
8877
8878 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
8879 CHECK(!owner->result_ok);
8880         return DecodeError_clone(&*owner->contents.err);
8881 }
8882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8883         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
8884         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
8885         int64_t ret_ref = 0;
8886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8889         ret_ref = (uintptr_t)ret_var.inner;
8890         if (ret_var.is_owned) {
8891                 ret_ref |= 1;
8892         }
8893         return ret_ref;
8894 }
8895
8896 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8897 CHECK(owner->result_ok);
8898         return Init_clone(&*owner->contents.result);
8899 }
8900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8901         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
8902         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
8903         int64_t ret_ref = 0;
8904         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8905         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8907         ret_ref = (uintptr_t)ret_var.inner;
8908         if (ret_var.is_owned) {
8909                 ret_ref |= 1;
8910         }
8911         return ret_ref;
8912 }
8913
8914 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8915 CHECK(!owner->result_ok);
8916         return DecodeError_clone(&*owner->contents.err);
8917 }
8918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8919         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
8920         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
8921         int64_t ret_ref = 0;
8922         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8923         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8925         ret_ref = (uintptr_t)ret_var.inner;
8926         if (ret_var.is_owned) {
8927                 ret_ref |= 1;
8928         }
8929         return ret_ref;
8930 }
8931
8932 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8933 CHECK(owner->result_ok);
8934         return OpenChannel_clone(&*owner->contents.result);
8935 }
8936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8937         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8938         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
8939         int64_t ret_ref = 0;
8940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8943         ret_ref = (uintptr_t)ret_var.inner;
8944         if (ret_var.is_owned) {
8945                 ret_ref |= 1;
8946         }
8947         return ret_ref;
8948 }
8949
8950 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8951 CHECK(!owner->result_ok);
8952         return DecodeError_clone(&*owner->contents.err);
8953 }
8954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8955         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8956         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
8957         int64_t ret_ref = 0;
8958         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8959         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8961         ret_ref = (uintptr_t)ret_var.inner;
8962         if (ret_var.is_owned) {
8963                 ret_ref |= 1;
8964         }
8965         return ret_ref;
8966 }
8967
8968 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8969 CHECK(owner->result_ok);
8970         return RevokeAndACK_clone(&*owner->contents.result);
8971 }
8972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8973         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8974         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
8975         int64_t ret_ref = 0;
8976         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8977         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8979         ret_ref = (uintptr_t)ret_var.inner;
8980         if (ret_var.is_owned) {
8981                 ret_ref |= 1;
8982         }
8983         return ret_ref;
8984 }
8985
8986 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8987 CHECK(!owner->result_ok);
8988         return DecodeError_clone(&*owner->contents.err);
8989 }
8990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8991         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8992         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
8993         int64_t ret_ref = 0;
8994         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8995         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8997         ret_ref = (uintptr_t)ret_var.inner;
8998         if (ret_var.is_owned) {
8999                 ret_ref |= 1;
9000         }
9001         return ret_ref;
9002 }
9003
9004 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9005 CHECK(owner->result_ok);
9006         return Shutdown_clone(&*owner->contents.result);
9007 }
9008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9009         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
9010         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
9011         int64_t ret_ref = 0;
9012         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9013         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9015         ret_ref = (uintptr_t)ret_var.inner;
9016         if (ret_var.is_owned) {
9017                 ret_ref |= 1;
9018         }
9019         return ret_ref;
9020 }
9021
9022 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9023 CHECK(!owner->result_ok);
9024         return DecodeError_clone(&*owner->contents.err);
9025 }
9026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9027         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
9028         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
9029         int64_t ret_ref = 0;
9030         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9031         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9033         ret_ref = (uintptr_t)ret_var.inner;
9034         if (ret_var.is_owned) {
9035                 ret_ref |= 1;
9036         }
9037         return ret_ref;
9038 }
9039
9040 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9041 CHECK(owner->result_ok);
9042         return UpdateFailHTLC_clone(&*owner->contents.result);
9043 }
9044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9045         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
9046         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
9047         int64_t ret_ref = 0;
9048         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9049         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9051         ret_ref = (uintptr_t)ret_var.inner;
9052         if (ret_var.is_owned) {
9053                 ret_ref |= 1;
9054         }
9055         return ret_ref;
9056 }
9057
9058 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9059 CHECK(!owner->result_ok);
9060         return DecodeError_clone(&*owner->contents.err);
9061 }
9062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9063         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
9064         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
9065         int64_t ret_ref = 0;
9066         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9067         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9069         ret_ref = (uintptr_t)ret_var.inner;
9070         if (ret_var.is_owned) {
9071                 ret_ref |= 1;
9072         }
9073         return ret_ref;
9074 }
9075
9076 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9077 CHECK(owner->result_ok);
9078         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
9079 }
9080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9081         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9082         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
9083         int64_t ret_ref = 0;
9084         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9085         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9087         ret_ref = (uintptr_t)ret_var.inner;
9088         if (ret_var.is_owned) {
9089                 ret_ref |= 1;
9090         }
9091         return ret_ref;
9092 }
9093
9094 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9095 CHECK(!owner->result_ok);
9096         return DecodeError_clone(&*owner->contents.err);
9097 }
9098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9099         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9100         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
9101         int64_t ret_ref = 0;
9102         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9103         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9105         ret_ref = (uintptr_t)ret_var.inner;
9106         if (ret_var.is_owned) {
9107                 ret_ref |= 1;
9108         }
9109         return ret_ref;
9110 }
9111
9112 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9113 CHECK(owner->result_ok);
9114         return UpdateFee_clone(&*owner->contents.result);
9115 }
9116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9117         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9118         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
9119         int64_t ret_ref = 0;
9120         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9121         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9123         ret_ref = (uintptr_t)ret_var.inner;
9124         if (ret_var.is_owned) {
9125                 ret_ref |= 1;
9126         }
9127         return ret_ref;
9128 }
9129
9130 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9131 CHECK(!owner->result_ok);
9132         return DecodeError_clone(&*owner->contents.err);
9133 }
9134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9135         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9136         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
9137         int64_t ret_ref = 0;
9138         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9139         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9141         ret_ref = (uintptr_t)ret_var.inner;
9142         if (ret_var.is_owned) {
9143                 ret_ref |= 1;
9144         }
9145         return ret_ref;
9146 }
9147
9148 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9149 CHECK(owner->result_ok);
9150         return UpdateFulfillHTLC_clone(&*owner->contents.result);
9151 }
9152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9153         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9154         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
9155         int64_t ret_ref = 0;
9156         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9157         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9159         ret_ref = (uintptr_t)ret_var.inner;
9160         if (ret_var.is_owned) {
9161                 ret_ref |= 1;
9162         }
9163         return ret_ref;
9164 }
9165
9166 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9167 CHECK(!owner->result_ok);
9168         return DecodeError_clone(&*owner->contents.err);
9169 }
9170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9171         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9172         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
9173         int64_t ret_ref = 0;
9174         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9175         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9177         ret_ref = (uintptr_t)ret_var.inner;
9178         if (ret_var.is_owned) {
9179                 ret_ref |= 1;
9180         }
9181         return ret_ref;
9182 }
9183
9184 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9185 CHECK(owner->result_ok);
9186         return UpdateAddHTLC_clone(&*owner->contents.result);
9187 }
9188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9189         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9190         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
9191         int64_t ret_ref = 0;
9192         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9193         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9195         ret_ref = (uintptr_t)ret_var.inner;
9196         if (ret_var.is_owned) {
9197                 ret_ref |= 1;
9198         }
9199         return ret_ref;
9200 }
9201
9202 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9203 CHECK(!owner->result_ok);
9204         return DecodeError_clone(&*owner->contents.err);
9205 }
9206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9207         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9208         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
9209         int64_t ret_ref = 0;
9210         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9211         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9212         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9213         ret_ref = (uintptr_t)ret_var.inner;
9214         if (ret_var.is_owned) {
9215                 ret_ref |= 1;
9216         }
9217         return ret_ref;
9218 }
9219
9220 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9221 CHECK(owner->result_ok);
9222         return Ping_clone(&*owner->contents.result);
9223 }
9224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9225         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9226         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
9227         int64_t ret_ref = 0;
9228         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9229         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9231         ret_ref = (uintptr_t)ret_var.inner;
9232         if (ret_var.is_owned) {
9233                 ret_ref |= 1;
9234         }
9235         return ret_ref;
9236 }
9237
9238 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9239 CHECK(!owner->result_ok);
9240         return DecodeError_clone(&*owner->contents.err);
9241 }
9242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9243         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9244         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
9245         int64_t ret_ref = 0;
9246         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9247         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9249         ret_ref = (uintptr_t)ret_var.inner;
9250         if (ret_var.is_owned) {
9251                 ret_ref |= 1;
9252         }
9253         return ret_ref;
9254 }
9255
9256 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9257 CHECK(owner->result_ok);
9258         return Pong_clone(&*owner->contents.result);
9259 }
9260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9261         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9262         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
9263         int64_t ret_ref = 0;
9264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9267         ret_ref = (uintptr_t)ret_var.inner;
9268         if (ret_var.is_owned) {
9269                 ret_ref |= 1;
9270         }
9271         return ret_ref;
9272 }
9273
9274 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9275 CHECK(!owner->result_ok);
9276         return DecodeError_clone(&*owner->contents.err);
9277 }
9278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9279         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9280         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
9281         int64_t ret_ref = 0;
9282         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9283         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9285         ret_ref = (uintptr_t)ret_var.inner;
9286         if (ret_var.is_owned) {
9287                 ret_ref |= 1;
9288         }
9289         return ret_ref;
9290 }
9291
9292 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9293 CHECK(owner->result_ok);
9294         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
9295 }
9296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9297         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9298         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9299         int64_t ret_ref = 0;
9300         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9301         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9303         ret_ref = (uintptr_t)ret_var.inner;
9304         if (ret_var.is_owned) {
9305                 ret_ref |= 1;
9306         }
9307         return ret_ref;
9308 }
9309
9310 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9311 CHECK(!owner->result_ok);
9312         return DecodeError_clone(&*owner->contents.err);
9313 }
9314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9315         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9316         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9317         int64_t ret_ref = 0;
9318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9321         ret_ref = (uintptr_t)ret_var.inner;
9322         if (ret_var.is_owned) {
9323                 ret_ref |= 1;
9324         }
9325         return ret_ref;
9326 }
9327
9328 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9329 CHECK(owner->result_ok);
9330         return ChannelAnnouncement_clone(&*owner->contents.result);
9331 }
9332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9333         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9334         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9335         int64_t ret_ref = 0;
9336         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9337         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9339         ret_ref = (uintptr_t)ret_var.inner;
9340         if (ret_var.is_owned) {
9341                 ret_ref |= 1;
9342         }
9343         return ret_ref;
9344 }
9345
9346 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9347 CHECK(!owner->result_ok);
9348         return DecodeError_clone(&*owner->contents.err);
9349 }
9350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9351         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9352         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9353         int64_t ret_ref = 0;
9354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9357         ret_ref = (uintptr_t)ret_var.inner;
9358         if (ret_var.is_owned) {
9359                 ret_ref |= 1;
9360         }
9361         return ret_ref;
9362 }
9363
9364 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9365 CHECK(owner->result_ok);
9366         return UnsignedChannelUpdate_clone(&*owner->contents.result);
9367 }
9368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9369         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9370         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9371         int64_t ret_ref = 0;
9372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9375         ret_ref = (uintptr_t)ret_var.inner;
9376         if (ret_var.is_owned) {
9377                 ret_ref |= 1;
9378         }
9379         return ret_ref;
9380 }
9381
9382 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9383 CHECK(!owner->result_ok);
9384         return DecodeError_clone(&*owner->contents.err);
9385 }
9386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9387         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9388         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
9389         int64_t ret_ref = 0;
9390         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9391         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9393         ret_ref = (uintptr_t)ret_var.inner;
9394         if (ret_var.is_owned) {
9395                 ret_ref |= 1;
9396         }
9397         return ret_ref;
9398 }
9399
9400 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9401 CHECK(owner->result_ok);
9402         return ChannelUpdate_clone(&*owner->contents.result);
9403 }
9404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9405         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9406         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9407         int64_t ret_ref = 0;
9408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9411         ret_ref = (uintptr_t)ret_var.inner;
9412         if (ret_var.is_owned) {
9413                 ret_ref |= 1;
9414         }
9415         return ret_ref;
9416 }
9417
9418 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9419 CHECK(!owner->result_ok);
9420         return DecodeError_clone(&*owner->contents.err);
9421 }
9422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9423         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9424         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
9425         int64_t ret_ref = 0;
9426         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9427         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9429         ret_ref = (uintptr_t)ret_var.inner;
9430         if (ret_var.is_owned) {
9431                 ret_ref |= 1;
9432         }
9433         return ret_ref;
9434 }
9435
9436 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9437 CHECK(owner->result_ok);
9438         return ErrorMessage_clone(&*owner->contents.result);
9439 }
9440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9441         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9442         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
9443         int64_t ret_ref = 0;
9444         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9445         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9447         ret_ref = (uintptr_t)ret_var.inner;
9448         if (ret_var.is_owned) {
9449                 ret_ref |= 1;
9450         }
9451         return ret_ref;
9452 }
9453
9454 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9455 CHECK(!owner->result_ok);
9456         return DecodeError_clone(&*owner->contents.err);
9457 }
9458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9459         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9460         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
9461         int64_t ret_ref = 0;
9462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9465         ret_ref = (uintptr_t)ret_var.inner;
9466         if (ret_var.is_owned) {
9467                 ret_ref |= 1;
9468         }
9469         return ret_ref;
9470 }
9471
9472 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9473 CHECK(owner->result_ok);
9474         return WarningMessage_clone(&*owner->contents.result);
9475 }
9476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9477         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9478         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
9479         int64_t ret_ref = 0;
9480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9483         ret_ref = (uintptr_t)ret_var.inner;
9484         if (ret_var.is_owned) {
9485                 ret_ref |= 1;
9486         }
9487         return ret_ref;
9488 }
9489
9490 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9491 CHECK(!owner->result_ok);
9492         return DecodeError_clone(&*owner->contents.err);
9493 }
9494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9495         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9496         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
9497         int64_t ret_ref = 0;
9498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9501         ret_ref = (uintptr_t)ret_var.inner;
9502         if (ret_var.is_owned) {
9503                 ret_ref |= 1;
9504         }
9505         return ret_ref;
9506 }
9507
9508 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9509 CHECK(owner->result_ok);
9510         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
9511 }
9512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9513         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9514         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9515         int64_t ret_ref = 0;
9516         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9517         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9519         ret_ref = (uintptr_t)ret_var.inner;
9520         if (ret_var.is_owned) {
9521                 ret_ref |= 1;
9522         }
9523         return ret_ref;
9524 }
9525
9526 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9527 CHECK(!owner->result_ok);
9528         return DecodeError_clone(&*owner->contents.err);
9529 }
9530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9531         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9532         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9533         int64_t ret_ref = 0;
9534         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9535         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9537         ret_ref = (uintptr_t)ret_var.inner;
9538         if (ret_var.is_owned) {
9539                 ret_ref |= 1;
9540         }
9541         return ret_ref;
9542 }
9543
9544 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9545 CHECK(owner->result_ok);
9546         return NodeAnnouncement_clone(&*owner->contents.result);
9547 }
9548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9549         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9550         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9551         int64_t ret_ref = 0;
9552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9555         ret_ref = (uintptr_t)ret_var.inner;
9556         if (ret_var.is_owned) {
9557                 ret_ref |= 1;
9558         }
9559         return ret_ref;
9560 }
9561
9562 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9563 CHECK(!owner->result_ok);
9564         return DecodeError_clone(&*owner->contents.err);
9565 }
9566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9567         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9568         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9569         int64_t ret_ref = 0;
9570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9573         ret_ref = (uintptr_t)ret_var.inner;
9574         if (ret_var.is_owned) {
9575                 ret_ref |= 1;
9576         }
9577         return ret_ref;
9578 }
9579
9580 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9581 CHECK(owner->result_ok);
9582         return QueryShortChannelIds_clone(&*owner->contents.result);
9583 }
9584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9585         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9586         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
9587         int64_t ret_ref = 0;
9588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9591         ret_ref = (uintptr_t)ret_var.inner;
9592         if (ret_var.is_owned) {
9593                 ret_ref |= 1;
9594         }
9595         return ret_ref;
9596 }
9597
9598 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9599 CHECK(!owner->result_ok);
9600         return DecodeError_clone(&*owner->contents.err);
9601 }
9602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9603         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9604         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
9605         int64_t ret_ref = 0;
9606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9609         ret_ref = (uintptr_t)ret_var.inner;
9610         if (ret_var.is_owned) {
9611                 ret_ref |= 1;
9612         }
9613         return ret_ref;
9614 }
9615
9616 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9617 CHECK(owner->result_ok);
9618         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
9619 }
9620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9621         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9622         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
9623         int64_t ret_ref = 0;
9624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9627         ret_ref = (uintptr_t)ret_var.inner;
9628         if (ret_var.is_owned) {
9629                 ret_ref |= 1;
9630         }
9631         return ret_ref;
9632 }
9633
9634 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9635 CHECK(!owner->result_ok);
9636         return DecodeError_clone(&*owner->contents.err);
9637 }
9638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9639         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9640         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
9641         int64_t ret_ref = 0;
9642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9645         ret_ref = (uintptr_t)ret_var.inner;
9646         if (ret_var.is_owned) {
9647                 ret_ref |= 1;
9648         }
9649         return ret_ref;
9650 }
9651
9652 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9653 CHECK(owner->result_ok);
9654         return QueryChannelRange_clone(&*owner->contents.result);
9655 }
9656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9657         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9658         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
9659         int64_t ret_ref = 0;
9660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9663         ret_ref = (uintptr_t)ret_var.inner;
9664         if (ret_var.is_owned) {
9665                 ret_ref |= 1;
9666         }
9667         return ret_ref;
9668 }
9669
9670 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9671 CHECK(!owner->result_ok);
9672         return DecodeError_clone(&*owner->contents.err);
9673 }
9674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9675         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9676         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
9677         int64_t ret_ref = 0;
9678         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9679         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9681         ret_ref = (uintptr_t)ret_var.inner;
9682         if (ret_var.is_owned) {
9683                 ret_ref |= 1;
9684         }
9685         return ret_ref;
9686 }
9687
9688 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9689 CHECK(owner->result_ok);
9690         return ReplyChannelRange_clone(&*owner->contents.result);
9691 }
9692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9693         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9694         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
9695         int64_t ret_ref = 0;
9696         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9697         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9699         ret_ref = (uintptr_t)ret_var.inner;
9700         if (ret_var.is_owned) {
9701                 ret_ref |= 1;
9702         }
9703         return ret_ref;
9704 }
9705
9706 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9707 CHECK(!owner->result_ok);
9708         return DecodeError_clone(&*owner->contents.err);
9709 }
9710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9711         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9712         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
9713         int64_t ret_ref = 0;
9714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9717         ret_ref = (uintptr_t)ret_var.inner;
9718         if (ret_var.is_owned) {
9719                 ret_ref |= 1;
9720         }
9721         return ret_ref;
9722 }
9723
9724 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9725 CHECK(owner->result_ok);
9726         return GossipTimestampFilter_clone(&*owner->contents.result);
9727 }
9728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9729         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9730         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
9731         int64_t ret_ref = 0;
9732         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9733         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9735         ret_ref = (uintptr_t)ret_var.inner;
9736         if (ret_var.is_owned) {
9737                 ret_ref |= 1;
9738         }
9739         return ret_ref;
9740 }
9741
9742 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9743 CHECK(!owner->result_ok);
9744         return DecodeError_clone(&*owner->contents.err);
9745 }
9746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9747         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9748         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
9749         int64_t ret_ref = 0;
9750         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9751         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9753         ret_ref = (uintptr_t)ret_var.inner;
9754         if (ret_var.is_owned) {
9755                 ret_ref |= 1;
9756         }
9757         return ret_ref;
9758 }
9759
9760 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
9761         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
9762         for (size_t i = 0; i < ret.datalen; i++) {
9763                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
9764         }
9765         return ret;
9766 }
9767 static jclass LDKSignOrCreationError_SignError_class = NULL;
9768 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
9769 static jclass LDKSignOrCreationError_CreationError_class = NULL;
9770 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
9771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
9772         LDKSignOrCreationError_SignError_class =
9773                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
9774         CHECK(LDKSignOrCreationError_SignError_class != NULL);
9775         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
9776         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
9777         LDKSignOrCreationError_CreationError_class =
9778                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
9779         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
9780         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
9781         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
9782 }
9783 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9784         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
9785         switch(obj->tag) {
9786                 case LDKSignOrCreationError_SignError: {
9787                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
9788                 }
9789                 case LDKSignOrCreationError_CreationError: {
9790                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
9791                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
9792                 }
9793                 default: abort();
9794         }
9795 }
9796 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9797 CHECK(owner->result_ok);
9798         return Invoice_clone(&*owner->contents.result);
9799 }
9800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9801         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9802         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
9803         int64_t ret_ref = 0;
9804         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9805         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9807         ret_ref = (uintptr_t)ret_var.inner;
9808         if (ret_var.is_owned) {
9809                 ret_ref |= 1;
9810         }
9811         return ret_ref;
9812 }
9813
9814 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9815 CHECK(!owner->result_ok);
9816         return SignOrCreationError_clone(&*owner->contents.err);
9817 }
9818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9819         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9820         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
9821         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
9822         int64_t ret_ref = (uintptr_t)ret_copy;
9823         return ret_ref;
9824 }
9825
9826 typedef struct LDKFilter_JCalls {
9827         atomic_size_t refcnt;
9828         JavaVM *vm;
9829         jweak o;
9830         jmethodID register_tx_meth;
9831         jmethodID register_output_meth;
9832 } LDKFilter_JCalls;
9833 static void LDKFilter_JCalls_free(void* this_arg) {
9834         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9835         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9836                 JNIEnv *env;
9837                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9838                 if (get_jenv_res == JNI_EDETACHED) {
9839                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9840                 } else {
9841                         DO_ASSERT(get_jenv_res == JNI_OK);
9842                 }
9843                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9844                 if (get_jenv_res == JNI_EDETACHED) {
9845                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9846                 }
9847                 FREE(j_calls);
9848         }
9849 }
9850 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
9851         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9852         JNIEnv *env;
9853         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9854         if (get_jenv_res == JNI_EDETACHED) {
9855                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9856         } else {
9857                 DO_ASSERT(get_jenv_res == JNI_OK);
9858         }
9859         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
9860         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
9861         LDKu8slice script_pubkey_var = script_pubkey;
9862         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
9863         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
9864         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9865         CHECK(obj != NULL);
9866         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
9867         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9868                 (*env)->ExceptionDescribe(env);
9869                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
9870         }
9871         if (get_jenv_res == JNI_EDETACHED) {
9872                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9873         }
9874 }
9875 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
9876         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9877         JNIEnv *env;
9878         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9879         if (get_jenv_res == JNI_EDETACHED) {
9880                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9881         } else {
9882                 DO_ASSERT(get_jenv_res == JNI_OK);
9883         }
9884         LDKWatchedOutput output_var = output;
9885         int64_t output_ref = 0;
9886         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9887         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9888         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
9889         output_ref = (uintptr_t)output_var.inner;
9890         if (output_var.is_owned) {
9891                 output_ref |= 1;
9892         }
9893         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9894         CHECK(obj != NULL);
9895         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
9896         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9897                 (*env)->ExceptionDescribe(env);
9898                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
9899         }
9900         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9901         CHECK_ACCESS(ret_ptr);
9902         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
9903         FREE((void*)ret);
9904         if (get_jenv_res == JNI_EDETACHED) {
9905                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9906         }
9907         return ret_conv;
9908 }
9909 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
9910         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
9911         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9912 }
9913 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
9914         jclass c = (*env)->GetObjectClass(env, o);
9915         CHECK(c != NULL);
9916         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
9917         atomic_init(&calls->refcnt, 1);
9918         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9919         calls->o = (*env)->NewWeakGlobalRef(env, o);
9920         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
9921         CHECK(calls->register_tx_meth != NULL);
9922         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
9923         CHECK(calls->register_output_meth != NULL);
9924
9925         LDKFilter ret = {
9926                 .this_arg = (void*) calls,
9927                 .register_tx = register_tx_LDKFilter_jcall,
9928                 .register_output = register_output_LDKFilter_jcall,
9929                 .free = LDKFilter_JCalls_free,
9930         };
9931         return ret;
9932 }
9933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
9934         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
9935         *res_ptr = LDKFilter_init(env, clz, o);
9936         return (uint64_t)res_ptr;
9937 }
9938 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) {
9939         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9940         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9941         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9942         unsigned char txid_arr[32];
9943         CHECK((*env)->GetArrayLength(env, txid) == 32);
9944         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
9945         unsigned char (*txid_ref)[32] = &txid_arr;
9946         LDKu8slice script_pubkey_ref;
9947         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
9948         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
9949         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
9950         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
9951 }
9952
9953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
9954         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9955         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9956         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9957         LDKWatchedOutput output_conv;
9958         output_conv.inner = (void*)(output & (~1));
9959         output_conv.is_owned = (output & 1) || (output == 0);
9960         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
9961         output_conv = WatchedOutput_clone(&output_conv);
9962         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9963         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
9964         int64_t ret_ref = (uintptr_t)ret_copy;
9965         return ret_ref;
9966 }
9967
9968 static jclass LDKCOption_FilterZ_Some_class = NULL;
9969 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
9970 static jclass LDKCOption_FilterZ_None_class = NULL;
9971 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
9972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
9973         LDKCOption_FilterZ_Some_class =
9974                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
9975         CHECK(LDKCOption_FilterZ_Some_class != NULL);
9976         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
9977         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
9978         LDKCOption_FilterZ_None_class =
9979                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
9980         CHECK(LDKCOption_FilterZ_None_class != NULL);
9981         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
9982         CHECK(LDKCOption_FilterZ_None_meth != NULL);
9983 }
9984 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9985         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
9986         switch(obj->tag) {
9987                 case LDKCOption_FilterZ_Some: {
9988                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
9989                         *some_ret = obj->some;
9990                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
9991                         if ((*some_ret).free == LDKFilter_JCalls_free) {
9992                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9993                                 LDKFilter_JCalls_cloned(&(*some_ret));
9994                         }
9995                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (int64_t)some_ret);
9996                 }
9997                 case LDKCOption_FilterZ_None: {
9998                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
9999                 }
10000                 default: abort();
10001         }
10002 }
10003 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10004 CHECK(owner->result_ok);
10005         return &*owner->contents.result;
10006 }
10007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10008         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
10009         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
10010         int64_t ret_ref = 0;
10011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10014         ret_ref = (uintptr_t)ret_var.inner & ~1;
10015         return ret_ref;
10016 }
10017
10018 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10019 CHECK(!owner->result_ok);
10020         return *owner->contents.err;
10021 }
10022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10023         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
10024         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
10025 }
10026
10027 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
10028         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
10029         for (size_t i = 0; i < ret.datalen; i++) {
10030                 ret.data[i] = OutPoint_clone(&orig->data[i]);
10031         }
10032         return ret;
10033 }
10034 typedef struct LDKMessageSendEventsProvider_JCalls {
10035         atomic_size_t refcnt;
10036         JavaVM *vm;
10037         jweak o;
10038         jmethodID get_and_clear_pending_msg_events_meth;
10039 } LDKMessageSendEventsProvider_JCalls;
10040 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
10041         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10042         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10043                 JNIEnv *env;
10044                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10045                 if (get_jenv_res == JNI_EDETACHED) {
10046                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10047                 } else {
10048                         DO_ASSERT(get_jenv_res == JNI_OK);
10049                 }
10050                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10051                 if (get_jenv_res == JNI_EDETACHED) {
10052                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10053                 }
10054                 FREE(j_calls);
10055         }
10056 }
10057 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
10058         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10059         JNIEnv *env;
10060         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10061         if (get_jenv_res == JNI_EDETACHED) {
10062                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10063         } else {
10064                 DO_ASSERT(get_jenv_res == JNI_OK);
10065         }
10066         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10067         CHECK(obj != NULL);
10068         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
10069         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10070                 (*env)->ExceptionDescribe(env);
10071                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
10072         }
10073         LDKCVec_MessageSendEventZ ret_constr;
10074         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10075         if (ret_constr.datalen > 0)
10076                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10077         else
10078                 ret_constr.data = NULL;
10079         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10080         for (size_t s = 0; s < ret_constr.datalen; s++) {
10081                 int64_t ret_conv_18 = ret_vals[s];
10082                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
10083                 CHECK_ACCESS(ret_conv_18_ptr);
10084                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
10085                 FREE((void*)ret_conv_18);
10086                 ret_constr.data[s] = ret_conv_18_conv;
10087         }
10088         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10089         if (get_jenv_res == JNI_EDETACHED) {
10090                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10091         }
10092         return ret_constr;
10093 }
10094 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
10095         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
10096         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10097 }
10098 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10099         jclass c = (*env)->GetObjectClass(env, o);
10100         CHECK(c != NULL);
10101         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
10102         atomic_init(&calls->refcnt, 1);
10103         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10104         calls->o = (*env)->NewWeakGlobalRef(env, o);
10105         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
10106         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
10107
10108         LDKMessageSendEventsProvider ret = {
10109                 .this_arg = (void*) calls,
10110                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
10111                 .free = LDKMessageSendEventsProvider_JCalls_free,
10112         };
10113         return ret;
10114 }
10115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10116         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
10117         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
10118         return (uint64_t)res_ptr;
10119 }
10120 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10121         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10122         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10123         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
10124         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
10125         int64_tArray ret_arr = NULL;
10126         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10127         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10128         for (size_t s = 0; s < ret_var.datalen; s++) {
10129                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10130                 *ret_conv_18_copy = ret_var.data[s];
10131                 int64_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
10132                 ret_arr_ptr[s] = ret_conv_18_ref;
10133         }
10134         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10135         FREE(ret_var.data);
10136         return ret_arr;
10137 }
10138
10139 typedef struct LDKEventHandler_JCalls {
10140         atomic_size_t refcnt;
10141         JavaVM *vm;
10142         jweak o;
10143         jmethodID handle_event_meth;
10144 } LDKEventHandler_JCalls;
10145 static void LDKEventHandler_JCalls_free(void* this_arg) {
10146         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10147         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10148                 JNIEnv *env;
10149                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10150                 if (get_jenv_res == JNI_EDETACHED) {
10151                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10152                 } else {
10153                         DO_ASSERT(get_jenv_res == JNI_OK);
10154                 }
10155                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10156                 if (get_jenv_res == JNI_EDETACHED) {
10157                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10158                 }
10159                 FREE(j_calls);
10160         }
10161 }
10162 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
10163         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10164         JNIEnv *env;
10165         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10166         if (get_jenv_res == JNI_EDETACHED) {
10167                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10168         } else {
10169                 DO_ASSERT(get_jenv_res == JNI_OK);
10170         }
10171         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
10172         *ret_event = Event_clone(event);
10173         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10174         CHECK(obj != NULL);
10175         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (int64_t)ret_event);
10176         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10177                 (*env)->ExceptionDescribe(env);
10178                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
10179         }
10180         if (get_jenv_res == JNI_EDETACHED) {
10181                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10182         }
10183 }
10184 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
10185         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
10186         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10187 }
10188 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
10189         jclass c = (*env)->GetObjectClass(env, o);
10190         CHECK(c != NULL);
10191         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
10192         atomic_init(&calls->refcnt, 1);
10193         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10194         calls->o = (*env)->NewWeakGlobalRef(env, o);
10195         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
10196         CHECK(calls->handle_event_meth != NULL);
10197
10198         LDKEventHandler ret = {
10199                 .this_arg = (void*) calls,
10200                 .handle_event = handle_event_LDKEventHandler_jcall,
10201                 .free = LDKEventHandler_JCalls_free,
10202         };
10203         return ret;
10204 }
10205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
10206         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10207         *res_ptr = LDKEventHandler_init(env, clz, o);
10208         return (uint64_t)res_ptr;
10209 }
10210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
10211         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10212         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10213         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
10214         LDKEvent* event_conv = (LDKEvent*)event;
10215         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
10216 }
10217
10218 typedef struct LDKEventsProvider_JCalls {
10219         atomic_size_t refcnt;
10220         JavaVM *vm;
10221         jweak o;
10222         jmethodID process_pending_events_meth;
10223 } LDKEventsProvider_JCalls;
10224 static void LDKEventsProvider_JCalls_free(void* this_arg) {
10225         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10226         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10227                 JNIEnv *env;
10228                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10229                 if (get_jenv_res == JNI_EDETACHED) {
10230                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10231                 } else {
10232                         DO_ASSERT(get_jenv_res == JNI_OK);
10233                 }
10234                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10235                 if (get_jenv_res == JNI_EDETACHED) {
10236                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10237                 }
10238                 FREE(j_calls);
10239         }
10240 }
10241 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
10242         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10243         JNIEnv *env;
10244         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10245         if (get_jenv_res == JNI_EDETACHED) {
10246                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10247         } else {
10248                 DO_ASSERT(get_jenv_res == JNI_OK);
10249         }
10250         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10251         *handler_ret = handler;
10252         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10253         CHECK(obj != NULL);
10254         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (int64_t)handler_ret);
10255         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10256                 (*env)->ExceptionDescribe(env);
10257                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
10258         }
10259         if (get_jenv_res == JNI_EDETACHED) {
10260                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10261         }
10262 }
10263 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
10264         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
10265         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10266 }
10267 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10268         jclass c = (*env)->GetObjectClass(env, o);
10269         CHECK(c != NULL);
10270         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
10271         atomic_init(&calls->refcnt, 1);
10272         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10273         calls->o = (*env)->NewWeakGlobalRef(env, o);
10274         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
10275         CHECK(calls->process_pending_events_meth != NULL);
10276
10277         LDKEventsProvider ret = {
10278                 .this_arg = (void*) calls,
10279                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
10280                 .free = LDKEventsProvider_JCalls_free,
10281         };
10282         return ret;
10283 }
10284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10285         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10286         *res_ptr = LDKEventsProvider_init(env, clz, o);
10287         return (uint64_t)res_ptr;
10288 }
10289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
10290         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10291         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10292         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
10293         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
10294         CHECK_ACCESS(handler_ptr);
10295         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
10296         if (handler_conv.free == LDKEventHandler_JCalls_free) {
10297                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10298                 LDKEventHandler_JCalls_cloned(&handler_conv);
10299         }
10300         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
10301 }
10302
10303 typedef struct LDKScore_JCalls {
10304         atomic_size_t refcnt;
10305         JavaVM *vm;
10306         jweak o;
10307         jmethodID channel_penalty_msat_meth;
10308         jmethodID payment_path_failed_meth;
10309         jmethodID payment_path_successful_meth;
10310         jmethodID write_meth;
10311 } LDKScore_JCalls;
10312 static void LDKScore_JCalls_free(void* this_arg) {
10313         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10314         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10315                 JNIEnv *env;
10316                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10317                 if (get_jenv_res == JNI_EDETACHED) {
10318                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10319                 } else {
10320                         DO_ASSERT(get_jenv_res == JNI_OK);
10321                 }
10322                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10323                 if (get_jenv_res == JNI_EDETACHED) {
10324                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10325                 }
10326                 FREE(j_calls);
10327         }
10328 }
10329 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
10330         LDKScore_JCalls *j_calls = (LDKScore_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         int64_t short_channel_id_conv = short_channel_id;
10339         LDKNodeId source_var = *source;
10340         int64_t source_ref = 0;
10341         source_var = NodeId_clone(&source_var);
10342         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10343         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10344         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
10345         source_ref = (uintptr_t)source_var.inner;
10346         if (source_var.is_owned) {
10347                 source_ref |= 1;
10348         }
10349         LDKNodeId target_var = *target;
10350         int64_t target_ref = 0;
10351         target_var = NodeId_clone(&target_var);
10352         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10353         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10354         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
10355         target_ref = (uintptr_t)target_var.inner;
10356         if (target_var.is_owned) {
10357                 target_ref |= 1;
10358         }
10359         LDKChannelUsage usage_var = usage;
10360         int64_t usage_ref = 0;
10361         CHECK((((uintptr_t)usage_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10362         CHECK((((uintptr_t)&usage_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10363         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
10364         usage_ref = (uintptr_t)usage_var.inner;
10365         if (usage_var.is_owned) {
10366                 usage_ref |= 1;
10367         }
10368         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10369         CHECK(obj != NULL);
10370         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
10371         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10372                 (*env)->ExceptionDescribe(env);
10373                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
10374         }
10375         if (get_jenv_res == JNI_EDETACHED) {
10376                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10377         }
10378         return ret;
10379 }
10380 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10381         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10382         JNIEnv *env;
10383         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10384         if (get_jenv_res == JNI_EDETACHED) {
10385                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10386         } else {
10387                 DO_ASSERT(get_jenv_res == JNI_OK);
10388         }
10389         LDKCVec_RouteHopZ path_var = path;
10390         int64_tArray path_arr = NULL;
10391         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10392         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10393         for (size_t k = 0; k < path_var.datalen; k++) {
10394                 LDKRouteHop path_conv_10_var = path_var.data[k];
10395                 int64_t path_conv_10_ref = 0;
10396                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10397                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10398                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10399                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10400                 if (path_conv_10_var.is_owned) {
10401                         path_conv_10_ref |= 1;
10402                 }
10403                 path_arr_ptr[k] = path_conv_10_ref;
10404         }
10405         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10406         FREE(path_var.data);
10407         int64_t short_channel_id_conv = short_channel_id;
10408         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10409         CHECK(obj != NULL);
10410         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
10411         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10412                 (*env)->ExceptionDescribe(env);
10413                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
10414         }
10415         if (get_jenv_res == JNI_EDETACHED) {
10416                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10417         }
10418 }
10419 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
10420         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10421         JNIEnv *env;
10422         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10423         if (get_jenv_res == JNI_EDETACHED) {
10424                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10425         } else {
10426                 DO_ASSERT(get_jenv_res == JNI_OK);
10427         }
10428         LDKCVec_RouteHopZ path_var = path;
10429         int64_tArray path_arr = NULL;
10430         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10431         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10432         for (size_t k = 0; k < path_var.datalen; k++) {
10433                 LDKRouteHop path_conv_10_var = path_var.data[k];
10434                 int64_t path_conv_10_ref = 0;
10435                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10436                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10437                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10438                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10439                 if (path_conv_10_var.is_owned) {
10440                         path_conv_10_ref |= 1;
10441                 }
10442                 path_arr_ptr[k] = path_conv_10_ref;
10443         }
10444         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10445         FREE(path_var.data);
10446         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10447         CHECK(obj != NULL);
10448         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
10449         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10450                 (*env)->ExceptionDescribe(env);
10451                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore 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 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
10458         LDKScore_JCalls *j_calls = (LDKScore_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         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10467         CHECK(obj != NULL);
10468         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
10469         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10470                 (*env)->ExceptionDescribe(env);
10471                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
10472         }
10473         LDKCVec_u8Z ret_ref;
10474         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
10475         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
10476         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
10477         if (get_jenv_res == JNI_EDETACHED) {
10478                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10479         }
10480         return ret_ref;
10481 }
10482 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10483         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10484         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10485 }
10486 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
10487         jclass c = (*env)->GetObjectClass(env, o);
10488         CHECK(c != NULL);
10489         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10490         atomic_init(&calls->refcnt, 1);
10491         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10492         calls->o = (*env)->NewWeakGlobalRef(env, o);
10493         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
10494         CHECK(calls->channel_penalty_msat_meth != NULL);
10495         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
10496         CHECK(calls->payment_path_failed_meth != NULL);
10497         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
10498         CHECK(calls->payment_path_successful_meth != NULL);
10499         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
10500         CHECK(calls->write_meth != NULL);
10501
10502         LDKScore ret = {
10503                 .this_arg = (void*) calls,
10504                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10505                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
10506                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
10507                 .write = write_LDKScore_jcall,
10508                 .free = LDKScore_JCalls_free,
10509         };
10510         return ret;
10511 }
10512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
10513         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10514         *res_ptr = LDKScore_init(env, clz, o);
10515         return (uint64_t)res_ptr;
10516 }
10517 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 source, int64_t target, int64_t usage) {
10518         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10519         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10520         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10521         LDKNodeId source_conv;
10522         source_conv.inner = (void*)(source & (~1));
10523         source_conv.is_owned = false;
10524         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
10525         LDKNodeId target_conv;
10526         target_conv.inner = (void*)(target & (~1));
10527         target_conv.is_owned = false;
10528         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
10529         LDKChannelUsage usage_conv;
10530         usage_conv.inner = (void*)(usage & (~1));
10531         usage_conv.is_owned = (usage & 1) || (usage == 0);
10532         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
10533         usage_conv = ChannelUsage_clone(&usage_conv);
10534         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
10535         return ret_conv;
10536 }
10537
10538 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) {
10539         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10540         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10541         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10542         LDKCVec_RouteHopZ path_constr;
10543         path_constr.datalen = (*env)->GetArrayLength(env, path);
10544         if (path_constr.datalen > 0)
10545                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10546         else
10547                 path_constr.data = NULL;
10548         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10549         for (size_t k = 0; k < path_constr.datalen; k++) {
10550                 int64_t path_conv_10 = path_vals[k];
10551                 LDKRouteHop path_conv_10_conv;
10552                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10553                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10554                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10555                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10556                 path_constr.data[k] = path_conv_10_conv;
10557         }
10558         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10559         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10560 }
10561
10562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
10563         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10564         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10565         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10566         LDKCVec_RouteHopZ path_constr;
10567         path_constr.datalen = (*env)->GetArrayLength(env, path);
10568         if (path_constr.datalen > 0)
10569                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10570         else
10571                 path_constr.data = NULL;
10572         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10573         for (size_t k = 0; k < path_constr.datalen; k++) {
10574                 int64_t path_conv_10 = path_vals[k];
10575                 LDKRouteHop path_conv_10_conv;
10576                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10577                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10578                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10579                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10580                 path_constr.data[k] = path_conv_10_conv;
10581         }
10582         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10583         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
10584 }
10585
10586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
10587         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10588         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10589         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10590         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
10591         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10592         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10593         CVec_u8Z_free(ret_var);
10594         return ret_arr;
10595 }
10596
10597 typedef struct LDKPersister_JCalls {
10598         atomic_size_t refcnt;
10599         JavaVM *vm;
10600         jweak o;
10601         jmethodID persist_manager_meth;
10602         jmethodID persist_graph_meth;
10603         jmethodID persist_scorer_meth;
10604 } LDKPersister_JCalls;
10605 static void LDKPersister_JCalls_free(void* this_arg) {
10606         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10607         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10608                 JNIEnv *env;
10609                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10610                 if (get_jenv_res == JNI_EDETACHED) {
10611                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10612                 } else {
10613                         DO_ASSERT(get_jenv_res == JNI_OK);
10614                 }
10615                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10616                 if (get_jenv_res == JNI_EDETACHED) {
10617                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10618                 }
10619                 FREE(j_calls);
10620         }
10621 }
10622 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
10623         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10624         JNIEnv *env;
10625         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10626         if (get_jenv_res == JNI_EDETACHED) {
10627                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10628         } else {
10629                 DO_ASSERT(get_jenv_res == JNI_OK);
10630         }
10631         LDKChannelManager channel_manager_var = *channel_manager;
10632         int64_t channel_manager_ref = 0;
10633         // WARNING: we may need a move here but no clone is available for LDKChannelManager
10634         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10635         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10636         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
10637         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
10638         if (channel_manager_var.is_owned) {
10639                 channel_manager_ref |= 1;
10640         }
10641         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10642         CHECK(obj != NULL);
10643         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
10644         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10645                 (*env)->ExceptionDescribe(env);
10646                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
10647         }
10648         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10649         CHECK_ACCESS(ret_ptr);
10650         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10651         FREE((void*)ret);
10652         if (get_jenv_res == JNI_EDETACHED) {
10653                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10654         }
10655         return ret_conv;
10656 }
10657 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
10658         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10659         JNIEnv *env;
10660         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10661         if (get_jenv_res == JNI_EDETACHED) {
10662                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10663         } else {
10664                 DO_ASSERT(get_jenv_res == JNI_OK);
10665         }
10666         LDKNetworkGraph network_graph_var = *network_graph;
10667         int64_t network_graph_ref = 0;
10668         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
10669         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10670         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10671         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
10672         network_graph_ref = (uintptr_t)network_graph_var.inner;
10673         if (network_graph_var.is_owned) {
10674                 network_graph_ref |= 1;
10675         }
10676         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10677         CHECK(obj != NULL);
10678         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
10679         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10680                 (*env)->ExceptionDescribe(env);
10681                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
10682         }
10683         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10684         CHECK_ACCESS(ret_ptr);
10685         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10686         FREE((void*)ret);
10687         if (get_jenv_res == JNI_EDETACHED) {
10688                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10689         }
10690         return ret_conv;
10691 }
10692 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKMultiThreadedLockableScore * scorer) {
10693         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10694         JNIEnv *env;
10695         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10696         if (get_jenv_res == JNI_EDETACHED) {
10697                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10698         } else {
10699                 DO_ASSERT(get_jenv_res == JNI_OK);
10700         }
10701         LDKMultiThreadedLockableScore scorer_var = *scorer;
10702         int64_t scorer_ref = 0;
10703         // WARNING: we may need a move here but no clone is available for LDKMultiThreadedLockableScore
10704         CHECK((((uintptr_t)scorer_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10705         CHECK((((uintptr_t)&scorer_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10706         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_var);
10707         scorer_ref = (uintptr_t)scorer_var.inner;
10708         if (scorer_var.is_owned) {
10709                 scorer_ref |= 1;
10710         }
10711         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10712         CHECK(obj != NULL);
10713         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, scorer_ref);
10714         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10715                 (*env)->ExceptionDescribe(env);
10716                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
10717         }
10718         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10719         CHECK_ACCESS(ret_ptr);
10720         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10721         FREE((void*)ret);
10722         if (get_jenv_res == JNI_EDETACHED) {
10723                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10724         }
10725         return ret_conv;
10726 }
10727 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
10728         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
10729         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10730 }
10731 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
10732         jclass c = (*env)->GetObjectClass(env, o);
10733         CHECK(c != NULL);
10734         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
10735         atomic_init(&calls->refcnt, 1);
10736         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10737         calls->o = (*env)->NewWeakGlobalRef(env, o);
10738         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
10739         CHECK(calls->persist_manager_meth != NULL);
10740         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
10741         CHECK(calls->persist_graph_meth != NULL);
10742         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
10743         CHECK(calls->persist_scorer_meth != NULL);
10744
10745         LDKPersister ret = {
10746                 .this_arg = (void*) calls,
10747                 .persist_manager = persist_manager_LDKPersister_jcall,
10748                 .persist_graph = persist_graph_LDKPersister_jcall,
10749                 .persist_scorer = persist_scorer_LDKPersister_jcall,
10750                 .free = LDKPersister_JCalls_free,
10751         };
10752         return ret;
10753 }
10754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
10755         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
10756         *res_ptr = LDKPersister_init(env, clz, o);
10757         return (uint64_t)res_ptr;
10758 }
10759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
10760         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10761         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10762         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10763         LDKChannelManager channel_manager_conv;
10764         channel_manager_conv.inner = (void*)(channel_manager & (~1));
10765         channel_manager_conv.is_owned = false;
10766         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
10767         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10768         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
10769         return (int64_t)ret_conv;
10770 }
10771
10772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
10773         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10774         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10775         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10776         LDKNetworkGraph network_graph_conv;
10777         network_graph_conv.inner = (void*)(network_graph & (~1));
10778         network_graph_conv.is_owned = false;
10779         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
10780         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10781         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
10782         return (int64_t)ret_conv;
10783 }
10784
10785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
10786         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10787         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10788         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10789         LDKMultiThreadedLockableScore scorer_conv;
10790         scorer_conv.inner = (void*)(scorer & (~1));
10791         scorer_conv.is_owned = false;
10792         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
10793         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10794         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, &scorer_conv);
10795         return (int64_t)ret_conv;
10796 }
10797
10798 typedef struct LDKListen_JCalls {
10799         atomic_size_t refcnt;
10800         JavaVM *vm;
10801         jweak o;
10802         jmethodID filtered_block_connected_meth;
10803         jmethodID block_connected_meth;
10804         jmethodID block_disconnected_meth;
10805 } LDKListen_JCalls;
10806 static void LDKListen_JCalls_free(void* this_arg) {
10807         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10808         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10809                 JNIEnv *env;
10810                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10811                 if (get_jenv_res == JNI_EDETACHED) {
10812                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10813                 } else {
10814                         DO_ASSERT(get_jenv_res == JNI_OK);
10815                 }
10816                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10817                 if (get_jenv_res == JNI_EDETACHED) {
10818                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10819                 }
10820                 FREE(j_calls);
10821         }
10822 }
10823 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
10824         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10825         JNIEnv *env;
10826         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10827         if (get_jenv_res == JNI_EDETACHED) {
10828                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10829         } else {
10830                 DO_ASSERT(get_jenv_res == JNI_OK);
10831         }
10832         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10833         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10834         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
10835         int64_tArray txdata_arr = NULL;
10836         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
10837         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
10838         for (size_t c = 0; c < txdata_var.datalen; c++) {
10839                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10840                 *txdata_conv_28_conv = txdata_var.data[c];
10841                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
10842         }
10843         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
10844         FREE(txdata_var.data);
10845         int32_t height_conv = height;
10846         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10847         CHECK(obj != NULL);
10848         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
10849         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10850                 (*env)->ExceptionDescribe(env);
10851                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
10852         }
10853         if (get_jenv_res == JNI_EDETACHED) {
10854                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10855         }
10856 }
10857 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
10858         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10859         JNIEnv *env;
10860         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10861         if (get_jenv_res == JNI_EDETACHED) {
10862                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10863         } else {
10864                 DO_ASSERT(get_jenv_res == JNI_OK);
10865         }
10866         LDKu8slice block_var = block;
10867         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
10868         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
10869         int32_t height_conv = height;
10870         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10871         CHECK(obj != NULL);
10872         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
10873         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10874                 (*env)->ExceptionDescribe(env);
10875                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
10876         }
10877         if (get_jenv_res == JNI_EDETACHED) {
10878                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10879         }
10880 }
10881 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
10882         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10883         JNIEnv *env;
10884         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10885         if (get_jenv_res == JNI_EDETACHED) {
10886                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10887         } else {
10888                 DO_ASSERT(get_jenv_res == JNI_OK);
10889         }
10890         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10891         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10892         int32_t height_conv = height;
10893         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10894         CHECK(obj != NULL);
10895         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
10896         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10897                 (*env)->ExceptionDescribe(env);
10898                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
10899         }
10900         if (get_jenv_res == JNI_EDETACHED) {
10901                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10902         }
10903 }
10904 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
10905         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
10906         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10907 }
10908 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
10909         jclass c = (*env)->GetObjectClass(env, o);
10910         CHECK(c != NULL);
10911         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
10912         atomic_init(&calls->refcnt, 1);
10913         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10914         calls->o = (*env)->NewWeakGlobalRef(env, o);
10915         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
10916         CHECK(calls->filtered_block_connected_meth != NULL);
10917         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
10918         CHECK(calls->block_connected_meth != NULL);
10919         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
10920         CHECK(calls->block_disconnected_meth != NULL);
10921
10922         LDKListen ret = {
10923                 .this_arg = (void*) calls,
10924                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
10925                 .block_connected = block_connected_LDKListen_jcall,
10926                 .block_disconnected = block_disconnected_LDKListen_jcall,
10927                 .free = LDKListen_JCalls_free,
10928         };
10929         return ret;
10930 }
10931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
10932         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
10933         *res_ptr = LDKListen_init(env, clz, o);
10934         return (uint64_t)res_ptr;
10935 }
10936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1filtered_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
10937         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10938         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10939         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
10940         unsigned char header_arr[80];
10941         CHECK((*env)->GetArrayLength(env, header) == 80);
10942         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10943         unsigned char (*header_ref)[80] = &header_arr;
10944         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10945         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10946         if (txdata_constr.datalen > 0)
10947                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10948         else
10949                 txdata_constr.data = NULL;
10950         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10951         for (size_t c = 0; c < txdata_constr.datalen; c++) {
10952                 int64_t txdata_conv_28 = txdata_vals[c];
10953                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
10954                 CHECK_ACCESS(txdata_conv_28_ptr);
10955                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
10956                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
10957                 txdata_constr.data[c] = txdata_conv_28_conv;
10958         }
10959         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10960         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
10961 }
10962
10963 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) {
10964         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10965         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10966         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
10967         LDKu8slice block_ref;
10968         block_ref.datalen = (*env)->GetArrayLength(env, block);
10969         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
10970         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
10971         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
10972 }
10973
10974 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) {
10975         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10976         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10977         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
10978         unsigned char header_arr[80];
10979         CHECK((*env)->GetArrayLength(env, header) == 80);
10980         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10981         unsigned char (*header_ref)[80] = &header_arr;
10982         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
10983 }
10984
10985 typedef struct LDKConfirm_JCalls {
10986         atomic_size_t refcnt;
10987         JavaVM *vm;
10988         jweak o;
10989         jmethodID transactions_confirmed_meth;
10990         jmethodID transaction_unconfirmed_meth;
10991         jmethodID best_block_updated_meth;
10992         jmethodID get_relevant_txids_meth;
10993 } LDKConfirm_JCalls;
10994 static void LDKConfirm_JCalls_free(void* this_arg) {
10995         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10996         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10997                 JNIEnv *env;
10998                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10999                 if (get_jenv_res == JNI_EDETACHED) {
11000                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11001                 } else {
11002                         DO_ASSERT(get_jenv_res == JNI_OK);
11003                 }
11004                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11005                 if (get_jenv_res == JNI_EDETACHED) {
11006                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11007                 }
11008                 FREE(j_calls);
11009         }
11010 }
11011 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11012         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11013         JNIEnv *env;
11014         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11015         if (get_jenv_res == JNI_EDETACHED) {
11016                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11017         } else {
11018                 DO_ASSERT(get_jenv_res == JNI_OK);
11019         }
11020         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11021         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11022         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11023         int64_tArray txdata_arr = NULL;
11024         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11025         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11026         for (size_t c = 0; c < txdata_var.datalen; c++) {
11027                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11028                 *txdata_conv_28_conv = txdata_var.data[c];
11029                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
11030         }
11031         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11032         FREE(txdata_var.data);
11033         int32_t height_conv = height;
11034         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11035         CHECK(obj != NULL);
11036         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
11037         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11038                 (*env)->ExceptionDescribe(env);
11039                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
11040         }
11041         if (get_jenv_res == JNI_EDETACHED) {
11042                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11043         }
11044 }
11045 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
11046         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11047         JNIEnv *env;
11048         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11049         if (get_jenv_res == JNI_EDETACHED) {
11050                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11051         } else {
11052                 DO_ASSERT(get_jenv_res == JNI_OK);
11053         }
11054         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11055         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11056         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11057         CHECK(obj != NULL);
11058         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
11059         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11060                 (*env)->ExceptionDescribe(env);
11061                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
11062         }
11063         if (get_jenv_res == JNI_EDETACHED) {
11064                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11065         }
11066 }
11067 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11068         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11069         JNIEnv *env;
11070         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11071         if (get_jenv_res == JNI_EDETACHED) {
11072                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11073         } else {
11074                 DO_ASSERT(get_jenv_res == JNI_OK);
11075         }
11076         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11077         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11078         int32_t height_conv = height;
11079         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11080         CHECK(obj != NULL);
11081         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
11082         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11083                 (*env)->ExceptionDescribe(env);
11084                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
11085         }
11086         if (get_jenv_res == JNI_EDETACHED) {
11087                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11088         }
11089 }
11090 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
11091         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11092         JNIEnv *env;
11093         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11094         if (get_jenv_res == JNI_EDETACHED) {
11095                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11096         } else {
11097                 DO_ASSERT(get_jenv_res == JNI_OK);
11098         }
11099         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11100         CHECK(obj != NULL);
11101         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
11102         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11103                 (*env)->ExceptionDescribe(env);
11104                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
11105         }
11106         LDKCVec_TxidZ ret_constr;
11107         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11108         if (ret_constr.datalen > 0)
11109                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
11110         else
11111                 ret_constr.data = NULL;
11112         for (size_t i = 0; i < ret_constr.datalen; i++) {
11113                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
11114                 LDKThirtyTwoBytes ret_conv_8_ref;
11115                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
11116                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
11117                 ret_constr.data[i] = ret_conv_8_ref;
11118         }
11119         if (get_jenv_res == JNI_EDETACHED) {
11120                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11121         }
11122         return ret_constr;
11123 }
11124 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
11125         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
11126         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11127 }
11128 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
11129         jclass c = (*env)->GetObjectClass(env, o);
11130         CHECK(c != NULL);
11131         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
11132         atomic_init(&calls->refcnt, 1);
11133         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11134         calls->o = (*env)->NewWeakGlobalRef(env, o);
11135         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
11136         CHECK(calls->transactions_confirmed_meth != NULL);
11137         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
11138         CHECK(calls->transaction_unconfirmed_meth != NULL);
11139         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
11140         CHECK(calls->best_block_updated_meth != NULL);
11141         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
11142         CHECK(calls->get_relevant_txids_meth != NULL);
11143
11144         LDKConfirm ret = {
11145                 .this_arg = (void*) calls,
11146                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
11147                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
11148                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
11149                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
11150                 .free = LDKConfirm_JCalls_free,
11151         };
11152         return ret;
11153 }
11154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
11155         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11156         *res_ptr = LDKConfirm_init(env, clz, o);
11157         return (uint64_t)res_ptr;
11158 }
11159 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) {
11160         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11161         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11162         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11163         unsigned char header_arr[80];
11164         CHECK((*env)->GetArrayLength(env, header) == 80);
11165         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11166         unsigned char (*header_ref)[80] = &header_arr;
11167         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11168         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11169         if (txdata_constr.datalen > 0)
11170                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11171         else
11172                 txdata_constr.data = NULL;
11173         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11174         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11175                 int64_t txdata_conv_28 = txdata_vals[c];
11176                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
11177                 CHECK_ACCESS(txdata_conv_28_ptr);
11178                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11179                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
11180                 txdata_constr.data[c] = txdata_conv_28_conv;
11181         }
11182         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11183         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11184 }
11185
11186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
11187         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11188         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11189         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11190         unsigned char txid_arr[32];
11191         CHECK((*env)->GetArrayLength(env, txid) == 32);
11192         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11193         unsigned char (*txid_ref)[32] = &txid_arr;
11194         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
11195 }
11196
11197 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) {
11198         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11199         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11200         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11201         unsigned char header_arr[80];
11202         CHECK((*env)->GetArrayLength(env, header) == 80);
11203         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11204         unsigned char (*header_ref)[80] = &header_arr;
11205         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
11206 }
11207
11208 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11209         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11210         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11211         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11212         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
11213         jobjectArray ret_arr = NULL;
11214         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11215         ;
11216         for (size_t i = 0; i < ret_var.datalen; i++) {
11217                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
11218                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
11219                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11220         }
11221         
11222         FREE(ret_var.data);
11223         return ret_arr;
11224 }
11225
11226 typedef struct LDKPersist_JCalls {
11227         atomic_size_t refcnt;
11228         JavaVM *vm;
11229         jweak o;
11230         jmethodID persist_new_channel_meth;
11231         jmethodID update_persisted_channel_meth;
11232 } LDKPersist_JCalls;
11233 static void LDKPersist_JCalls_free(void* this_arg) {
11234         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11235         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11236                 JNIEnv *env;
11237                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11238                 if (get_jenv_res == JNI_EDETACHED) {
11239                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11240                 } else {
11241                         DO_ASSERT(get_jenv_res == JNI_OK);
11242                 }
11243                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11244                 if (get_jenv_res == JNI_EDETACHED) {
11245                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11246                 }
11247                 FREE(j_calls);
11248         }
11249 }
11250 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11251         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11252         JNIEnv *env;
11253         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11254         if (get_jenv_res == JNI_EDETACHED) {
11255                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11256         } else {
11257                 DO_ASSERT(get_jenv_res == JNI_OK);
11258         }
11259         LDKOutPoint channel_id_var = channel_id;
11260         int64_t channel_id_ref = 0;
11261         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11262         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11263         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11264         channel_id_ref = (uintptr_t)channel_id_var.inner;
11265         if (channel_id_var.is_owned) {
11266                 channel_id_ref |= 1;
11267         }
11268         LDKChannelMonitor data_var = *data;
11269         int64_t data_ref = 0;
11270         data_var = ChannelMonitor_clone(&data_var);
11271         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11272         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11273         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11274         data_ref = (uintptr_t)data_var.inner;
11275         if (data_var.is_owned) {
11276                 data_ref |= 1;
11277         }
11278         LDKMonitorUpdateId update_id_var = update_id;
11279         int64_t update_id_ref = 0;
11280         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11281         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11282         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11283         update_id_ref = (uintptr_t)update_id_var.inner;
11284         if (update_id_var.is_owned) {
11285                 update_id_ref |= 1;
11286         }
11287         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11288         CHECK(obj != NULL);
11289         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
11290         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11291                 (*env)->ExceptionDescribe(env);
11292                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
11293         }
11294         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11295         CHECK_ACCESS(ret_ptr);
11296         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11297         FREE((void*)ret);
11298         if (get_jenv_res == JNI_EDETACHED) {
11299                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11300         }
11301         return ret_conv;
11302 }
11303 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11304         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11305         JNIEnv *env;
11306         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11307         if (get_jenv_res == JNI_EDETACHED) {
11308                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11309         } else {
11310                 DO_ASSERT(get_jenv_res == JNI_OK);
11311         }
11312         LDKOutPoint channel_id_var = channel_id;
11313         int64_t channel_id_ref = 0;
11314         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11315         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11316         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11317         channel_id_ref = (uintptr_t)channel_id_var.inner;
11318         if (channel_id_var.is_owned) {
11319                 channel_id_ref |= 1;
11320         }
11321         LDKChannelMonitorUpdate update_var = *update;
11322         int64_t update_ref = 0;
11323         if ((uintptr_t)update_var.inner > 4096) {
11324                 update_var = ChannelMonitorUpdate_clone(&update_var);
11325                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11326                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11327         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
11328                 update_ref = (uintptr_t)update_var.inner;
11329                 if (update_var.is_owned) {
11330                         update_ref |= 1;
11331                 }
11332         }
11333         LDKChannelMonitor data_var = *data;
11334         int64_t data_ref = 0;
11335         data_var = ChannelMonitor_clone(&data_var);
11336         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11337         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11338         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11339         data_ref = (uintptr_t)data_var.inner;
11340         if (data_var.is_owned) {
11341                 data_ref |= 1;
11342         }
11343         LDKMonitorUpdateId update_id_var = update_id;
11344         int64_t update_id_ref = 0;
11345         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11346         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11347         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11348         update_id_ref = (uintptr_t)update_id_var.inner;
11349         if (update_id_var.is_owned) {
11350                 update_id_ref |= 1;
11351         }
11352         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11353         CHECK(obj != NULL);
11354         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
11355         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11356                 (*env)->ExceptionDescribe(env);
11357                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
11358         }
11359         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11360         CHECK_ACCESS(ret_ptr);
11361         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11362         FREE((void*)ret);
11363         if (get_jenv_res == JNI_EDETACHED) {
11364                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11365         }
11366         return ret_conv;
11367 }
11368 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
11369         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
11370         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11371 }
11372 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
11373         jclass c = (*env)->GetObjectClass(env, o);
11374         CHECK(c != NULL);
11375         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
11376         atomic_init(&calls->refcnt, 1);
11377         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11378         calls->o = (*env)->NewWeakGlobalRef(env, o);
11379         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
11380         CHECK(calls->persist_new_channel_meth != NULL);
11381         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
11382         CHECK(calls->update_persisted_channel_meth != NULL);
11383
11384         LDKPersist ret = {
11385                 .this_arg = (void*) calls,
11386                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
11387                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
11388                 .free = LDKPersist_JCalls_free,
11389         };
11390         return ret;
11391 }
11392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
11393         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
11394         *res_ptr = LDKPersist_init(env, clz, o);
11395         return (uint64_t)res_ptr;
11396 }
11397 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) {
11398         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11399         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11400         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11401         LDKOutPoint channel_id_conv;
11402         channel_id_conv.inner = (void*)(channel_id & (~1));
11403         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
11404         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11405         channel_id_conv = OutPoint_clone(&channel_id_conv);
11406         LDKChannelMonitor data_conv;
11407         data_conv.inner = (void*)(data & (~1));
11408         data_conv.is_owned = false;
11409         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11410         LDKMonitorUpdateId update_id_conv;
11411         update_id_conv.inner = (void*)(update_id & (~1));
11412         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
11413         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11414         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11415         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11416         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
11417         return (int64_t)ret_conv;
11418 }
11419
11420 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) {
11421         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11422         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11423         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11424         LDKOutPoint channel_id_conv;
11425         channel_id_conv.inner = (void*)(channel_id & (~1));
11426         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
11427         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11428         channel_id_conv = OutPoint_clone(&channel_id_conv);
11429         LDKChannelMonitorUpdate update_conv;
11430         update_conv.inner = (void*)(update & (~1));
11431         update_conv.is_owned = false;
11432         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
11433         LDKChannelMonitor data_conv;
11434         data_conv.inner = (void*)(data & (~1));
11435         data_conv.is_owned = false;
11436         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11437         LDKMonitorUpdateId update_id_conv;
11438         update_id_conv.inner = (void*)(update_id & (~1));
11439         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
11440         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11441         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11442         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11443         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
11444         return (int64_t)ret_conv;
11445 }
11446
11447 typedef struct LDKChannelMessageHandler_JCalls {
11448         atomic_size_t refcnt;
11449         JavaVM *vm;
11450         jweak o;
11451         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11452         jmethodID handle_open_channel_meth;
11453         jmethodID handle_accept_channel_meth;
11454         jmethodID handle_funding_created_meth;
11455         jmethodID handle_funding_signed_meth;
11456         jmethodID handle_channel_ready_meth;
11457         jmethodID handle_shutdown_meth;
11458         jmethodID handle_closing_signed_meth;
11459         jmethodID handle_update_add_htlc_meth;
11460         jmethodID handle_update_fulfill_htlc_meth;
11461         jmethodID handle_update_fail_htlc_meth;
11462         jmethodID handle_update_fail_malformed_htlc_meth;
11463         jmethodID handle_commitment_signed_meth;
11464         jmethodID handle_revoke_and_ack_meth;
11465         jmethodID handle_update_fee_meth;
11466         jmethodID handle_announcement_signatures_meth;
11467         jmethodID peer_disconnected_meth;
11468         jmethodID peer_connected_meth;
11469         jmethodID handle_channel_reestablish_meth;
11470         jmethodID handle_channel_update_meth;
11471         jmethodID handle_error_meth;
11472 } LDKChannelMessageHandler_JCalls;
11473 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
11474         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11475         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11476                 JNIEnv *env;
11477                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11478                 if (get_jenv_res == JNI_EDETACHED) {
11479                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11480                 } else {
11481                         DO_ASSERT(get_jenv_res == JNI_OK);
11482                 }
11483                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11484                 if (get_jenv_res == JNI_EDETACHED) {
11485                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11486                 }
11487                 FREE(j_calls);
11488         }
11489 }
11490 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
11491         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11492         JNIEnv *env;
11493         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11494         if (get_jenv_res == JNI_EDETACHED) {
11495                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11496         } else {
11497                 DO_ASSERT(get_jenv_res == JNI_OK);
11498         }
11499         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11500         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11501         LDKInitFeatures their_features_var = their_features;
11502         int64_t their_features_ref = 0;
11503         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11504         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11505         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11506         their_features_ref = (uintptr_t)their_features_var.inner;
11507         if (their_features_var.is_owned) {
11508                 their_features_ref |= 1;
11509         }
11510         LDKOpenChannel msg_var = *msg;
11511         int64_t msg_ref = 0;
11512         msg_var = OpenChannel_clone(&msg_var);
11513         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11514         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11515         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11516         msg_ref = (uintptr_t)msg_var.inner;
11517         if (msg_var.is_owned) {
11518                 msg_ref |= 1;
11519         }
11520         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11521         CHECK(obj != NULL);
11522         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11523         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11524                 (*env)->ExceptionDescribe(env);
11525                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
11526         }
11527         if (get_jenv_res == JNI_EDETACHED) {
11528                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11529         }
11530 }
11531 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
11532         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11533         JNIEnv *env;
11534         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11535         if (get_jenv_res == JNI_EDETACHED) {
11536                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11537         } else {
11538                 DO_ASSERT(get_jenv_res == JNI_OK);
11539         }
11540         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11541         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11542         LDKInitFeatures their_features_var = their_features;
11543         int64_t their_features_ref = 0;
11544         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11545         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11546         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11547         their_features_ref = (uintptr_t)their_features_var.inner;
11548         if (their_features_var.is_owned) {
11549                 their_features_ref |= 1;
11550         }
11551         LDKAcceptChannel msg_var = *msg;
11552         int64_t msg_ref = 0;
11553         msg_var = AcceptChannel_clone(&msg_var);
11554         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11555         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11556         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11557         msg_ref = (uintptr_t)msg_var.inner;
11558         if (msg_var.is_owned) {
11559                 msg_ref |= 1;
11560         }
11561         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11562         CHECK(obj != NULL);
11563         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11564         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11565                 (*env)->ExceptionDescribe(env);
11566                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
11567         }
11568         if (get_jenv_res == JNI_EDETACHED) {
11569                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11570         }
11571 }
11572 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
11573         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11574         JNIEnv *env;
11575         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11576         if (get_jenv_res == JNI_EDETACHED) {
11577                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11578         } else {
11579                 DO_ASSERT(get_jenv_res == JNI_OK);
11580         }
11581         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11582         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11583         LDKFundingCreated msg_var = *msg;
11584         int64_t msg_ref = 0;
11585         msg_var = FundingCreated_clone(&msg_var);
11586         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11587         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11588         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11589         msg_ref = (uintptr_t)msg_var.inner;
11590         if (msg_var.is_owned) {
11591                 msg_ref |= 1;
11592         }
11593         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11594         CHECK(obj != NULL);
11595         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
11596         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11597                 (*env)->ExceptionDescribe(env);
11598                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
11599         }
11600         if (get_jenv_res == JNI_EDETACHED) {
11601                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11602         }
11603 }
11604 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
11605         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11606         JNIEnv *env;
11607         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11608         if (get_jenv_res == JNI_EDETACHED) {
11609                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11610         } else {
11611                 DO_ASSERT(get_jenv_res == JNI_OK);
11612         }
11613         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11614         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11615         LDKFundingSigned msg_var = *msg;
11616         int64_t msg_ref = 0;
11617         msg_var = FundingSigned_clone(&msg_var);
11618         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11619         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11620         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11621         msg_ref = (uintptr_t)msg_var.inner;
11622         if (msg_var.is_owned) {
11623                 msg_ref |= 1;
11624         }
11625         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11626         CHECK(obj != NULL);
11627         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
11628         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11629                 (*env)->ExceptionDescribe(env);
11630                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
11631         }
11632         if (get_jenv_res == JNI_EDETACHED) {
11633                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11634         }
11635 }
11636 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
11637         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11638         JNIEnv *env;
11639         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11640         if (get_jenv_res == JNI_EDETACHED) {
11641                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11642         } else {
11643                 DO_ASSERT(get_jenv_res == JNI_OK);
11644         }
11645         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11646         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11647         LDKChannelReady msg_var = *msg;
11648         int64_t msg_ref = 0;
11649         msg_var = ChannelReady_clone(&msg_var);
11650         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11651         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11652         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11653         msg_ref = (uintptr_t)msg_var.inner;
11654         if (msg_var.is_owned) {
11655                 msg_ref |= 1;
11656         }
11657         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11658         CHECK(obj != NULL);
11659         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
11660         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11661                 (*env)->ExceptionDescribe(env);
11662                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
11663         }
11664         if (get_jenv_res == JNI_EDETACHED) {
11665                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11666         }
11667 }
11668 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
11669         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11670         JNIEnv *env;
11671         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11672         if (get_jenv_res == JNI_EDETACHED) {
11673                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11674         } else {
11675                 DO_ASSERT(get_jenv_res == JNI_OK);
11676         }
11677         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11678         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11679         LDKInitFeatures their_features_var = *their_features;
11680         int64_t their_features_ref = 0;
11681         their_features_var = InitFeatures_clone(&their_features_var);
11682         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11683         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11684         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11685         their_features_ref = (uintptr_t)their_features_var.inner;
11686         if (their_features_var.is_owned) {
11687                 their_features_ref |= 1;
11688         }
11689         LDKShutdown msg_var = *msg;
11690         int64_t msg_ref = 0;
11691         msg_var = Shutdown_clone(&msg_var);
11692         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11693         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11694         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11695         msg_ref = (uintptr_t)msg_var.inner;
11696         if (msg_var.is_owned) {
11697                 msg_ref |= 1;
11698         }
11699         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11700         CHECK(obj != NULL);
11701         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
11702         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11703                 (*env)->ExceptionDescribe(env);
11704                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
11705         }
11706         if (get_jenv_res == JNI_EDETACHED) {
11707                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11708         }
11709 }
11710 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
11711         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11712         JNIEnv *env;
11713         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11714         if (get_jenv_res == JNI_EDETACHED) {
11715                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11716         } else {
11717                 DO_ASSERT(get_jenv_res == JNI_OK);
11718         }
11719         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11720         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11721         LDKClosingSigned msg_var = *msg;
11722         int64_t msg_ref = 0;
11723         msg_var = ClosingSigned_clone(&msg_var);
11724         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11725         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11726         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11727         msg_ref = (uintptr_t)msg_var.inner;
11728         if (msg_var.is_owned) {
11729                 msg_ref |= 1;
11730         }
11731         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11732         CHECK(obj != NULL);
11733         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
11734         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11735                 (*env)->ExceptionDescribe(env);
11736                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
11737         }
11738         if (get_jenv_res == JNI_EDETACHED) {
11739                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11740         }
11741 }
11742 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
11743         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11744         JNIEnv *env;
11745         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11746         if (get_jenv_res == JNI_EDETACHED) {
11747                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11748         } else {
11749                 DO_ASSERT(get_jenv_res == JNI_OK);
11750         }
11751         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11752         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11753         LDKUpdateAddHTLC msg_var = *msg;
11754         int64_t msg_ref = 0;
11755         msg_var = UpdateAddHTLC_clone(&msg_var);
11756         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11757         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11758         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11759         msg_ref = (uintptr_t)msg_var.inner;
11760         if (msg_var.is_owned) {
11761                 msg_ref |= 1;
11762         }
11763         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11764         CHECK(obj != NULL);
11765         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
11766         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11767                 (*env)->ExceptionDescribe(env);
11768                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
11769         }
11770         if (get_jenv_res == JNI_EDETACHED) {
11771                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11772         }
11773 }
11774 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
11775         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11776         JNIEnv *env;
11777         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11778         if (get_jenv_res == JNI_EDETACHED) {
11779                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11780         } else {
11781                 DO_ASSERT(get_jenv_res == JNI_OK);
11782         }
11783         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11784         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11785         LDKUpdateFulfillHTLC msg_var = *msg;
11786         int64_t msg_ref = 0;
11787         msg_var = UpdateFulfillHTLC_clone(&msg_var);
11788         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11789         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11790         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11791         msg_ref = (uintptr_t)msg_var.inner;
11792         if (msg_var.is_owned) {
11793                 msg_ref |= 1;
11794         }
11795         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11796         CHECK(obj != NULL);
11797         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
11798         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11799                 (*env)->ExceptionDescribe(env);
11800                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
11801         }
11802         if (get_jenv_res == JNI_EDETACHED) {
11803                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11804         }
11805 }
11806 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
11807         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11808         JNIEnv *env;
11809         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11810         if (get_jenv_res == JNI_EDETACHED) {
11811                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11812         } else {
11813                 DO_ASSERT(get_jenv_res == JNI_OK);
11814         }
11815         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11816         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11817         LDKUpdateFailHTLC msg_var = *msg;
11818         int64_t msg_ref = 0;
11819         msg_var = UpdateFailHTLC_clone(&msg_var);
11820         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11821         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11822         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11823         msg_ref = (uintptr_t)msg_var.inner;
11824         if (msg_var.is_owned) {
11825                 msg_ref |= 1;
11826         }
11827         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11828         CHECK(obj != NULL);
11829         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
11830         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11831                 (*env)->ExceptionDescribe(env);
11832                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
11833         }
11834         if (get_jenv_res == JNI_EDETACHED) {
11835                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11836         }
11837 }
11838 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
11839         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11840         JNIEnv *env;
11841         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11842         if (get_jenv_res == JNI_EDETACHED) {
11843                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11844         } else {
11845                 DO_ASSERT(get_jenv_res == JNI_OK);
11846         }
11847         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11848         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11849         LDKUpdateFailMalformedHTLC msg_var = *msg;
11850         int64_t msg_ref = 0;
11851         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
11852         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11853         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11854         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11855         msg_ref = (uintptr_t)msg_var.inner;
11856         if (msg_var.is_owned) {
11857                 msg_ref |= 1;
11858         }
11859         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11860         CHECK(obj != NULL);
11861         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
11862         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11863                 (*env)->ExceptionDescribe(env);
11864                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
11865         }
11866         if (get_jenv_res == JNI_EDETACHED) {
11867                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11868         }
11869 }
11870 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
11871         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11872         JNIEnv *env;
11873         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11874         if (get_jenv_res == JNI_EDETACHED) {
11875                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11876         } else {
11877                 DO_ASSERT(get_jenv_res == JNI_OK);
11878         }
11879         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11880         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11881         LDKCommitmentSigned msg_var = *msg;
11882         int64_t msg_ref = 0;
11883         msg_var = CommitmentSigned_clone(&msg_var);
11884         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11885         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11886         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11887         msg_ref = (uintptr_t)msg_var.inner;
11888         if (msg_var.is_owned) {
11889                 msg_ref |= 1;
11890         }
11891         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11892         CHECK(obj != NULL);
11893         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
11894         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11895                 (*env)->ExceptionDescribe(env);
11896                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
11897         }
11898         if (get_jenv_res == JNI_EDETACHED) {
11899                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11900         }
11901 }
11902 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
11903         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11904         JNIEnv *env;
11905         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11906         if (get_jenv_res == JNI_EDETACHED) {
11907                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11908         } else {
11909                 DO_ASSERT(get_jenv_res == JNI_OK);
11910         }
11911         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11912         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11913         LDKRevokeAndACK msg_var = *msg;
11914         int64_t msg_ref = 0;
11915         msg_var = RevokeAndACK_clone(&msg_var);
11916         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11917         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11918         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11919         msg_ref = (uintptr_t)msg_var.inner;
11920         if (msg_var.is_owned) {
11921                 msg_ref |= 1;
11922         }
11923         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11924         CHECK(obj != NULL);
11925         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
11926         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11927                 (*env)->ExceptionDescribe(env);
11928                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler 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 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
11935         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_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         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11944         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11945         LDKUpdateFee msg_var = *msg;
11946         int64_t msg_ref = 0;
11947         msg_var = UpdateFee_clone(&msg_var);
11948         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11949         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11950         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11951         msg_ref = (uintptr_t)msg_var.inner;
11952         if (msg_var.is_owned) {
11953                 msg_ref |= 1;
11954         }
11955         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11956         CHECK(obj != NULL);
11957         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
11958         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11959                 (*env)->ExceptionDescribe(env);
11960                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
11961         }
11962         if (get_jenv_res == JNI_EDETACHED) {
11963                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11964         }
11965 }
11966 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
11967         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11968         JNIEnv *env;
11969         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11970         if (get_jenv_res == JNI_EDETACHED) {
11971                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11972         } else {
11973                 DO_ASSERT(get_jenv_res == JNI_OK);
11974         }
11975         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11976         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11977         LDKAnnouncementSignatures msg_var = *msg;
11978         int64_t msg_ref = 0;
11979         msg_var = AnnouncementSignatures_clone(&msg_var);
11980         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11981         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11982         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11983         msg_ref = (uintptr_t)msg_var.inner;
11984         if (msg_var.is_owned) {
11985                 msg_ref |= 1;
11986         }
11987         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11988         CHECK(obj != NULL);
11989         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
11990         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11991                 (*env)->ExceptionDescribe(env);
11992                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
11993         }
11994         if (get_jenv_res == JNI_EDETACHED) {
11995                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11996         }
11997 }
11998 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
11999         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12000         JNIEnv *env;
12001         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12002         if (get_jenv_res == JNI_EDETACHED) {
12003                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12004         } else {
12005                 DO_ASSERT(get_jenv_res == JNI_OK);
12006         }
12007         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12008         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12009         jboolean no_connection_possible_conv = no_connection_possible;
12010         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12011         CHECK(obj != NULL);
12012         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
12013         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12014                 (*env)->ExceptionDescribe(env);
12015                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
12016         }
12017         if (get_jenv_res == JNI_EDETACHED) {
12018                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12019         }
12020 }
12021 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
12022         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12023         JNIEnv *env;
12024         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12025         if (get_jenv_res == JNI_EDETACHED) {
12026                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12027         } else {
12028                 DO_ASSERT(get_jenv_res == JNI_OK);
12029         }
12030         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12031         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12032         LDKInit msg_var = *msg;
12033         int64_t msg_ref = 0;
12034         msg_var = Init_clone(&msg_var);
12035         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12036         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12037         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12038         msg_ref = (uintptr_t)msg_var.inner;
12039         if (msg_var.is_owned) {
12040                 msg_ref |= 1;
12041         }
12042         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12043         CHECK(obj != NULL);
12044         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
12045         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12046                 (*env)->ExceptionDescribe(env);
12047                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
12048         }
12049         if (get_jenv_res == JNI_EDETACHED) {
12050                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12051         }
12052 }
12053 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
12054         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12055         JNIEnv *env;
12056         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12057         if (get_jenv_res == JNI_EDETACHED) {
12058                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12059         } else {
12060                 DO_ASSERT(get_jenv_res == JNI_OK);
12061         }
12062         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12063         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12064         LDKChannelReestablish msg_var = *msg;
12065         int64_t msg_ref = 0;
12066         msg_var = ChannelReestablish_clone(&msg_var);
12067         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12068         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12069         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12070         msg_ref = (uintptr_t)msg_var.inner;
12071         if (msg_var.is_owned) {
12072                 msg_ref |= 1;
12073         }
12074         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12075         CHECK(obj != NULL);
12076         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
12077         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12078                 (*env)->ExceptionDescribe(env);
12079                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
12080         }
12081         if (get_jenv_res == JNI_EDETACHED) {
12082                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12083         }
12084 }
12085 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
12086         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12087         JNIEnv *env;
12088         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12089         if (get_jenv_res == JNI_EDETACHED) {
12090                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12091         } else {
12092                 DO_ASSERT(get_jenv_res == JNI_OK);
12093         }
12094         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12095         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12096         LDKChannelUpdate msg_var = *msg;
12097         int64_t msg_ref = 0;
12098         msg_var = ChannelUpdate_clone(&msg_var);
12099         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12100         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12101         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12102         msg_ref = (uintptr_t)msg_var.inner;
12103         if (msg_var.is_owned) {
12104                 msg_ref |= 1;
12105         }
12106         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12107         CHECK(obj != NULL);
12108         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
12109         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12110                 (*env)->ExceptionDescribe(env);
12111                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
12112         }
12113         if (get_jenv_res == JNI_EDETACHED) {
12114                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12115         }
12116 }
12117 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
12118         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12119         JNIEnv *env;
12120         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12121         if (get_jenv_res == JNI_EDETACHED) {
12122                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12123         } else {
12124                 DO_ASSERT(get_jenv_res == JNI_OK);
12125         }
12126         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12127         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12128         LDKErrorMessage msg_var = *msg;
12129         int64_t msg_ref = 0;
12130         msg_var = ErrorMessage_clone(&msg_var);
12131         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12132         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12133         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12134         msg_ref = (uintptr_t)msg_var.inner;
12135         if (msg_var.is_owned) {
12136                 msg_ref |= 1;
12137         }
12138         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12139         CHECK(obj != NULL);
12140         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
12141         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12142                 (*env)->ExceptionDescribe(env);
12143                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler 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 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
12150         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
12151         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12152         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12153 }
12154 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12155         jclass c = (*env)->GetObjectClass(env, o);
12156         CHECK(c != NULL);
12157         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
12158         atomic_init(&calls->refcnt, 1);
12159         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12160         calls->o = (*env)->NewWeakGlobalRef(env, o);
12161         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
12162         CHECK(calls->handle_open_channel_meth != NULL);
12163         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
12164         CHECK(calls->handle_accept_channel_meth != NULL);
12165         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
12166         CHECK(calls->handle_funding_created_meth != NULL);
12167         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
12168         CHECK(calls->handle_funding_signed_meth != NULL);
12169         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
12170         CHECK(calls->handle_channel_ready_meth != NULL);
12171         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
12172         CHECK(calls->handle_shutdown_meth != NULL);
12173         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
12174         CHECK(calls->handle_closing_signed_meth != NULL);
12175         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
12176         CHECK(calls->handle_update_add_htlc_meth != NULL);
12177         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
12178         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
12179         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
12180         CHECK(calls->handle_update_fail_htlc_meth != NULL);
12181         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
12182         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
12183         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
12184         CHECK(calls->handle_commitment_signed_meth != NULL);
12185         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
12186         CHECK(calls->handle_revoke_and_ack_meth != NULL);
12187         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
12188         CHECK(calls->handle_update_fee_meth != NULL);
12189         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
12190         CHECK(calls->handle_announcement_signatures_meth != NULL);
12191         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
12192         CHECK(calls->peer_disconnected_meth != NULL);
12193         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
12194         CHECK(calls->peer_connected_meth != NULL);
12195         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
12196         CHECK(calls->handle_channel_reestablish_meth != NULL);
12197         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
12198         CHECK(calls->handle_channel_update_meth != NULL);
12199         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
12200         CHECK(calls->handle_error_meth != NULL);
12201
12202         LDKChannelMessageHandler ret = {
12203                 .this_arg = (void*) calls,
12204                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
12205                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
12206                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
12207                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
12208                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
12209                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
12210                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
12211                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
12212                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
12213                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
12214                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
12215                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
12216                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
12217                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
12218                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
12219                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
12220                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
12221                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
12222                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
12223                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
12224                 .free = LDKChannelMessageHandler_JCalls_free,
12225                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12226         };
12227         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12228         return ret;
12229 }
12230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12231         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12232         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12233         return (uint64_t)res_ptr;
12234 }
12235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12236         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
12237         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
12238         DO_ASSERT((res_ptr & 1) == 0);
12239         return (int64_t)(res_ptr | 1);
12240 }
12241 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) {
12242         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12243         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12244         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12245         LDKPublicKey their_node_id_ref;
12246         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12247         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12248         LDKInitFeatures their_features_conv;
12249         their_features_conv.inner = (void*)(their_features & (~1));
12250         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
12251         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12252         their_features_conv = InitFeatures_clone(&their_features_conv);
12253         LDKOpenChannel msg_conv;
12254         msg_conv.inner = (void*)(msg & (~1));
12255         msg_conv.is_owned = false;
12256         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12257         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12258 }
12259
12260 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) {
12261         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12262         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12263         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12264         LDKPublicKey their_node_id_ref;
12265         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12266         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12267         LDKInitFeatures their_features_conv;
12268         their_features_conv.inner = (void*)(their_features & (~1));
12269         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
12270         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12271         their_features_conv = InitFeatures_clone(&their_features_conv);
12272         LDKAcceptChannel msg_conv;
12273         msg_conv.inner = (void*)(msg & (~1));
12274         msg_conv.is_owned = false;
12275         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12276         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12277 }
12278
12279 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) {
12280         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12281         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12282         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12283         LDKPublicKey their_node_id_ref;
12284         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12285         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12286         LDKFundingCreated msg_conv;
12287         msg_conv.inner = (void*)(msg & (~1));
12288         msg_conv.is_owned = false;
12289         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12290         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12291 }
12292
12293 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) {
12294         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12295         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12296         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12297         LDKPublicKey their_node_id_ref;
12298         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12299         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12300         LDKFundingSigned msg_conv;
12301         msg_conv.inner = (void*)(msg & (~1));
12302         msg_conv.is_owned = false;
12303         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12304         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12305 }
12306
12307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12308         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12309         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12310         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12311         LDKPublicKey their_node_id_ref;
12312         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12313         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12314         LDKChannelReady msg_conv;
12315         msg_conv.inner = (void*)(msg & (~1));
12316         msg_conv.is_owned = false;
12317         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12318         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12319 }
12320
12321 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) {
12322         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12323         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12324         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12325         LDKPublicKey their_node_id_ref;
12326         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12327         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12328         LDKInitFeatures their_features_conv;
12329         their_features_conv.inner = (void*)(their_features & (~1));
12330         their_features_conv.is_owned = false;
12331         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12332         LDKShutdown msg_conv;
12333         msg_conv.inner = (void*)(msg & (~1));
12334         msg_conv.is_owned = false;
12335         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12336         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
12337 }
12338
12339 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) {
12340         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12341         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12342         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12343         LDKPublicKey their_node_id_ref;
12344         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12345         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12346         LDKClosingSigned msg_conv;
12347         msg_conv.inner = (void*)(msg & (~1));
12348         msg_conv.is_owned = false;
12349         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12350         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12351 }
12352
12353 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) {
12354         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12355         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12356         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12357         LDKPublicKey their_node_id_ref;
12358         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12359         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12360         LDKUpdateAddHTLC msg_conv;
12361         msg_conv.inner = (void*)(msg & (~1));
12362         msg_conv.is_owned = false;
12363         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12364         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12365 }
12366
12367 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) {
12368         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12369         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12370         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12371         LDKPublicKey their_node_id_ref;
12372         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12373         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12374         LDKUpdateFulfillHTLC msg_conv;
12375         msg_conv.inner = (void*)(msg & (~1));
12376         msg_conv.is_owned = false;
12377         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12378         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12379 }
12380
12381 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) {
12382         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12383         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12384         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12385         LDKPublicKey their_node_id_ref;
12386         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12387         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12388         LDKUpdateFailHTLC msg_conv;
12389         msg_conv.inner = (void*)(msg & (~1));
12390         msg_conv.is_owned = false;
12391         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12392         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12393 }
12394
12395 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) {
12396         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12397         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12398         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12399         LDKPublicKey their_node_id_ref;
12400         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12401         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12402         LDKUpdateFailMalformedHTLC msg_conv;
12403         msg_conv.inner = (void*)(msg & (~1));
12404         msg_conv.is_owned = false;
12405         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12406         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12407 }
12408
12409 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) {
12410         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12411         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12412         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12413         LDKPublicKey their_node_id_ref;
12414         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12415         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12416         LDKCommitmentSigned msg_conv;
12417         msg_conv.inner = (void*)(msg & (~1));
12418         msg_conv.is_owned = false;
12419         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12420         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12421 }
12422
12423 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) {
12424         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12425         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12426         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12427         LDKPublicKey their_node_id_ref;
12428         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12429         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12430         LDKRevokeAndACK msg_conv;
12431         msg_conv.inner = (void*)(msg & (~1));
12432         msg_conv.is_owned = false;
12433         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12434         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12435 }
12436
12437 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) {
12438         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12439         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12440         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12441         LDKPublicKey their_node_id_ref;
12442         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12443         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12444         LDKUpdateFee msg_conv;
12445         msg_conv.inner = (void*)(msg & (~1));
12446         msg_conv.is_owned = false;
12447         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12448         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12449 }
12450
12451 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) {
12452         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12453         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12454         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12455         LDKPublicKey their_node_id_ref;
12456         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12457         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12458         LDKAnnouncementSignatures msg_conv;
12459         msg_conv.inner = (void*)(msg & (~1));
12460         msg_conv.is_owned = false;
12461         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12462         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12463 }
12464
12465 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) {
12466         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12467         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12468         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12469         LDKPublicKey their_node_id_ref;
12470         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12471         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12472         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
12473 }
12474
12475 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) {
12476         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12477         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12478         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12479         LDKPublicKey their_node_id_ref;
12480         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12481         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12482         LDKInit msg_conv;
12483         msg_conv.inner = (void*)(msg & (~1));
12484         msg_conv.is_owned = false;
12485         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12486         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12487 }
12488
12489 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) {
12490         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12491         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12492         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12493         LDKPublicKey their_node_id_ref;
12494         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12495         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12496         LDKChannelReestablish msg_conv;
12497         msg_conv.inner = (void*)(msg & (~1));
12498         msg_conv.is_owned = false;
12499         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12500         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12501 }
12502
12503 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) {
12504         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12505         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12506         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12507         LDKPublicKey their_node_id_ref;
12508         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12509         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12510         LDKChannelUpdate msg_conv;
12511         msg_conv.inner = (void*)(msg & (~1));
12512         msg_conv.is_owned = false;
12513         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12514         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12515 }
12516
12517 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) {
12518         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12519         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12520         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12521         LDKPublicKey their_node_id_ref;
12522         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12523         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12524         LDKErrorMessage msg_conv;
12525         msg_conv.inner = (void*)(msg & (~1));
12526         msg_conv.is_owned = false;
12527         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12528         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12529 }
12530
12531 typedef struct LDKRoutingMessageHandler_JCalls {
12532         atomic_size_t refcnt;
12533         JavaVM *vm;
12534         jweak o;
12535         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12536         jmethodID handle_node_announcement_meth;
12537         jmethodID handle_channel_announcement_meth;
12538         jmethodID handle_channel_update_meth;
12539         jmethodID get_next_channel_announcements_meth;
12540         jmethodID get_next_node_announcements_meth;
12541         jmethodID peer_connected_meth;
12542         jmethodID handle_reply_channel_range_meth;
12543         jmethodID handle_reply_short_channel_ids_end_meth;
12544         jmethodID handle_query_channel_range_meth;
12545         jmethodID handle_query_short_channel_ids_meth;
12546 } LDKRoutingMessageHandler_JCalls;
12547 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
12548         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12549         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12550                 JNIEnv *env;
12551                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12552                 if (get_jenv_res == JNI_EDETACHED) {
12553                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12554                 } else {
12555                         DO_ASSERT(get_jenv_res == JNI_OK);
12556                 }
12557                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12558                 if (get_jenv_res == JNI_EDETACHED) {
12559                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12560                 }
12561                 FREE(j_calls);
12562         }
12563 }
12564 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
12565         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12566         JNIEnv *env;
12567         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12568         if (get_jenv_res == JNI_EDETACHED) {
12569                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12570         } else {
12571                 DO_ASSERT(get_jenv_res == JNI_OK);
12572         }
12573         LDKNodeAnnouncement msg_var = *msg;
12574         int64_t msg_ref = 0;
12575         msg_var = NodeAnnouncement_clone(&msg_var);
12576         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12577         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12578         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12579         msg_ref = (uintptr_t)msg_var.inner;
12580         if (msg_var.is_owned) {
12581                 msg_ref |= 1;
12582         }
12583         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12584         CHECK(obj != NULL);
12585         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
12586         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12587                 (*env)->ExceptionDescribe(env);
12588                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12589         }
12590         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12591         CHECK_ACCESS(ret_ptr);
12592         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12593         FREE((void*)ret);
12594         if (get_jenv_res == JNI_EDETACHED) {
12595                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12596         }
12597         return ret_conv;
12598 }
12599 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
12600         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12601         JNIEnv *env;
12602         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12603         if (get_jenv_res == JNI_EDETACHED) {
12604                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12605         } else {
12606                 DO_ASSERT(get_jenv_res == JNI_OK);
12607         }
12608         LDKChannelAnnouncement msg_var = *msg;
12609         int64_t msg_ref = 0;
12610         msg_var = ChannelAnnouncement_clone(&msg_var);
12611         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12612         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12613         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12614         msg_ref = (uintptr_t)msg_var.inner;
12615         if (msg_var.is_owned) {
12616                 msg_ref |= 1;
12617         }
12618         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12619         CHECK(obj != NULL);
12620         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
12621         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12622                 (*env)->ExceptionDescribe(env);
12623                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12624         }
12625         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12626         CHECK_ACCESS(ret_ptr);
12627         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12628         FREE((void*)ret);
12629         if (get_jenv_res == JNI_EDETACHED) {
12630                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12631         }
12632         return ret_conv;
12633 }
12634 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
12635         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12636         JNIEnv *env;
12637         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12638         if (get_jenv_res == JNI_EDETACHED) {
12639                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12640         } else {
12641                 DO_ASSERT(get_jenv_res == JNI_OK);
12642         }
12643         LDKChannelUpdate msg_var = *msg;
12644         int64_t msg_ref = 0;
12645         msg_var = ChannelUpdate_clone(&msg_var);
12646         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12647         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12648         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12649         msg_ref = (uintptr_t)msg_var.inner;
12650         if (msg_var.is_owned) {
12651                 msg_ref |= 1;
12652         }
12653         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12654         CHECK(obj != NULL);
12655         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
12656         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12657                 (*env)->ExceptionDescribe(env);
12658                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
12659         }
12660         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12661         CHECK_ACCESS(ret_ptr);
12662         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12663         FREE((void*)ret);
12664         if (get_jenv_res == JNI_EDETACHED) {
12665                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12666         }
12667         return ret_conv;
12668 }
12669 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
12670         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12671         JNIEnv *env;
12672         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12673         if (get_jenv_res == JNI_EDETACHED) {
12674                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12675         } else {
12676                 DO_ASSERT(get_jenv_res == JNI_OK);
12677         }
12678         int64_t starting_point_conv = starting_point;
12679         int8_t batch_amount_conv = batch_amount;
12680         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12681         CHECK(obj != NULL);
12682         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point_conv, batch_amount_conv);
12683         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12684                 (*env)->ExceptionDescribe(env);
12685                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
12686         }
12687         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
12688         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12689         if (ret_constr.datalen > 0)
12690                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
12691         else
12692                 ret_constr.data = NULL;
12693         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12694         for (size_t h = 0; h < ret_constr.datalen; h++) {
12695                 int64_t ret_conv_59 = ret_vals[h];
12696                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
12697                 CHECK_ACCESS(ret_conv_59_ptr);
12698                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
12699                 FREE((void*)ret_conv_59);
12700                 ret_constr.data[h] = ret_conv_59_conv;
12701         }
12702         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12703         if (get_jenv_res == JNI_EDETACHED) {
12704                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12705         }
12706         return ret_constr;
12707 }
12708 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
12709         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12710         JNIEnv *env;
12711         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12712         if (get_jenv_res == JNI_EDETACHED) {
12713                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12714         } else {
12715                 DO_ASSERT(get_jenv_res == JNI_OK);
12716         }
12717         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
12718         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
12719         int8_t batch_amount_conv = batch_amount;
12720         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12721         CHECK(obj != NULL);
12722         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount_conv);
12723         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12724                 (*env)->ExceptionDescribe(env);
12725                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
12726         }
12727         LDKCVec_NodeAnnouncementZ ret_constr;
12728         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12729         if (ret_constr.datalen > 0)
12730                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
12731         else
12732                 ret_constr.data = NULL;
12733         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12734         for (size_t s = 0; s < ret_constr.datalen; s++) {
12735                 int64_t ret_conv_18 = ret_vals[s];
12736                 LDKNodeAnnouncement ret_conv_18_conv;
12737                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
12738                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
12739                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
12740                 ret_constr.data[s] = ret_conv_18_conv;
12741         }
12742         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12743         if (get_jenv_res == JNI_EDETACHED) {
12744                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12745         }
12746         return ret_constr;
12747 }
12748 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
12749         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12750         JNIEnv *env;
12751         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12752         if (get_jenv_res == JNI_EDETACHED) {
12753                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12754         } else {
12755                 DO_ASSERT(get_jenv_res == JNI_OK);
12756         }
12757         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12758         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12759         LDKInit init_var = *init;
12760         int64_t init_ref = 0;
12761         init_var = Init_clone(&init_var);
12762         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12763         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12764         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
12765         init_ref = (uintptr_t)init_var.inner;
12766         if (init_var.is_owned) {
12767                 init_ref |= 1;
12768         }
12769         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12770         CHECK(obj != NULL);
12771         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
12772         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12773                 (*env)->ExceptionDescribe(env);
12774                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler 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 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
12781         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12782         JNIEnv *env;
12783         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12784         if (get_jenv_res == JNI_EDETACHED) {
12785                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12786         } else {
12787                 DO_ASSERT(get_jenv_res == JNI_OK);
12788         }
12789         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12790         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12791         LDKReplyChannelRange msg_var = msg;
12792         int64_t msg_ref = 0;
12793         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12794         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12795         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12796         msg_ref = (uintptr_t)msg_var.inner;
12797         if (msg_var.is_owned) {
12798                 msg_ref |= 1;
12799         }
12800         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12801         CHECK(obj != NULL);
12802         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
12803         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12804                 (*env)->ExceptionDescribe(env);
12805                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12806         }
12807         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12808         CHECK_ACCESS(ret_ptr);
12809         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12810         FREE((void*)ret);
12811         if (get_jenv_res == JNI_EDETACHED) {
12812                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12813         }
12814         return ret_conv;
12815 }
12816 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
12817         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12818         JNIEnv *env;
12819         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12820         if (get_jenv_res == JNI_EDETACHED) {
12821                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12822         } else {
12823                 DO_ASSERT(get_jenv_res == JNI_OK);
12824         }
12825         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12826         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12827         LDKReplyShortChannelIdsEnd msg_var = msg;
12828         int64_t msg_ref = 0;
12829         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12830         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12831         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12832         msg_ref = (uintptr_t)msg_var.inner;
12833         if (msg_var.is_owned) {
12834                 msg_ref |= 1;
12835         }
12836         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12837         CHECK(obj != NULL);
12838         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
12839         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12840                 (*env)->ExceptionDescribe(env);
12841                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
12842         }
12843         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12844         CHECK_ACCESS(ret_ptr);
12845         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12846         FREE((void*)ret);
12847         if (get_jenv_res == JNI_EDETACHED) {
12848                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12849         }
12850         return ret_conv;
12851 }
12852 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
12853         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12854         JNIEnv *env;
12855         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12856         if (get_jenv_res == JNI_EDETACHED) {
12857                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12858         } else {
12859                 DO_ASSERT(get_jenv_res == JNI_OK);
12860         }
12861         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12862         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12863         LDKQueryChannelRange msg_var = msg;
12864         int64_t msg_ref = 0;
12865         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12866         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12867         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12868         msg_ref = (uintptr_t)msg_var.inner;
12869         if (msg_var.is_owned) {
12870                 msg_ref |= 1;
12871         }
12872         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12873         CHECK(obj != NULL);
12874         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
12875         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12876                 (*env)->ExceptionDescribe(env);
12877                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12878         }
12879         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12880         CHECK_ACCESS(ret_ptr);
12881         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12882         FREE((void*)ret);
12883         if (get_jenv_res == JNI_EDETACHED) {
12884                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12885         }
12886         return ret_conv;
12887 }
12888 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
12889         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12890         JNIEnv *env;
12891         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12892         if (get_jenv_res == JNI_EDETACHED) {
12893                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12894         } else {
12895                 DO_ASSERT(get_jenv_res == JNI_OK);
12896         }
12897         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12898         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12899         LDKQueryShortChannelIds msg_var = msg;
12900         int64_t msg_ref = 0;
12901         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12902         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12903         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12904         msg_ref = (uintptr_t)msg_var.inner;
12905         if (msg_var.is_owned) {
12906                 msg_ref |= 1;
12907         }
12908         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12909         CHECK(obj != NULL);
12910         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
12911         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12912                 (*env)->ExceptionDescribe(env);
12913                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
12914         }
12915         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12916         CHECK_ACCESS(ret_ptr);
12917         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12918         FREE((void*)ret);
12919         if (get_jenv_res == JNI_EDETACHED) {
12920                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12921         }
12922         return ret_conv;
12923 }
12924 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
12925         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
12926         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12927         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12928 }
12929 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12930         jclass c = (*env)->GetObjectClass(env, o);
12931         CHECK(c != NULL);
12932         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
12933         atomic_init(&calls->refcnt, 1);
12934         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12935         calls->o = (*env)->NewWeakGlobalRef(env, o);
12936         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
12937         CHECK(calls->handle_node_announcement_meth != NULL);
12938         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
12939         CHECK(calls->handle_channel_announcement_meth != NULL);
12940         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
12941         CHECK(calls->handle_channel_update_meth != NULL);
12942         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
12943         CHECK(calls->get_next_channel_announcements_meth != NULL);
12944         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
12945         CHECK(calls->get_next_node_announcements_meth != NULL);
12946         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
12947         CHECK(calls->peer_connected_meth != NULL);
12948         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
12949         CHECK(calls->handle_reply_channel_range_meth != NULL);
12950         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
12951         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
12952         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
12953         CHECK(calls->handle_query_channel_range_meth != NULL);
12954         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
12955         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
12956
12957         LDKRoutingMessageHandler ret = {
12958                 .this_arg = (void*) calls,
12959                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
12960                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
12961                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
12962                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
12963                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
12964                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
12965                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
12966                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
12967                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
12968                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
12969                 .free = LDKRoutingMessageHandler_JCalls_free,
12970                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12971         };
12972         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12973         return ret;
12974 }
12975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12976         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
12977         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12978         return (uint64_t)res_ptr;
12979 }
12980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12981         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
12982         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
12983         DO_ASSERT((res_ptr & 1) == 0);
12984         return (int64_t)(res_ptr | 1);
12985 }
12986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12987         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12988         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12989         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12990         LDKNodeAnnouncement msg_conv;
12991         msg_conv.inner = (void*)(msg & (~1));
12992         msg_conv.is_owned = false;
12993         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12994         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12995         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
12996         return (int64_t)ret_conv;
12997 }
12998
12999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13000         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13001         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13002         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13003         LDKChannelAnnouncement msg_conv;
13004         msg_conv.inner = (void*)(msg & (~1));
13005         msg_conv.is_owned = false;
13006         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13007         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13008         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
13009         return (int64_t)ret_conv;
13010 }
13011
13012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13013         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13014         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13015         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13016         LDKChannelUpdate msg_conv;
13017         msg_conv.inner = (void*)(msg & (~1));
13018         msg_conv.is_owned = false;
13019         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13020         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13021         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
13022         return (int64_t)ret_conv;
13023 }
13024
13025 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) {
13026         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13027         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13028         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13029         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
13030         int64_tArray ret_arr = NULL;
13031         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13032         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13033         for (size_t h = 0; h < ret_var.datalen; h++) {
13034                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13035                 *ret_conv_59_conv = ret_var.data[h];
13036                 ret_arr_ptr[h] = ((int64_t)ret_conv_59_conv);
13037         }
13038         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13039         FREE(ret_var.data);
13040         return ret_arr;
13041 }
13042
13043 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) {
13044         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13045         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13046         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13047         LDKPublicKey starting_point_ref;
13048         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
13049         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
13050         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
13051         int64_tArray ret_arr = NULL;
13052         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13053         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13054         for (size_t s = 0; s < ret_var.datalen; s++) {
13055                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
13056                 int64_t ret_conv_18_ref = 0;
13057                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13058                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13059                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
13060                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
13061                 if (ret_conv_18_var.is_owned) {
13062                         ret_conv_18_ref |= 1;
13063                 }
13064                 ret_arr_ptr[s] = ret_conv_18_ref;
13065         }
13066         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13067         FREE(ret_var.data);
13068         return ret_arr;
13069 }
13070
13071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1peer_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) {
13072         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13073         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13074         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13075         LDKPublicKey their_node_id_ref;
13076         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13077         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13078         LDKInit init_conv;
13079         init_conv.inner = (void*)(init & (~1));
13080         init_conv.is_owned = false;
13081         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13082         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13083 }
13084
13085 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) {
13086         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13087         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13088         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13089         LDKPublicKey their_node_id_ref;
13090         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13091         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13092         LDKReplyChannelRange msg_conv;
13093         msg_conv.inner = (void*)(msg & (~1));
13094         msg_conv.is_owned = (msg & 1) || (msg == 0);
13095         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13096         msg_conv = ReplyChannelRange_clone(&msg_conv);
13097         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13098         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13099         return (int64_t)ret_conv;
13100 }
13101
13102 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) {
13103         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13104         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13105         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13106         LDKPublicKey their_node_id_ref;
13107         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13108         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13109         LDKReplyShortChannelIdsEnd msg_conv;
13110         msg_conv.inner = (void*)(msg & (~1));
13111         msg_conv.is_owned = (msg & 1) || (msg == 0);
13112         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13113         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
13114         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13115         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13116         return (int64_t)ret_conv;
13117 }
13118
13119 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) {
13120         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13121         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13122         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13123         LDKPublicKey their_node_id_ref;
13124         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13125         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13126         LDKQueryChannelRange msg_conv;
13127         msg_conv.inner = (void*)(msg & (~1));
13128         msg_conv.is_owned = (msg & 1) || (msg == 0);
13129         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13130         msg_conv = QueryChannelRange_clone(&msg_conv);
13131         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13132         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13133         return (int64_t)ret_conv;
13134 }
13135
13136 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) {
13137         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13138         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13139         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13140         LDKPublicKey their_node_id_ref;
13141         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13142         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13143         LDKQueryShortChannelIds msg_conv;
13144         msg_conv.inner = (void*)(msg & (~1));
13145         msg_conv.is_owned = (msg & 1) || (msg == 0);
13146         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13147         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13148         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13149         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13150         return (int64_t)ret_conv;
13151 }
13152
13153 typedef struct LDKCustomMessageReader_JCalls {
13154         atomic_size_t refcnt;
13155         JavaVM *vm;
13156         jweak o;
13157         jmethodID read_meth;
13158 } LDKCustomMessageReader_JCalls;
13159 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
13160         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13161         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13162                 JNIEnv *env;
13163                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13164                 if (get_jenv_res == JNI_EDETACHED) {
13165                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13166                 } else {
13167                         DO_ASSERT(get_jenv_res == JNI_OK);
13168                 }
13169                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13170                 if (get_jenv_res == JNI_EDETACHED) {
13171                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13172                 }
13173                 FREE(j_calls);
13174         }
13175 }
13176 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
13177         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13178         JNIEnv *env;
13179         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13180         if (get_jenv_res == JNI_EDETACHED) {
13181                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13182         } else {
13183                 DO_ASSERT(get_jenv_res == JNI_OK);
13184         }
13185         int16_t message_type_conv = message_type;
13186         LDKu8slice buffer_var = buffer;
13187         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
13188         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
13189         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13190         CHECK(obj != NULL);
13191         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
13192         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13193                 (*env)->ExceptionDescribe(env);
13194                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
13195         }
13196         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13197         CHECK_ACCESS(ret_ptr);
13198         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
13199         FREE((void*)ret);
13200         if (get_jenv_res == JNI_EDETACHED) {
13201                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13202         }
13203         return ret_conv;
13204 }
13205 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
13206         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
13207         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13208 }
13209 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
13210         jclass c = (*env)->GetObjectClass(env, o);
13211         CHECK(c != NULL);
13212         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
13213         atomic_init(&calls->refcnt, 1);
13214         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13215         calls->o = (*env)->NewWeakGlobalRef(env, o);
13216         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
13217         CHECK(calls->read_meth != NULL);
13218
13219         LDKCustomMessageReader ret = {
13220                 .this_arg = (void*) calls,
13221                 .read = read_LDKCustomMessageReader_jcall,
13222                 .free = LDKCustomMessageReader_JCalls_free,
13223         };
13224         return ret;
13225 }
13226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
13227         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
13228         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
13229         return (uint64_t)res_ptr;
13230 }
13231 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) {
13232         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13233         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13234         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
13235         LDKu8slice buffer_ref;
13236         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
13237         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
13238         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
13239         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
13240         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
13241         return (int64_t)ret_conv;
13242 }
13243
13244 typedef struct LDKCustomMessageHandler_JCalls {
13245         atomic_size_t refcnt;
13246         JavaVM *vm;
13247         jweak o;
13248         LDKCustomMessageReader_JCalls* CustomMessageReader;
13249         jmethodID handle_custom_message_meth;
13250         jmethodID get_and_clear_pending_msg_meth;
13251 } LDKCustomMessageHandler_JCalls;
13252 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
13253         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13254         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13255                 JNIEnv *env;
13256                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13257                 if (get_jenv_res == JNI_EDETACHED) {
13258                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13259                 } else {
13260                         DO_ASSERT(get_jenv_res == JNI_OK);
13261                 }
13262                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13263                 if (get_jenv_res == JNI_EDETACHED) {
13264                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13265                 }
13266                 FREE(j_calls);
13267         }
13268 }
13269 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
13270         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13271         JNIEnv *env;
13272         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13273         if (get_jenv_res == JNI_EDETACHED) {
13274                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13275         } else {
13276                 DO_ASSERT(get_jenv_res == JNI_OK);
13277         }
13278         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
13279         *msg_ret = msg;
13280         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
13281         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
13282         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13283         CHECK(obj != NULL);
13284         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (int64_t)msg_ret, sender_node_id_arr);
13285         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13286                 (*env)->ExceptionDescribe(env);
13287                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
13288         }
13289         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13290         CHECK_ACCESS(ret_ptr);
13291         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13292         FREE((void*)ret);
13293         if (get_jenv_res == JNI_EDETACHED) {
13294                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13295         }
13296         return ret_conv;
13297 }
13298 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
13299         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13300         JNIEnv *env;
13301         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13302         if (get_jenv_res == JNI_EDETACHED) {
13303                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13304         } else {
13305                 DO_ASSERT(get_jenv_res == JNI_OK);
13306         }
13307         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13308         CHECK(obj != NULL);
13309         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
13310         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13311                 (*env)->ExceptionDescribe(env);
13312                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
13313         }
13314         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
13315         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13316         if (ret_constr.datalen > 0)
13317                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13318         else
13319                 ret_constr.data = NULL;
13320         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13321         for (size_t z = 0; z < ret_constr.datalen; z++) {
13322                 int64_t ret_conv_25 = ret_vals[z];
13323                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
13324                 CHECK_ACCESS(ret_conv_25_ptr);
13325                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
13326                 FREE((void*)ret_conv_25);
13327                 ret_constr.data[z] = ret_conv_25_conv;
13328         }
13329         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13330         if (get_jenv_res == JNI_EDETACHED) {
13331                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13332         }
13333         return ret_constr;
13334 }
13335 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
13336         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
13337         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13338         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
13339 }
13340 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13341         jclass c = (*env)->GetObjectClass(env, o);
13342         CHECK(c != NULL);
13343         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
13344         atomic_init(&calls->refcnt, 1);
13345         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13346         calls->o = (*env)->NewWeakGlobalRef(env, o);
13347         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
13348         CHECK(calls->handle_custom_message_meth != NULL);
13349         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
13350         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
13351
13352         LDKCustomMessageHandler ret = {
13353                 .this_arg = (void*) calls,
13354                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
13355                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
13356                 .free = LDKCustomMessageHandler_JCalls_free,
13357                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
13358         };
13359         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
13360         return ret;
13361 }
13362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13363         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
13364         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
13365         return (uint64_t)res_ptr;
13366 }
13367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
13368         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
13369         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
13370         DO_ASSERT((res_ptr & 1) == 0);
13371         return (int64_t)(res_ptr | 1);
13372 }
13373 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) {
13374         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13375         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13376         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13377         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
13378         CHECK_ACCESS(msg_ptr);
13379         LDKType msg_conv = *(LDKType*)(msg_ptr);
13380         if (msg_conv.free == LDKType_JCalls_free) {
13381                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13382                 LDKType_JCalls_cloned(&msg_conv);
13383         }
13384         LDKPublicKey sender_node_id_ref;
13385         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
13386         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
13387         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13388         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
13389         return (int64_t)ret_conv;
13390 }
13391
13392 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
13393         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13394         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13395         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13396         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
13397         int64_tArray ret_arr = NULL;
13398         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13399         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13400         for (size_t z = 0; z < ret_var.datalen; z++) {
13401                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13402                 *ret_conv_25_conv = ret_var.data[z];
13403                 ret_arr_ptr[z] = ((int64_t)ret_conv_25_conv);
13404         }
13405         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13406         FREE(ret_var.data);
13407         return ret_arr;
13408 }
13409
13410 typedef struct LDKSocketDescriptor_JCalls {
13411         atomic_size_t refcnt;
13412         JavaVM *vm;
13413         jweak o;
13414         jmethodID send_data_meth;
13415         jmethodID disconnect_socket_meth;
13416         jmethodID eq_meth;
13417         jmethodID hash_meth;
13418 } LDKSocketDescriptor_JCalls;
13419 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
13420         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13421         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13422                 JNIEnv *env;
13423                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13424                 if (get_jenv_res == JNI_EDETACHED) {
13425                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13426                 } else {
13427                         DO_ASSERT(get_jenv_res == JNI_OK);
13428                 }
13429                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13430                 if (get_jenv_res == JNI_EDETACHED) {
13431                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13432                 }
13433                 FREE(j_calls);
13434         }
13435 }
13436 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
13437         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13438         JNIEnv *env;
13439         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13440         if (get_jenv_res == JNI_EDETACHED) {
13441                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13442         } else {
13443                 DO_ASSERT(get_jenv_res == JNI_OK);
13444         }
13445         LDKu8slice data_var = data;
13446         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
13447         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
13448         jboolean resume_read_conv = resume_read;
13449         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13450         CHECK(obj != NULL);
13451         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
13452         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13453                 (*env)->ExceptionDescribe(env);
13454                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
13455         }
13456         if (get_jenv_res == JNI_EDETACHED) {
13457                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13458         }
13459         return ret;
13460 }
13461 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
13462         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13463         JNIEnv *env;
13464         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13465         if (get_jenv_res == JNI_EDETACHED) {
13466                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13467         } else {
13468                 DO_ASSERT(get_jenv_res == JNI_OK);
13469         }
13470         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13471         CHECK(obj != NULL);
13472         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
13473         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13474                 (*env)->ExceptionDescribe(env);
13475                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
13476         }
13477         if (get_jenv_res == JNI_EDETACHED) {
13478                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13479         }
13480 }
13481 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
13482         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13483         JNIEnv *env;
13484         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13485         if (get_jenv_res == JNI_EDETACHED) {
13486                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13487         } else {
13488                 DO_ASSERT(get_jenv_res == JNI_OK);
13489         }
13490         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
13491         *other_arg_clone = SocketDescriptor_clone(other_arg);
13492         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13493         CHECK(obj != NULL);
13494         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (int64_t)other_arg_clone);
13495         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13496                 (*env)->ExceptionDescribe(env);
13497                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
13498         }
13499         if (get_jenv_res == JNI_EDETACHED) {
13500                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13501         }
13502         return ret;
13503 }
13504 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
13505         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13506         JNIEnv *env;
13507         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13508         if (get_jenv_res == JNI_EDETACHED) {
13509                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13510         } else {
13511                 DO_ASSERT(get_jenv_res == JNI_OK);
13512         }
13513         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13514         CHECK(obj != NULL);
13515         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
13516         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13517                 (*env)->ExceptionDescribe(env);
13518                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
13519         }
13520         if (get_jenv_res == JNI_EDETACHED) {
13521                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13522         }
13523         return ret;
13524 }
13525 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
13526         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
13527         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13528 }
13529 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
13530         jclass c = (*env)->GetObjectClass(env, o);
13531         CHECK(c != NULL);
13532         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
13533         atomic_init(&calls->refcnt, 1);
13534         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13535         calls->o = (*env)->NewWeakGlobalRef(env, o);
13536         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
13537         CHECK(calls->send_data_meth != NULL);
13538         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
13539         CHECK(calls->disconnect_socket_meth != NULL);
13540         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
13541         CHECK(calls->eq_meth != NULL);
13542         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
13543         CHECK(calls->hash_meth != NULL);
13544
13545         LDKSocketDescriptor ret = {
13546                 .this_arg = (void*) calls,
13547                 .send_data = send_data_LDKSocketDescriptor_jcall,
13548                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
13549                 .eq = eq_LDKSocketDescriptor_jcall,
13550                 .hash = hash_LDKSocketDescriptor_jcall,
13551                 .cloned = LDKSocketDescriptor_JCalls_cloned,
13552                 .free = LDKSocketDescriptor_JCalls_free,
13553         };
13554         return ret;
13555 }
13556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
13557         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
13558         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
13559         return (uint64_t)res_ptr;
13560 }
13561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1data(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray data, jboolean resume_read) {
13562         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13563         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13564         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
13565         LDKu8slice data_ref;
13566         data_ref.datalen = (*env)->GetArrayLength(env, data);
13567         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
13568         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
13569         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
13570         return ret_conv;
13571 }
13572
13573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
13574         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13575         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13576         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
13577         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
13578 }
13579
13580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
13581         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13582         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13583         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
13584         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
13585         return ret_conv;
13586 }
13587
13588 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
13589 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
13590 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
13591 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
13592 static jclass LDKEffectiveCapacity_Total_class = NULL;
13593 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
13594 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
13595 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
13596 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
13597 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
13598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
13599         LDKEffectiveCapacity_ExactLiquidity_class =
13600                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
13601         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
13602         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
13603         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
13604         LDKEffectiveCapacity_MaximumHTLC_class =
13605                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
13606         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
13607         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
13608         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
13609         LDKEffectiveCapacity_Total_class =
13610                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
13611         CHECK(LDKEffectiveCapacity_Total_class != NULL);
13612         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(J)V");
13613         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
13614         LDKEffectiveCapacity_Infinite_class =
13615                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
13616         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
13617         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
13618         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
13619         LDKEffectiveCapacity_Unknown_class =
13620                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
13621         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
13622         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
13623         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
13624 }
13625 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13626         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
13627         switch(obj->tag) {
13628                 case LDKEffectiveCapacity_ExactLiquidity: {
13629                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
13630                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
13631                 }
13632                 case LDKEffectiveCapacity_MaximumHTLC: {
13633                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
13634                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
13635                 }
13636                 case LDKEffectiveCapacity_Total: {
13637                         int64_t capacity_msat_conv = obj->total.capacity_msat;
13638                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv);
13639                 }
13640                 case LDKEffectiveCapacity_Infinite: {
13641                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
13642                 }
13643                 case LDKEffectiveCapacity_Unknown: {
13644                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
13645                 }
13646                 default: abort();
13647         }
13648 }
13649 typedef struct LDKLockableScore_JCalls {
13650         atomic_size_t refcnt;
13651         JavaVM *vm;
13652         jweak o;
13653         jmethodID lock_meth;
13654 } LDKLockableScore_JCalls;
13655 static void LDKLockableScore_JCalls_free(void* this_arg) {
13656         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
13657         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13658                 JNIEnv *env;
13659                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13660                 if (get_jenv_res == JNI_EDETACHED) {
13661                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13662                 } else {
13663                         DO_ASSERT(get_jenv_res == JNI_OK);
13664                 }
13665                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13666                 if (get_jenv_res == JNI_EDETACHED) {
13667                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13668                 }
13669                 FREE(j_calls);
13670         }
13671 }
13672 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
13673         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
13674         JNIEnv *env;
13675         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13676         if (get_jenv_res == JNI_EDETACHED) {
13677                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13678         } else {
13679                 DO_ASSERT(get_jenv_res == JNI_OK);
13680         }
13681         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13682         CHECK(obj != NULL);
13683         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
13684         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13685                 (*env)->ExceptionDescribe(env);
13686                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
13687         }
13688         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13689         CHECK_ACCESS(ret_ptr);
13690         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
13691         if (ret_conv.free == LDKScore_JCalls_free) {
13692                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13693                 LDKScore_JCalls_cloned(&ret_conv);
13694         }// WARNING: we may need a move here but no clone is available for LDKScore
13695         
13696         if (get_jenv_res == JNI_EDETACHED) {
13697                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13698         }
13699         return ret_conv;
13700 }
13701 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
13702         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
13703         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13704 }
13705 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
13706         jclass c = (*env)->GetObjectClass(env, o);
13707         CHECK(c != NULL);
13708         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
13709         atomic_init(&calls->refcnt, 1);
13710         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13711         calls->o = (*env)->NewWeakGlobalRef(env, o);
13712         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
13713         CHECK(calls->lock_meth != NULL);
13714
13715         LDKLockableScore ret = {
13716                 .this_arg = (void*) calls,
13717                 .lock = lock_LDKLockableScore_jcall,
13718                 .free = LDKLockableScore_JCalls_free,
13719         };
13720         return ret;
13721 }
13722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
13723         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
13724         *res_ptr = LDKLockableScore_init(env, clz, o);
13725         return (uint64_t)res_ptr;
13726 }
13727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
13728         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13729         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13730         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
13731         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
13732         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
13733         return (int64_t)ret_ret;
13734 }
13735
13736 static jclass LDKGossipSync_P2P_class = NULL;
13737 static jmethodID LDKGossipSync_P2P_meth = NULL;
13738 static jclass LDKGossipSync_Rapid_class = NULL;
13739 static jmethodID LDKGossipSync_Rapid_meth = NULL;
13740 static jclass LDKGossipSync_None_class = NULL;
13741 static jmethodID LDKGossipSync_None_meth = NULL;
13742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
13743         LDKGossipSync_P2P_class =
13744                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
13745         CHECK(LDKGossipSync_P2P_class != NULL);
13746         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
13747         CHECK(LDKGossipSync_P2P_meth != NULL);
13748         LDKGossipSync_Rapid_class =
13749                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
13750         CHECK(LDKGossipSync_Rapid_class != NULL);
13751         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
13752         CHECK(LDKGossipSync_Rapid_meth != NULL);
13753         LDKGossipSync_None_class =
13754                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
13755         CHECK(LDKGossipSync_None_class != NULL);
13756         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
13757         CHECK(LDKGossipSync_None_meth != NULL);
13758 }
13759 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13760         LDKGossipSync *obj = (LDKGossipSync*)(ptr & ~1);
13761         switch(obj->tag) {
13762                 case LDKGossipSync_P2P: {
13763                         LDKP2PGossipSync p2p_var = obj->p2p;
13764                         int64_t p2p_ref = 0;
13765                         CHECK((((uintptr_t)p2p_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13766                         CHECK((((uintptr_t)&p2p_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13767                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
13768                         p2p_ref = (uintptr_t)p2p_var.inner & ~1;
13769                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
13770                 }
13771                 case LDKGossipSync_Rapid: {
13772                         LDKRapidGossipSync rapid_var = obj->rapid;
13773                         int64_t rapid_ref = 0;
13774                         CHECK((((uintptr_t)rapid_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13775                         CHECK((((uintptr_t)&rapid_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13776                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
13777                         rapid_ref = (uintptr_t)rapid_var.inner & ~1;
13778                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
13779                 }
13780                 case LDKGossipSync_None: {
13781                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
13782                 }
13783                 default: abort();
13784         }
13785 }
13786 static jclass LDKFallback_SegWitProgram_class = NULL;
13787 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
13788 static jclass LDKFallback_PubKeyHash_class = NULL;
13789 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
13790 static jclass LDKFallback_ScriptHash_class = NULL;
13791 static jmethodID LDKFallback_ScriptHash_meth = NULL;
13792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
13793         LDKFallback_SegWitProgram_class =
13794                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
13795         CHECK(LDKFallback_SegWitProgram_class != NULL);
13796         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
13797         CHECK(LDKFallback_SegWitProgram_meth != NULL);
13798         LDKFallback_PubKeyHash_class =
13799                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
13800         CHECK(LDKFallback_PubKeyHash_class != NULL);
13801         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
13802         CHECK(LDKFallback_PubKeyHash_meth != NULL);
13803         LDKFallback_ScriptHash_class =
13804                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
13805         CHECK(LDKFallback_ScriptHash_class != NULL);
13806         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
13807         CHECK(LDKFallback_ScriptHash_meth != NULL);
13808 }
13809 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13810         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
13811         switch(obj->tag) {
13812                 case LDKFallback_SegWitProgram: {
13813                         uint8_t version_val = obj->seg_wit_program.version._0;
13814                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
13815                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
13816                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
13817                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
13818                 }
13819                 case LDKFallback_PubKeyHash: {
13820                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
13821                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
13822                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
13823                 }
13824                 case LDKFallback_ScriptHash: {
13825                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
13826                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
13827                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
13828                 }
13829                 default: abort();
13830         }
13831 }
13832 typedef struct LDKPayer_JCalls {
13833         atomic_size_t refcnt;
13834         JavaVM *vm;
13835         jweak o;
13836         jmethodID node_id_meth;
13837         jmethodID first_hops_meth;
13838         jmethodID send_payment_meth;
13839         jmethodID send_spontaneous_payment_meth;
13840         jmethodID retry_payment_meth;
13841         jmethodID abandon_payment_meth;
13842 } LDKPayer_JCalls;
13843 static void LDKPayer_JCalls_free(void* this_arg) {
13844         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13845         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13846                 JNIEnv *env;
13847                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13848                 if (get_jenv_res == JNI_EDETACHED) {
13849                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13850                 } else {
13851                         DO_ASSERT(get_jenv_res == JNI_OK);
13852                 }
13853                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13854                 if (get_jenv_res == JNI_EDETACHED) {
13855                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13856                 }
13857                 FREE(j_calls);
13858         }
13859 }
13860 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
13861         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13862         JNIEnv *env;
13863         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13864         if (get_jenv_res == JNI_EDETACHED) {
13865                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13866         } else {
13867                 DO_ASSERT(get_jenv_res == JNI_OK);
13868         }
13869         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13870         CHECK(obj != NULL);
13871         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
13872         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13873                 (*env)->ExceptionDescribe(env);
13874                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
13875         }
13876         LDKPublicKey ret_ref;
13877         CHECK((*env)->GetArrayLength(env, ret) == 33);
13878         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
13879         if (get_jenv_res == JNI_EDETACHED) {
13880                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13881         }
13882         return ret_ref;
13883 }
13884 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
13885         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13886         JNIEnv *env;
13887         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13888         if (get_jenv_res == JNI_EDETACHED) {
13889                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13890         } else {
13891                 DO_ASSERT(get_jenv_res == JNI_OK);
13892         }
13893         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13894         CHECK(obj != NULL);
13895         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
13896         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13897                 (*env)->ExceptionDescribe(env);
13898                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
13899         }
13900         LDKCVec_ChannelDetailsZ ret_constr;
13901         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13902         if (ret_constr.datalen > 0)
13903                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13904         else
13905                 ret_constr.data = NULL;
13906         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13907         for (size_t q = 0; q < ret_constr.datalen; q++) {
13908                 int64_t ret_conv_16 = ret_vals[q];
13909                 LDKChannelDetails ret_conv_16_conv;
13910                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
13911                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
13912                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
13913                 ret_constr.data[q] = ret_conv_16_conv;
13914         }
13915         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13916         if (get_jenv_res == JNI_EDETACHED) {
13917                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13918         }
13919         return ret_constr;
13920 }
13921 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
13922         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13923         JNIEnv *env;
13924         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13925         if (get_jenv_res == JNI_EDETACHED) {
13926                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13927         } else {
13928                 DO_ASSERT(get_jenv_res == JNI_OK);
13929         }
13930         LDKRoute route_var = *route;
13931         int64_t route_ref = 0;
13932         route_var = Route_clone(&route_var);
13933         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13934         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13935         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13936         route_ref = (uintptr_t)route_var.inner;
13937         if (route_var.is_owned) {
13938                 route_ref |= 1;
13939         }
13940         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
13941         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
13942         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
13943         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
13944         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13945         CHECK(obj != NULL);
13946         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
13947         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13948                 (*env)->ExceptionDescribe(env);
13949                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
13950         }
13951         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13952         CHECK_ACCESS(ret_ptr);
13953         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
13954         FREE((void*)ret);
13955         if (get_jenv_res == JNI_EDETACHED) {
13956                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13957         }
13958         return ret_conv;
13959 }
13960 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
13961         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13962         JNIEnv *env;
13963         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13964         if (get_jenv_res == JNI_EDETACHED) {
13965                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13966         } else {
13967                 DO_ASSERT(get_jenv_res == JNI_OK);
13968         }
13969         LDKRoute route_var = *route;
13970         int64_t route_ref = 0;
13971         route_var = Route_clone(&route_var);
13972         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13973         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13974         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13975         route_ref = (uintptr_t)route_var.inner;
13976         if (route_var.is_owned) {
13977                 route_ref |= 1;
13978         }
13979         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
13980         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
13981         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13982         CHECK(obj != NULL);
13983         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
13984         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13985                 (*env)->ExceptionDescribe(env);
13986                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
13987         }
13988         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13989         CHECK_ACCESS(ret_ptr);
13990         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
13991         FREE((void*)ret);
13992         if (get_jenv_res == JNI_EDETACHED) {
13993                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13994         }
13995         return ret_conv;
13996 }
13997 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
13998         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13999         JNIEnv *env;
14000         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14001         if (get_jenv_res == JNI_EDETACHED) {
14002                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14003         } else {
14004                 DO_ASSERT(get_jenv_res == JNI_OK);
14005         }
14006         LDKRoute route_var = *route;
14007         int64_t route_ref = 0;
14008         route_var = Route_clone(&route_var);
14009         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14010         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14011         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14012         route_ref = (uintptr_t)route_var.inner;
14013         if (route_var.is_owned) {
14014                 route_ref |= 1;
14015         }
14016         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14017         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14018         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14019         CHECK(obj != NULL);
14020         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
14021         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14022                 (*env)->ExceptionDescribe(env);
14023                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
14024         }
14025         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14026         CHECK_ACCESS(ret_ptr);
14027         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
14028         FREE((void*)ret);
14029         if (get_jenv_res == JNI_EDETACHED) {
14030                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14031         }
14032         return ret_conv;
14033 }
14034 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
14035         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14036         JNIEnv *env;
14037         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14038         if (get_jenv_res == JNI_EDETACHED) {
14039                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14040         } else {
14041                 DO_ASSERT(get_jenv_res == JNI_OK);
14042         }
14043         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14044         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14045         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14046         CHECK(obj != NULL);
14047         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
14048         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14049                 (*env)->ExceptionDescribe(env);
14050                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
14051         }
14052         if (get_jenv_res == JNI_EDETACHED) {
14053                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14054         }
14055 }
14056 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
14057         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
14058         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14059 }
14060 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
14061         jclass c = (*env)->GetObjectClass(env, o);
14062         CHECK(c != NULL);
14063         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
14064         atomic_init(&calls->refcnt, 1);
14065         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14066         calls->o = (*env)->NewWeakGlobalRef(env, o);
14067         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
14068         CHECK(calls->node_id_meth != NULL);
14069         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
14070         CHECK(calls->first_hops_meth != NULL);
14071         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
14072         CHECK(calls->send_payment_meth != NULL);
14073         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
14074         CHECK(calls->send_spontaneous_payment_meth != NULL);
14075         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
14076         CHECK(calls->retry_payment_meth != NULL);
14077         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
14078         CHECK(calls->abandon_payment_meth != NULL);
14079
14080         LDKPayer ret = {
14081                 .this_arg = (void*) calls,
14082                 .node_id = node_id_LDKPayer_jcall,
14083                 .first_hops = first_hops_LDKPayer_jcall,
14084                 .send_payment = send_payment_LDKPayer_jcall,
14085                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
14086                 .retry_payment = retry_payment_LDKPayer_jcall,
14087                 .abandon_payment = abandon_payment_LDKPayer_jcall,
14088                 .free = LDKPayer_JCalls_free,
14089         };
14090         return ret;
14091 }
14092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
14093         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
14094         *res_ptr = LDKPayer_init(env, clz, o);
14095         return (uint64_t)res_ptr;
14096 }
14097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14098         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14099         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14100         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14101         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14102         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
14103         return ret_arr;
14104 }
14105
14106 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
14107         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14108         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14109         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14110         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
14111         int64_tArray ret_arr = NULL;
14112         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14113         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14114         for (size_t q = 0; q < ret_var.datalen; q++) {
14115                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
14116                 int64_t ret_conv_16_ref = 0;
14117                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14118                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14119                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
14120                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
14121                 if (ret_conv_16_var.is_owned) {
14122                         ret_conv_16_ref |= 1;
14123                 }
14124                 ret_arr_ptr[q] = ret_conv_16_ref;
14125         }
14126         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14127         FREE(ret_var.data);
14128         return ret_arr;
14129 }
14130
14131 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) {
14132         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14133         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14134         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14135         LDKRoute route_conv;
14136         route_conv.inner = (void*)(route & (~1));
14137         route_conv.is_owned = false;
14138         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14139         LDKThirtyTwoBytes payment_hash_ref;
14140         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14141         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
14142         LDKThirtyTwoBytes payment_secret_ref;
14143         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
14144         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
14145         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14146         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
14147         return (int64_t)ret_conv;
14148 }
14149
14150 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) {
14151         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14152         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14153         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14154         LDKRoute route_conv;
14155         route_conv.inner = (void*)(route & (~1));
14156         route_conv.is_owned = false;
14157         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14158         LDKThirtyTwoBytes payment_preimage_ref;
14159         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
14160         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
14161         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14162         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
14163         return (int64_t)ret_conv;
14164 }
14165
14166 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) {
14167         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14168         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14169         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14170         LDKRoute route_conv;
14171         route_conv.inner = (void*)(route & (~1));
14172         route_conv.is_owned = false;
14173         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14174         LDKThirtyTwoBytes payment_id_ref;
14175         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14176         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14177         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14178         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
14179         return (int64_t)ret_conv;
14180 }
14181
14182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
14183         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14184         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14185         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14186         LDKThirtyTwoBytes payment_id_ref;
14187         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14188         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14189         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
14190 }
14191
14192 typedef struct LDKRouter_JCalls {
14193         atomic_size_t refcnt;
14194         JavaVM *vm;
14195         jweak o;
14196         jmethodID find_route_meth;
14197 } LDKRouter_JCalls;
14198 static void LDKRouter_JCalls_free(void* this_arg) {
14199         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14200         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14201                 JNIEnv *env;
14202                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14203                 if (get_jenv_res == JNI_EDETACHED) {
14204                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14205                 } else {
14206                         DO_ASSERT(get_jenv_res == JNI_OK);
14207                 }
14208                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14209                 if (get_jenv_res == JNI_EDETACHED) {
14210                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14211                 }
14212                 FREE(j_calls);
14213         }
14214 }
14215 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, const uint8_t (* payment_hash)[32], LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
14216         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14217         JNIEnv *env;
14218         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14219         if (get_jenv_res == JNI_EDETACHED) {
14220                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14221         } else {
14222                 DO_ASSERT(get_jenv_res == JNI_OK);
14223         }
14224         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
14225         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
14226         LDKRouteParameters route_params_var = *route_params;
14227         int64_t route_params_ref = 0;
14228         route_params_var = RouteParameters_clone(&route_params_var);
14229         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14230         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14231         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
14232         route_params_ref = (uintptr_t)route_params_var.inner;
14233         if (route_params_var.is_owned) {
14234                 route_params_ref |= 1;
14235         }
14236         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14237         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
14238         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
14239         int64_tArray first_hops_arr = NULL;
14240         if (first_hops != NULL) {
14241                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
14242                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
14243                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
14244                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
14245                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
14246                         int64_t first_hops_conv_16_ref = 0;
14247                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14248                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14249                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
14250                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
14251                         if (first_hops_conv_16_var.is_owned) {
14252                                 first_hops_conv_16_ref |= 1;
14253                         }
14254                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
14255                 }
14256                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
14257         }
14258         // WARNING: This object doesn't live past this scope, needs clone!
14259         int64_t ret_scorer = ((uintptr_t)scorer) | 1;
14260         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14261         CHECK(obj != NULL);
14262         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, route_params_ref, payment_hash_arr, first_hops_arr, ret_scorer);
14263         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14264                 (*env)->ExceptionDescribe(env);
14265                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
14266         }
14267         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14268         CHECK_ACCESS(ret_ptr);
14269         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
14270         FREE((void*)ret);
14271         if (get_jenv_res == JNI_EDETACHED) {
14272                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14273         }
14274         return ret_conv;
14275 }
14276 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
14277         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
14278         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14279 }
14280 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
14281         jclass c = (*env)->GetObjectClass(env, o);
14282         CHECK(c != NULL);
14283         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
14284         atomic_init(&calls->refcnt, 1);
14285         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14286         calls->o = (*env)->NewWeakGlobalRef(env, o);
14287         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
14288         CHECK(calls->find_route_meth != NULL);
14289
14290         LDKRouter ret = {
14291                 .this_arg = (void*) calls,
14292                 .find_route = find_route_LDKRouter_jcall,
14293                 .free = LDKRouter_JCalls_free,
14294         };
14295         return ret;
14296 }
14297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
14298         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
14299         *res_ptr = LDKRouter_init(env, clz, o);
14300         return (uint64_t)res_ptr;
14301 }
14302 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 route_params, int8_tArray payment_hash, int64_tArray first_hops, int64_t scorer) {
14303         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14304         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14305         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
14306         LDKPublicKey payer_ref;
14307         CHECK((*env)->GetArrayLength(env, payer) == 33);
14308         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
14309         LDKRouteParameters route_params_conv;
14310         route_params_conv.inner = (void*)(route_params & (~1));
14311         route_params_conv.is_owned = false;
14312         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
14313         unsigned char payment_hash_arr[32];
14314         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14315         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
14316         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
14317         LDKCVec_ChannelDetailsZ first_hops_constr;
14318         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
14319         if (first_hops != NULL) {
14320                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
14321                 if (first_hops_constr.datalen > 0)
14322                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14323                 else
14324                         first_hops_constr.data = NULL;
14325                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
14326                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
14327                         int64_t first_hops_conv_16 = first_hops_vals[q];
14328                         LDKChannelDetails first_hops_conv_16_conv;
14329                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
14330                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
14331                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
14332                         first_hops_constr.data[q] = first_hops_conv_16_conv;
14333                 }
14334                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
14335                 first_hops_ptr = &first_hops_constr;
14336         }
14337         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
14338         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
14339         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
14340         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14341         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, payment_hash_ref, first_hops_ptr, scorer_conv);
14342         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
14343         return (int64_t)ret_conv;
14344 }
14345
14346 static jclass LDKRetry_Attempts_class = NULL;
14347 static jmethodID LDKRetry_Attempts_meth = NULL;
14348 static jclass LDKRetry_Timeout_class = NULL;
14349 static jmethodID LDKRetry_Timeout_meth = NULL;
14350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
14351         LDKRetry_Attempts_class =
14352                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
14353         CHECK(LDKRetry_Attempts_class != NULL);
14354         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
14355         CHECK(LDKRetry_Attempts_meth != NULL);
14356         LDKRetry_Timeout_class =
14357                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
14358         CHECK(LDKRetry_Timeout_class != NULL);
14359         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
14360         CHECK(LDKRetry_Timeout_meth != NULL);
14361 }
14362 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14363         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
14364         switch(obj->tag) {
14365                 case LDKRetry_Attempts: {
14366                         int64_t attempts_conv = obj->attempts;
14367                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
14368                 }
14369                 case LDKRetry_Timeout: {
14370                         int64_t timeout_conv = obj->timeout;
14371                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
14372                 }
14373                 default: abort();
14374         }
14375 }
14376 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14377         LDKStr ret_str = _ldk_get_compiled_version();
14378         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14379         Str_free(ret_str);
14380         return ret_conv;
14381 }
14382
14383 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14384         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
14385         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14386         Str_free(ret_str);
14387         return ret_conv;
14388 }
14389
14390 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
14391         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14392         *ret_copy = Bech32Error_clone(arg);
14393 int64_t ret_ref = (uintptr_t)ret_copy;
14394         return ret_ref;
14395 }
14396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14397         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
14398         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
14399         return ret_conv;
14400 }
14401
14402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14403         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
14404         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14405         *ret_copy = Bech32Error_clone(orig_conv);
14406         int64_t ret_ref = (uintptr_t)ret_copy;
14407         return ret_ref;
14408 }
14409
14410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
14411         if ((o & 1) != 0) return;
14412         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14413         CHECK_ACCESS(o_ptr);
14414         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
14415         FREE((void*)o);
14416         Bech32Error_free(o_conv);
14417 }
14418
14419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
14420         LDKTransaction _res_ref;
14421         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
14422         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
14423         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
14424         _res_ref.data_is_owned = true;
14425         Transaction_free(_res_ref);
14426 }
14427
14428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
14429         LDKCVec_u8Z script_pubkey_ref;
14430         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
14431         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
14432         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
14433         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14434         *ret_ref = TxOut_new(script_pubkey_ref, value);
14435         return (int64_t)ret_ref;
14436 }
14437
14438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
14439         if ((_res & 1) != 0) return;
14440         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14441         CHECK_ACCESS(_res_ptr);
14442         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
14443         FREE((void*)_res);
14444         TxOut_free(_res_conv);
14445 }
14446
14447 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
14448         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14449         *ret_ref = TxOut_clone(arg);
14450         return (int64_t)ret_ref;
14451 }
14452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14453         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
14454         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
14455         return ret_conv;
14456 }
14457
14458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14459         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
14460         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14461         *ret_ref = TxOut_clone(orig_conv);
14462         return (int64_t)ret_ref;
14463 }
14464
14465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
14466         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
14467         Str_free(dummy);
14468 }
14469
14470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
14471         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14472         *ret_conv = CResult_NoneNoneZ_ok();
14473         return (int64_t)ret_conv;
14474 }
14475
14476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
14477         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14478         *ret_conv = CResult_NoneNoneZ_err();
14479         return (int64_t)ret_conv;
14480 }
14481
14482 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14483         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
14484         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
14485         return ret_conv;
14486 }
14487
14488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14489         if ((_res & 1) != 0) return;
14490         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14491         CHECK_ACCESS(_res_ptr);
14492         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
14493         FREE((void*)_res);
14494         CResult_NoneNoneZ_free(_res_conv);
14495 }
14496
14497 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
14498         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14499         *ret_conv = CResult_NoneNoneZ_clone(arg);
14500         return (int64_t)ret_conv;
14501 }
14502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14503         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
14504         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
14505         return ret_conv;
14506 }
14507
14508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14509         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
14510         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14511         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
14512         return (int64_t)ret_conv;
14513 }
14514
14515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14516         LDKCounterpartyCommitmentSecrets o_conv;
14517         o_conv.inner = (void*)(o & (~1));
14518         o_conv.is_owned = (o & 1) || (o == 0);
14519         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14520         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
14521         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14522         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
14523         return (int64_t)ret_conv;
14524 }
14525
14526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14527         LDKDecodeError e_conv;
14528         e_conv.inner = (void*)(e & (~1));
14529         e_conv.is_owned = (e & 1) || (e == 0);
14530         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14531         e_conv = DecodeError_clone(&e_conv);
14532         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14533         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
14534         return (int64_t)ret_conv;
14535 }
14536
14537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14538         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
14539         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
14540         return ret_conv;
14541 }
14542
14543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14544         if ((_res & 1) != 0) return;
14545         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14546         CHECK_ACCESS(_res_ptr);
14547         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
14548         FREE((void*)_res);
14549         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
14550 }
14551
14552 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
14553         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14554         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
14555         return (int64_t)ret_conv;
14556 }
14557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14558         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
14559         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
14560         return ret_conv;
14561 }
14562
14563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14564         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
14565         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14566         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
14567         return (int64_t)ret_conv;
14568 }
14569
14570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14571         LDKSecretKey o_ref;
14572         CHECK((*env)->GetArrayLength(env, o) == 32);
14573         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
14574         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14575         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
14576         return (int64_t)ret_conv;
14577 }
14578
14579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14580         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14581         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14582         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
14583         return (int64_t)ret_conv;
14584 }
14585
14586 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14587         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
14588         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
14589         return ret_conv;
14590 }
14591
14592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14593         if ((_res & 1) != 0) return;
14594         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14595         CHECK_ACCESS(_res_ptr);
14596         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
14597         FREE((void*)_res);
14598         CResult_SecretKeyErrorZ_free(_res_conv);
14599 }
14600
14601 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
14602         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14603         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
14604         return (int64_t)ret_conv;
14605 }
14606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14607         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
14608         int64_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
14609         return ret_conv;
14610 }
14611
14612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14613         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
14614         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14615         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
14616         return (int64_t)ret_conv;
14617 }
14618
14619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14620         LDKPublicKey o_ref;
14621         CHECK((*env)->GetArrayLength(env, o) == 33);
14622         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
14623         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14624         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
14625         return (int64_t)ret_conv;
14626 }
14627
14628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14629         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14630         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14631         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
14632         return (int64_t)ret_conv;
14633 }
14634
14635 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14636         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
14637         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
14638         return ret_conv;
14639 }
14640
14641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14642         if ((_res & 1) != 0) return;
14643         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14644         CHECK_ACCESS(_res_ptr);
14645         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
14646         FREE((void*)_res);
14647         CResult_PublicKeyErrorZ_free(_res_conv);
14648 }
14649
14650 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
14651         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14652         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
14653         return (int64_t)ret_conv;
14654 }
14655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14656         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
14657         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
14658         return ret_conv;
14659 }
14660
14661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14662         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
14663         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14664         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
14665         return (int64_t)ret_conv;
14666 }
14667
14668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14669         LDKTxCreationKeys o_conv;
14670         o_conv.inner = (void*)(o & (~1));
14671         o_conv.is_owned = (o & 1) || (o == 0);
14672         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14673         o_conv = TxCreationKeys_clone(&o_conv);
14674         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14675         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
14676         return (int64_t)ret_conv;
14677 }
14678
14679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14680         LDKDecodeError e_conv;
14681         e_conv.inner = (void*)(e & (~1));
14682         e_conv.is_owned = (e & 1) || (e == 0);
14683         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14684         e_conv = DecodeError_clone(&e_conv);
14685         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14686         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
14687         return (int64_t)ret_conv;
14688 }
14689
14690 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14691         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
14692         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
14693         return ret_conv;
14694 }
14695
14696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14697         if ((_res & 1) != 0) return;
14698         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14699         CHECK_ACCESS(_res_ptr);
14700         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
14701         FREE((void*)_res);
14702         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
14703 }
14704
14705 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
14706         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14707         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
14708         return (int64_t)ret_conv;
14709 }
14710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14711         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
14712         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
14713         return ret_conv;
14714 }
14715
14716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14717         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
14718         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14719         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
14720         return (int64_t)ret_conv;
14721 }
14722
14723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14724         LDKChannelPublicKeys o_conv;
14725         o_conv.inner = (void*)(o & (~1));
14726         o_conv.is_owned = (o & 1) || (o == 0);
14727         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14728         o_conv = ChannelPublicKeys_clone(&o_conv);
14729         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14730         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
14731         return (int64_t)ret_conv;
14732 }
14733
14734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14735         LDKDecodeError e_conv;
14736         e_conv.inner = (void*)(e & (~1));
14737         e_conv.is_owned = (e & 1) || (e == 0);
14738         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14739         e_conv = DecodeError_clone(&e_conv);
14740         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14741         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
14742         return (int64_t)ret_conv;
14743 }
14744
14745 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14746         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
14747         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
14748         return ret_conv;
14749 }
14750
14751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14752         if ((_res & 1) != 0) return;
14753         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14754         CHECK_ACCESS(_res_ptr);
14755         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
14756         FREE((void*)_res);
14757         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
14758 }
14759
14760 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
14761         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14762         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
14763         return (int64_t)ret_conv;
14764 }
14765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14766         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
14767         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
14768         return ret_conv;
14769 }
14770
14771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14772         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
14773         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14774         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
14775         return (int64_t)ret_conv;
14776 }
14777
14778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14779         LDKTxCreationKeys o_conv;
14780         o_conv.inner = (void*)(o & (~1));
14781         o_conv.is_owned = (o & 1) || (o == 0);
14782         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14783         o_conv = TxCreationKeys_clone(&o_conv);
14784         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14785         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
14786         return (int64_t)ret_conv;
14787 }
14788
14789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14790         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14791         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14792         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
14793         return (int64_t)ret_conv;
14794 }
14795
14796 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14797         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
14798         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
14799         return ret_conv;
14800 }
14801
14802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14803         if ((_res & 1) != 0) return;
14804         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14805         CHECK_ACCESS(_res_ptr);
14806         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
14807         FREE((void*)_res);
14808         CResult_TxCreationKeysErrorZ_free(_res_conv);
14809 }
14810
14811 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
14812         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14813         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
14814         return (int64_t)ret_conv;
14815 }
14816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14817         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
14818         int64_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
14819         return ret_conv;
14820 }
14821
14822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14823         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
14824         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14825         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
14826         return (int64_t)ret_conv;
14827 }
14828
14829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
14830         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14831         *ret_copy = COption_u32Z_some(o);
14832         int64_t ret_ref = (uintptr_t)ret_copy;
14833         return ret_ref;
14834 }
14835
14836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
14837         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14838         *ret_copy = COption_u32Z_none();
14839         int64_t ret_ref = (uintptr_t)ret_copy;
14840         return ret_ref;
14841 }
14842
14843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14844         if ((_res & 1) != 0) return;
14845         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14846         CHECK_ACCESS(_res_ptr);
14847         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
14848         FREE((void*)_res);
14849         COption_u32Z_free(_res_conv);
14850 }
14851
14852 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
14853         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14854         *ret_copy = COption_u32Z_clone(arg);
14855 int64_t ret_ref = (uintptr_t)ret_copy;
14856         return ret_ref;
14857 }
14858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14859         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
14860         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
14861         return ret_conv;
14862 }
14863
14864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14865         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
14866         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14867         *ret_copy = COption_u32Z_clone(orig_conv);
14868         int64_t ret_ref = (uintptr_t)ret_copy;
14869         return ret_ref;
14870 }
14871
14872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14873         LDKHTLCOutputInCommitment o_conv;
14874         o_conv.inner = (void*)(o & (~1));
14875         o_conv.is_owned = (o & 1) || (o == 0);
14876         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14877         o_conv = HTLCOutputInCommitment_clone(&o_conv);
14878         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14879         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
14880         return (int64_t)ret_conv;
14881 }
14882
14883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14884         LDKDecodeError e_conv;
14885         e_conv.inner = (void*)(e & (~1));
14886         e_conv.is_owned = (e & 1) || (e == 0);
14887         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14888         e_conv = DecodeError_clone(&e_conv);
14889         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14890         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
14891         return (int64_t)ret_conv;
14892 }
14893
14894 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14895         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
14896         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
14897         return ret_conv;
14898 }
14899
14900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14901         if ((_res & 1) != 0) return;
14902         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14903         CHECK_ACCESS(_res_ptr);
14904         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
14905         FREE((void*)_res);
14906         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
14907 }
14908
14909 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
14910         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14911         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
14912         return (int64_t)ret_conv;
14913 }
14914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14915         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
14916         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
14917         return ret_conv;
14918 }
14919
14920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14921         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
14922         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14923         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
14924         return (int64_t)ret_conv;
14925 }
14926
14927 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
14928         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
14929         return ret_conv;
14930 }
14931
14932 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
14933         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
14934         return ret_conv;
14935 }
14936
14937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
14938         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
14939         COption_NoneZ_free(_res_conv);
14940 }
14941
14942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14943         LDKCounterpartyChannelTransactionParameters o_conv;
14944         o_conv.inner = (void*)(o & (~1));
14945         o_conv.is_owned = (o & 1) || (o == 0);
14946         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14947         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
14948         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14949         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
14950         return (int64_t)ret_conv;
14951 }
14952
14953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14954         LDKDecodeError e_conv;
14955         e_conv.inner = (void*)(e & (~1));
14956         e_conv.is_owned = (e & 1) || (e == 0);
14957         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14958         e_conv = DecodeError_clone(&e_conv);
14959         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14960         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
14961         return (int64_t)ret_conv;
14962 }
14963
14964 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14965         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
14966         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
14967         return ret_conv;
14968 }
14969
14970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14971         if ((_res & 1) != 0) return;
14972         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14973         CHECK_ACCESS(_res_ptr);
14974         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
14975         FREE((void*)_res);
14976         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
14977 }
14978
14979 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
14980         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14981         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
14982         return (int64_t)ret_conv;
14983 }
14984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14985         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
14986         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
14987         return ret_conv;
14988 }
14989
14990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14991         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
14992         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14993         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
14994         return (int64_t)ret_conv;
14995 }
14996
14997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14998         LDKChannelTransactionParameters o_conv;
14999         o_conv.inner = (void*)(o & (~1));
15000         o_conv.is_owned = (o & 1) || (o == 0);
15001         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15002         o_conv = ChannelTransactionParameters_clone(&o_conv);
15003         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15004         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
15005         return (int64_t)ret_conv;
15006 }
15007
15008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15009         LDKDecodeError e_conv;
15010         e_conv.inner = (void*)(e & (~1));
15011         e_conv.is_owned = (e & 1) || (e == 0);
15012         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15013         e_conv = DecodeError_clone(&e_conv);
15014         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15015         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
15016         return (int64_t)ret_conv;
15017 }
15018
15019 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15020         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
15021         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
15022         return ret_conv;
15023 }
15024
15025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15026         if ((_res & 1) != 0) return;
15027         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15028         CHECK_ACCESS(_res_ptr);
15029         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
15030         FREE((void*)_res);
15031         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
15032 }
15033
15034 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
15035         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15036         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
15037         return (int64_t)ret_conv;
15038 }
15039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15040         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
15041         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
15042         return ret_conv;
15043 }
15044
15045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15046         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
15047         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15048         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
15049         return (int64_t)ret_conv;
15050 }
15051
15052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15053         LDKCVec_SignatureZ _res_constr;
15054         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15055         if (_res_constr.datalen > 0)
15056                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15057         else
15058                 _res_constr.data = NULL;
15059         for (size_t i = 0; i < _res_constr.datalen; i++) {
15060                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15061                 LDKSignature _res_conv_8_ref;
15062                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
15063                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
15064                 _res_constr.data[i] = _res_conv_8_ref;
15065         }
15066         CVec_SignatureZ_free(_res_constr);
15067 }
15068
15069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15070         LDKHolderCommitmentTransaction o_conv;
15071         o_conv.inner = (void*)(o & (~1));
15072         o_conv.is_owned = (o & 1) || (o == 0);
15073         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15074         o_conv = HolderCommitmentTransaction_clone(&o_conv);
15075         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15076         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
15077         return (int64_t)ret_conv;
15078 }
15079
15080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15081         LDKDecodeError e_conv;
15082         e_conv.inner = (void*)(e & (~1));
15083         e_conv.is_owned = (e & 1) || (e == 0);
15084         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15085         e_conv = DecodeError_clone(&e_conv);
15086         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15087         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
15088         return (int64_t)ret_conv;
15089 }
15090
15091 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15092         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
15093         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15094         return ret_conv;
15095 }
15096
15097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15098         if ((_res & 1) != 0) return;
15099         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15100         CHECK_ACCESS(_res_ptr);
15101         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15102         FREE((void*)_res);
15103         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
15104 }
15105
15106 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15107         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15108         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
15109         return (int64_t)ret_conv;
15110 }
15111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15112         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
15113         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15114         return ret_conv;
15115 }
15116
15117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15118         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
15119         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15120         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15121         return (int64_t)ret_conv;
15122 }
15123
15124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15125         LDKBuiltCommitmentTransaction 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         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
15130         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15131         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
15132         return (int64_t)ret_conv;
15133 }
15134
15135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_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_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15142         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
15143         return (int64_t)ret_conv;
15144 }
15145
15146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15147         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
15148         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15149         return ret_conv;
15150 }
15151
15152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_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_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15157         FREE((void*)_res);
15158         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
15159 }
15160
15161 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15162         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15163         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
15164         return (int64_t)ret_conv;
15165 }
15166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15167         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
15168         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15169         return ret_conv;
15170 }
15171
15172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15173         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
15174         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15175         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15176         return (int64_t)ret_conv;
15177 }
15178
15179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15180         LDKTrustedClosingTransaction o_conv;
15181         o_conv.inner = (void*)(o & (~1));
15182         o_conv.is_owned = (o & 1) || (o == 0);
15183         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15184         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
15185         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15186         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
15187         return (int64_t)ret_conv;
15188 }
15189
15190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
15191         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15192         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
15193         return (int64_t)ret_conv;
15194 }
15195
15196 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15197         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
15198         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
15199         return ret_conv;
15200 }
15201
15202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15203         if ((_res & 1) != 0) return;
15204         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15205         CHECK_ACCESS(_res_ptr);
15206         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
15207         FREE((void*)_res);
15208         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
15209 }
15210
15211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15212         LDKCommitmentTransaction o_conv;
15213         o_conv.inner = (void*)(o & (~1));
15214         o_conv.is_owned = (o & 1) || (o == 0);
15215         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15216         o_conv = CommitmentTransaction_clone(&o_conv);
15217         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15218         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
15219         return (int64_t)ret_conv;
15220 }
15221
15222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15223         LDKDecodeError e_conv;
15224         e_conv.inner = (void*)(e & (~1));
15225         e_conv.is_owned = (e & 1) || (e == 0);
15226         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15227         e_conv = DecodeError_clone(&e_conv);
15228         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15229         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
15230         return (int64_t)ret_conv;
15231 }
15232
15233 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15234         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
15235         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15236         return ret_conv;
15237 }
15238
15239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15240         if ((_res & 1) != 0) return;
15241         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15242         CHECK_ACCESS(_res_ptr);
15243         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
15244         FREE((void*)_res);
15245         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
15246 }
15247
15248 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15249         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15250         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
15251         return (int64_t)ret_conv;
15252 }
15253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15254         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
15255         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15256         return ret_conv;
15257 }
15258
15259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15260         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
15261         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15262         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
15263         return (int64_t)ret_conv;
15264 }
15265
15266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15267         LDKTrustedCommitmentTransaction o_conv;
15268         o_conv.inner = (void*)(o & (~1));
15269         o_conv.is_owned = (o & 1) || (o == 0);
15270         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15271         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
15272         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
15273         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
15274         return (int64_t)ret_conv;
15275 }
15276
15277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
15278         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
15279         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
15280         return (int64_t)ret_conv;
15281 }
15282
15283 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15284         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
15285         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
15286         return ret_conv;
15287 }
15288
15289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15290         if ((_res & 1) != 0) return;
15291         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15292         CHECK_ACCESS(_res_ptr);
15293         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
15294         FREE((void*)_res);
15295         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
15296 }
15297
15298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
15299         LDKCVec_SignatureZ o_constr;
15300         o_constr.datalen = (*env)->GetArrayLength(env, o);
15301         if (o_constr.datalen > 0)
15302                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15303         else
15304                 o_constr.data = NULL;
15305         for (size_t i = 0; i < o_constr.datalen; i++) {
15306                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
15307                 LDKSignature o_conv_8_ref;
15308                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
15309                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
15310                 o_constr.data[i] = o_conv_8_ref;
15311         }
15312         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15313         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
15314         return (int64_t)ret_conv;
15315 }
15316
15317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
15318         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15319         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
15320         return (int64_t)ret_conv;
15321 }
15322
15323 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15324         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
15325         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
15326         return ret_conv;
15327 }
15328
15329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15330         if ((_res & 1) != 0) return;
15331         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15332         CHECK_ACCESS(_res_ptr);
15333         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
15334         FREE((void*)_res);
15335         CResult_CVec_SignatureZNoneZ_free(_res_conv);
15336 }
15337
15338 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
15339         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15340         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
15341         return (int64_t)ret_conv;
15342 }
15343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15344         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
15345         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
15346         return ret_conv;
15347 }
15348
15349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15350         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
15351         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15352         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
15353         return (int64_t)ret_conv;
15354 }
15355
15356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15357         LDKShutdownScript o_conv;
15358         o_conv.inner = (void*)(o & (~1));
15359         o_conv.is_owned = (o & 1) || (o == 0);
15360         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15361         o_conv = ShutdownScript_clone(&o_conv);
15362         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15363         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
15364         return (int64_t)ret_conv;
15365 }
15366
15367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15368         LDKDecodeError e_conv;
15369         e_conv.inner = (void*)(e & (~1));
15370         e_conv.is_owned = (e & 1) || (e == 0);
15371         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15372         e_conv = DecodeError_clone(&e_conv);
15373         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15374         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
15375         return (int64_t)ret_conv;
15376 }
15377
15378 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15379         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
15380         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
15381         return ret_conv;
15382 }
15383
15384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15385         if ((_res & 1) != 0) return;
15386         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15387         CHECK_ACCESS(_res_ptr);
15388         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
15389         FREE((void*)_res);
15390         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
15391 }
15392
15393 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
15394         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15395         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
15396         return (int64_t)ret_conv;
15397 }
15398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15399         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
15400         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
15401         return ret_conv;
15402 }
15403
15404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15405         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
15406         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15407         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
15408         return (int64_t)ret_conv;
15409 }
15410
15411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15412         LDKShutdownScript o_conv;
15413         o_conv.inner = (void*)(o & (~1));
15414         o_conv.is_owned = (o & 1) || (o == 0);
15415         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15416         o_conv = ShutdownScript_clone(&o_conv);
15417         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15418         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
15419         return (int64_t)ret_conv;
15420 }
15421
15422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15423         LDKInvalidShutdownScript e_conv;
15424         e_conv.inner = (void*)(e & (~1));
15425         e_conv.is_owned = (e & 1) || (e == 0);
15426         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15427         e_conv = InvalidShutdownScript_clone(&e_conv);
15428         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15429         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
15430         return (int64_t)ret_conv;
15431 }
15432
15433 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15434         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
15435         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
15436         return ret_conv;
15437 }
15438
15439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15440         if ((_res & 1) != 0) return;
15441         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15442         CHECK_ACCESS(_res_ptr);
15443         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
15444         FREE((void*)_res);
15445         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
15446 }
15447
15448 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
15449         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15450         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
15451         return (int64_t)ret_conv;
15452 }
15453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15454         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
15455         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
15456         return ret_conv;
15457 }
15458
15459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15460         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
15461         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15462         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
15463         return (int64_t)ret_conv;
15464 }
15465
15466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
15467         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15468         *ret_conv = CResult_NoneErrorZ_ok();
15469         return (int64_t)ret_conv;
15470 }
15471
15472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15473         LDKIOError e_conv = LDKIOError_from_java(env, e);
15474         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15475         *ret_conv = CResult_NoneErrorZ_err(e_conv);
15476         return (int64_t)ret_conv;
15477 }
15478
15479 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15480         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
15481         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
15482         return ret_conv;
15483 }
15484
15485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15486         if ((_res & 1) != 0) return;
15487         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15488         CHECK_ACCESS(_res_ptr);
15489         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
15490         FREE((void*)_res);
15491         CResult_NoneErrorZ_free(_res_conv);
15492 }
15493
15494 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
15495         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15496         *ret_conv = CResult_NoneErrorZ_clone(arg);
15497         return (int64_t)ret_conv;
15498 }
15499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15500         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
15501         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
15502         return ret_conv;
15503 }
15504
15505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15506         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
15507         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15508         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
15509         return (int64_t)ret_conv;
15510 }
15511
15512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15513         LDKRouteHop o_conv;
15514         o_conv.inner = (void*)(o & (~1));
15515         o_conv.is_owned = (o & 1) || (o == 0);
15516         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15517         o_conv = RouteHop_clone(&o_conv);
15518         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15519         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
15520         return (int64_t)ret_conv;
15521 }
15522
15523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15524         LDKDecodeError e_conv;
15525         e_conv.inner = (void*)(e & (~1));
15526         e_conv.is_owned = (e & 1) || (e == 0);
15527         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15528         e_conv = DecodeError_clone(&e_conv);
15529         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15530         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
15531         return (int64_t)ret_conv;
15532 }
15533
15534 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15535         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
15536         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
15537         return ret_conv;
15538 }
15539
15540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15541         if ((_res & 1) != 0) return;
15542         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15543         CHECK_ACCESS(_res_ptr);
15544         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
15545         FREE((void*)_res);
15546         CResult_RouteHopDecodeErrorZ_free(_res_conv);
15547 }
15548
15549 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
15550         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15551         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
15552         return (int64_t)ret_conv;
15553 }
15554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15555         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
15556         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
15557         return ret_conv;
15558 }
15559
15560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15561         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
15562         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15563         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
15564         return (int64_t)ret_conv;
15565 }
15566
15567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15568         LDKCVec_RouteHopZ _res_constr;
15569         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15570         if (_res_constr.datalen > 0)
15571                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15572         else
15573                 _res_constr.data = NULL;
15574         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15575         for (size_t k = 0; k < _res_constr.datalen; k++) {
15576                 int64_t _res_conv_10 = _res_vals[k];
15577                 LDKRouteHop _res_conv_10_conv;
15578                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
15579                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
15580                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
15581                 _res_constr.data[k] = _res_conv_10_conv;
15582         }
15583         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15584         CVec_RouteHopZ_free(_res_constr);
15585 }
15586
15587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15588         LDKCVec_CVec_RouteHopZZ _res_constr;
15589         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15590         if (_res_constr.datalen > 0)
15591                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
15592         else
15593                 _res_constr.data = NULL;
15594         for (size_t m = 0; m < _res_constr.datalen; m++) {
15595                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
15596                 LDKCVec_RouteHopZ _res_conv_12_constr;
15597                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
15598                 if (_res_conv_12_constr.datalen > 0)
15599                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15600                 else
15601                         _res_conv_12_constr.data = NULL;
15602                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
15603                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
15604                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
15605                         LDKRouteHop _res_conv_12_conv_10_conv;
15606                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
15607                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
15608                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
15609                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
15610                 }
15611                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
15612                 _res_constr.data[m] = _res_conv_12_constr;
15613         }
15614         CVec_CVec_RouteHopZZ_free(_res_constr);
15615 }
15616
15617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15618         LDKRoute o_conv;
15619         o_conv.inner = (void*)(o & (~1));
15620         o_conv.is_owned = (o & 1) || (o == 0);
15621         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15622         o_conv = Route_clone(&o_conv);
15623         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15624         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
15625         return (int64_t)ret_conv;
15626 }
15627
15628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15629         LDKDecodeError e_conv;
15630         e_conv.inner = (void*)(e & (~1));
15631         e_conv.is_owned = (e & 1) || (e == 0);
15632         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15633         e_conv = DecodeError_clone(&e_conv);
15634         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15635         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
15636         return (int64_t)ret_conv;
15637 }
15638
15639 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15640         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
15641         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
15642         return ret_conv;
15643 }
15644
15645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15646         if ((_res & 1) != 0) return;
15647         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15648         CHECK_ACCESS(_res_ptr);
15649         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
15650         FREE((void*)_res);
15651         CResult_RouteDecodeErrorZ_free(_res_conv);
15652 }
15653
15654 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
15655         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15656         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
15657         return (int64_t)ret_conv;
15658 }
15659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15660         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
15661         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
15662         return ret_conv;
15663 }
15664
15665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15666         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
15667         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15668         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
15669         return (int64_t)ret_conv;
15670 }
15671
15672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15673         LDKRouteParameters o_conv;
15674         o_conv.inner = (void*)(o & (~1));
15675         o_conv.is_owned = (o & 1) || (o == 0);
15676         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15677         o_conv = RouteParameters_clone(&o_conv);
15678         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15679         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
15680         return (int64_t)ret_conv;
15681 }
15682
15683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15684         LDKDecodeError e_conv;
15685         e_conv.inner = (void*)(e & (~1));
15686         e_conv.is_owned = (e & 1) || (e == 0);
15687         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15688         e_conv = DecodeError_clone(&e_conv);
15689         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15690         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
15691         return (int64_t)ret_conv;
15692 }
15693
15694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15695         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
15696         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
15697         return ret_conv;
15698 }
15699
15700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15701         if ((_res & 1) != 0) return;
15702         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15703         CHECK_ACCESS(_res_ptr);
15704         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
15705         FREE((void*)_res);
15706         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
15707 }
15708
15709 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
15710         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15711         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
15712         return (int64_t)ret_conv;
15713 }
15714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15715         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
15716         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
15717         return ret_conv;
15718 }
15719
15720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15721         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
15722         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15723         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
15724         return (int64_t)ret_conv;
15725 }
15726
15727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15728         LDKCVec_RouteHintZ _res_constr;
15729         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15730         if (_res_constr.datalen > 0)
15731                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
15732         else
15733                 _res_constr.data = NULL;
15734         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15735         for (size_t l = 0; l < _res_constr.datalen; l++) {
15736                 int64_t _res_conv_11 = _res_vals[l];
15737                 LDKRouteHint _res_conv_11_conv;
15738                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
15739                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
15740                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
15741                 _res_constr.data[l] = _res_conv_11_conv;
15742         }
15743         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15744         CVec_RouteHintZ_free(_res_constr);
15745 }
15746
15747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
15748         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15749         *ret_copy = COption_u64Z_some(o);
15750         int64_t ret_ref = (uintptr_t)ret_copy;
15751         return ret_ref;
15752 }
15753
15754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
15755         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15756         *ret_copy = COption_u64Z_none();
15757         int64_t ret_ref = (uintptr_t)ret_copy;
15758         return ret_ref;
15759 }
15760
15761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
15762         if ((_res & 1) != 0) return;
15763         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15764         CHECK_ACCESS(_res_ptr);
15765         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
15766         FREE((void*)_res);
15767         COption_u64Z_free(_res_conv);
15768 }
15769
15770 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
15771         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15772         *ret_copy = COption_u64Z_clone(arg);
15773 int64_t ret_ref = (uintptr_t)ret_copy;
15774         return ret_ref;
15775 }
15776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15777         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
15778         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
15779         return ret_conv;
15780 }
15781
15782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15783         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
15784         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15785         *ret_copy = COption_u64Z_clone(orig_conv);
15786         int64_t ret_ref = (uintptr_t)ret_copy;
15787         return ret_ref;
15788 }
15789
15790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15791         LDKPaymentParameters o_conv;
15792         o_conv.inner = (void*)(o & (~1));
15793         o_conv.is_owned = (o & 1) || (o == 0);
15794         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15795         o_conv = PaymentParameters_clone(&o_conv);
15796         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15797         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
15798         return (int64_t)ret_conv;
15799 }
15800
15801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15802         LDKDecodeError e_conv;
15803         e_conv.inner = (void*)(e & (~1));
15804         e_conv.is_owned = (e & 1) || (e == 0);
15805         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15806         e_conv = DecodeError_clone(&e_conv);
15807         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15808         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
15809         return (int64_t)ret_conv;
15810 }
15811
15812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15813         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
15814         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
15815         return ret_conv;
15816 }
15817
15818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15819         if ((_res & 1) != 0) return;
15820         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15821         CHECK_ACCESS(_res_ptr);
15822         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
15823         FREE((void*)_res);
15824         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
15825 }
15826
15827 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
15828         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15829         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
15830         return (int64_t)ret_conv;
15831 }
15832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15833         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
15834         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
15835         return ret_conv;
15836 }
15837
15838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15839         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
15840         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15841         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
15842         return (int64_t)ret_conv;
15843 }
15844
15845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15846         LDKCVec_RouteHintHopZ _res_constr;
15847         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15848         if (_res_constr.datalen > 0)
15849                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
15850         else
15851                 _res_constr.data = NULL;
15852         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15853         for (size_t o = 0; o < _res_constr.datalen; o++) {
15854                 int64_t _res_conv_14 = _res_vals[o];
15855                 LDKRouteHintHop _res_conv_14_conv;
15856                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15857                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15858                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15859                 _res_constr.data[o] = _res_conv_14_conv;
15860         }
15861         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15862         CVec_RouteHintHopZ_free(_res_constr);
15863 }
15864
15865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15866         LDKRouteHint o_conv;
15867         o_conv.inner = (void*)(o & (~1));
15868         o_conv.is_owned = (o & 1) || (o == 0);
15869         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15870         o_conv = RouteHint_clone(&o_conv);
15871         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15872         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
15873         return (int64_t)ret_conv;
15874 }
15875
15876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15877         LDKDecodeError e_conv;
15878         e_conv.inner = (void*)(e & (~1));
15879         e_conv.is_owned = (e & 1) || (e == 0);
15880         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15881         e_conv = DecodeError_clone(&e_conv);
15882         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15883         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
15884         return (int64_t)ret_conv;
15885 }
15886
15887 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15888         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
15889         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
15890         return ret_conv;
15891 }
15892
15893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15894         if ((_res & 1) != 0) return;
15895         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15896         CHECK_ACCESS(_res_ptr);
15897         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
15898         FREE((void*)_res);
15899         CResult_RouteHintDecodeErrorZ_free(_res_conv);
15900 }
15901
15902 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
15903         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15904         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
15905         return (int64_t)ret_conv;
15906 }
15907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15908         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
15909         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
15910         return ret_conv;
15911 }
15912
15913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15914         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
15915         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15916         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
15917         return (int64_t)ret_conv;
15918 }
15919
15920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15921         LDKRouteHintHop o_conv;
15922         o_conv.inner = (void*)(o & (~1));
15923         o_conv.is_owned = (o & 1) || (o == 0);
15924         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15925         o_conv = RouteHintHop_clone(&o_conv);
15926         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15927         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
15928         return (int64_t)ret_conv;
15929 }
15930
15931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15932         LDKDecodeError e_conv;
15933         e_conv.inner = (void*)(e & (~1));
15934         e_conv.is_owned = (e & 1) || (e == 0);
15935         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15936         e_conv = DecodeError_clone(&e_conv);
15937         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15938         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
15939         return (int64_t)ret_conv;
15940 }
15941
15942 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15943         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
15944         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
15945         return ret_conv;
15946 }
15947
15948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15949         if ((_res & 1) != 0) return;
15950         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15951         CHECK_ACCESS(_res_ptr);
15952         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
15953         FREE((void*)_res);
15954         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
15955 }
15956
15957 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
15958         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15959         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
15960         return (int64_t)ret_conv;
15961 }
15962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15963         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
15964         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
15965         return ret_conv;
15966 }
15967
15968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15969         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
15970         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15971         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
15972         return (int64_t)ret_conv;
15973 }
15974
15975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15976         LDKCVec_ChannelDetailsZ _res_constr;
15977         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15978         if (_res_constr.datalen > 0)
15979                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15980         else
15981                 _res_constr.data = NULL;
15982         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15983         for (size_t q = 0; q < _res_constr.datalen; q++) {
15984                 int64_t _res_conv_16 = _res_vals[q];
15985                 LDKChannelDetails _res_conv_16_conv;
15986                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
15987                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
15988                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
15989                 _res_constr.data[q] = _res_conv_16_conv;
15990         }
15991         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15992         CVec_ChannelDetailsZ_free(_res_constr);
15993 }
15994
15995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15996         LDKRoute o_conv;
15997         o_conv.inner = (void*)(o & (~1));
15998         o_conv.is_owned = (o & 1) || (o == 0);
15999         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16000         o_conv = Route_clone(&o_conv);
16001         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16002         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
16003         return (int64_t)ret_conv;
16004 }
16005
16006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16007         LDKLightningError e_conv;
16008         e_conv.inner = (void*)(e & (~1));
16009         e_conv.is_owned = (e & 1) || (e == 0);
16010         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16011         e_conv = LightningError_clone(&e_conv);
16012         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16013         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
16014         return (int64_t)ret_conv;
16015 }
16016
16017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16018         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
16019         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
16020         return ret_conv;
16021 }
16022
16023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16024         if ((_res & 1) != 0) return;
16025         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16026         CHECK_ACCESS(_res_ptr);
16027         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
16028         FREE((void*)_res);
16029         CResult_RouteLightningErrorZ_free(_res_conv);
16030 }
16031
16032 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
16033         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16034         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
16035         return (int64_t)ret_conv;
16036 }
16037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16038         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
16039         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
16040         return ret_conv;
16041 }
16042
16043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16044         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
16045         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16046         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
16047         return (int64_t)ret_conv;
16048 }
16049
16050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16051         LDKCVec_PublicKeyZ _res_constr;
16052         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16053         if (_res_constr.datalen > 0)
16054                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16055         else
16056                 _res_constr.data = NULL;
16057         for (size_t i = 0; i < _res_constr.datalen; i++) {
16058                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16059                 LDKPublicKey _res_conv_8_ref;
16060                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
16061                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
16062                 _res_constr.data[i] = _res_conv_8_ref;
16063         }
16064         CVec_PublicKeyZ_free(_res_constr);
16065 }
16066
16067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16068         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16069         CHECK_ACCESS(o_ptr);
16070         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
16071         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)o) & ~1));
16072         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16073         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
16074         return (int64_t)ret_conv;
16075 }
16076
16077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16078         LDKDecodeError e_conv;
16079         e_conv.inner = (void*)(e & (~1));
16080         e_conv.is_owned = (e & 1) || (e == 0);
16081         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16082         e_conv = DecodeError_clone(&e_conv);
16083         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16084         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
16085         return (int64_t)ret_conv;
16086 }
16087
16088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16089         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(o & ~1);
16090         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
16091         return ret_conv;
16092 }
16093
16094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16095         if ((_res & 1) != 0) return;
16096         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16097         CHECK_ACCESS(_res_ptr);
16098         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
16099         FREE((void*)_res);
16100         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
16101 }
16102
16103 static inline uintptr_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
16104         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16105         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
16106         return (int64_t)ret_conv;
16107 }
16108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16109         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(arg & ~1);
16110         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
16111         return ret_conv;
16112 }
16113
16114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16115         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(orig & ~1);
16116         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16117         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
16118         return (int64_t)ret_conv;
16119 }
16120
16121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16122         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16123         CHECK_ACCESS(o_ptr);
16124         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
16125         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
16126         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16127         *ret_copy = COption_ClosureReasonZ_some(o_conv);
16128         int64_t ret_ref = (uintptr_t)ret_copy;
16129         return ret_ref;
16130 }
16131
16132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
16133         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16134         *ret_copy = COption_ClosureReasonZ_none();
16135         int64_t ret_ref = (uintptr_t)ret_copy;
16136         return ret_ref;
16137 }
16138
16139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16140         if ((_res & 1) != 0) return;
16141         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16142         CHECK_ACCESS(_res_ptr);
16143         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
16144         FREE((void*)_res);
16145         COption_ClosureReasonZ_free(_res_conv);
16146 }
16147
16148 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
16149         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16150         *ret_copy = COption_ClosureReasonZ_clone(arg);
16151 int64_t ret_ref = (uintptr_t)ret_copy;
16152         return ret_ref;
16153 }
16154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16155         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
16156         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
16157         return ret_conv;
16158 }
16159
16160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16161         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
16162         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16163         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
16164         int64_t ret_ref = (uintptr_t)ret_copy;
16165         return ret_ref;
16166 }
16167
16168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16169         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16170         CHECK_ACCESS(o_ptr);
16171         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
16172         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
16173         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16174         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
16175         return (int64_t)ret_conv;
16176 }
16177
16178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16179         LDKDecodeError e_conv;
16180         e_conv.inner = (void*)(e & (~1));
16181         e_conv.is_owned = (e & 1) || (e == 0);
16182         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16183         e_conv = DecodeError_clone(&e_conv);
16184         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16185         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
16186         return (int64_t)ret_conv;
16187 }
16188
16189 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16190         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
16191         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
16192         return ret_conv;
16193 }
16194
16195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16196         if ((_res & 1) != 0) return;
16197         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16198         CHECK_ACCESS(_res_ptr);
16199         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
16200         FREE((void*)_res);
16201         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
16202 }
16203
16204 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
16205         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16206         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
16207         return (int64_t)ret_conv;
16208 }
16209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16210         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
16211         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
16212         return ret_conv;
16213 }
16214
16215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16216         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
16217         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16218         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
16219         return (int64_t)ret_conv;
16220 }
16221
16222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16223         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16224         CHECK_ACCESS(o_ptr);
16225         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
16226         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
16227         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16228         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
16229         int64_t ret_ref = (uintptr_t)ret_copy;
16230         return ret_ref;
16231 }
16232
16233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
16234         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16235         *ret_copy = COption_NetworkUpdateZ_none();
16236         int64_t ret_ref = (uintptr_t)ret_copy;
16237         return ret_ref;
16238 }
16239
16240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16241         if ((_res & 1) != 0) return;
16242         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16243         CHECK_ACCESS(_res_ptr);
16244         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
16245         FREE((void*)_res);
16246         COption_NetworkUpdateZ_free(_res_conv);
16247 }
16248
16249 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
16250         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16251         *ret_copy = COption_NetworkUpdateZ_clone(arg);
16252 int64_t ret_ref = (uintptr_t)ret_copy;
16253         return ret_ref;
16254 }
16255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16256         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
16257         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
16258         return ret_conv;
16259 }
16260
16261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16262         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
16263         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16264         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
16265         int64_t ret_ref = (uintptr_t)ret_copy;
16266         return ret_ref;
16267 }
16268
16269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16270         LDKCVec_SpendableOutputDescriptorZ _res_constr;
16271         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16272         if (_res_constr.datalen > 0)
16273                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16274         else
16275                 _res_constr.data = NULL;
16276         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16277         for (size_t b = 0; b < _res_constr.datalen; b++) {
16278                 int64_t _res_conv_27 = _res_vals[b];
16279                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
16280                 CHECK_ACCESS(_res_conv_27_ptr);
16281                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
16282                 FREE((void*)_res_conv_27);
16283                 _res_constr.data[b] = _res_conv_27_conv;
16284         }
16285         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16286         CVec_SpendableOutputDescriptorZ_free(_res_constr);
16287 }
16288
16289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16290         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16291         CHECK_ACCESS(o_ptr);
16292         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
16293         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
16294         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16295         *ret_copy = COption_EventZ_some(o_conv);
16296         int64_t ret_ref = (uintptr_t)ret_copy;
16297         return ret_ref;
16298 }
16299
16300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
16301         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16302         *ret_copy = COption_EventZ_none();
16303         int64_t ret_ref = (uintptr_t)ret_copy;
16304         return ret_ref;
16305 }
16306
16307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16308         if ((_res & 1) != 0) return;
16309         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16310         CHECK_ACCESS(_res_ptr);
16311         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
16312         FREE((void*)_res);
16313         COption_EventZ_free(_res_conv);
16314 }
16315
16316 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
16317         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16318         *ret_copy = COption_EventZ_clone(arg);
16319 int64_t ret_ref = (uintptr_t)ret_copy;
16320         return ret_ref;
16321 }
16322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16323         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
16324         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
16325         return ret_conv;
16326 }
16327
16328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16329         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
16330         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16331         *ret_copy = COption_EventZ_clone(orig_conv);
16332         int64_t ret_ref = (uintptr_t)ret_copy;
16333         return ret_ref;
16334 }
16335
16336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16337         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16338         CHECK_ACCESS(o_ptr);
16339         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
16340         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
16341         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16342         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
16343         return (int64_t)ret_conv;
16344 }
16345
16346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16347         LDKDecodeError e_conv;
16348         e_conv.inner = (void*)(e & (~1));
16349         e_conv.is_owned = (e & 1) || (e == 0);
16350         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16351         e_conv = DecodeError_clone(&e_conv);
16352         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16353         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
16354         return (int64_t)ret_conv;
16355 }
16356
16357 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16358         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
16359         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
16360         return ret_conv;
16361 }
16362
16363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16364         if ((_res & 1) != 0) return;
16365         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16366         CHECK_ACCESS(_res_ptr);
16367         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
16368         FREE((void*)_res);
16369         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
16370 }
16371
16372 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
16373         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16374         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
16375         return (int64_t)ret_conv;
16376 }
16377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16378         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
16379         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
16380         return ret_conv;
16381 }
16382
16383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16384         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
16385         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16386         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
16387         return (int64_t)ret_conv;
16388 }
16389
16390 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16391         LDKCVec_MessageSendEventZ _res_constr;
16392         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16393         if (_res_constr.datalen > 0)
16394                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
16395         else
16396                 _res_constr.data = NULL;
16397         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16398         for (size_t s = 0; s < _res_constr.datalen; s++) {
16399                 int64_t _res_conv_18 = _res_vals[s];
16400                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
16401                 CHECK_ACCESS(_res_conv_18_ptr);
16402                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
16403                 FREE((void*)_res_conv_18);
16404                 _res_constr.data[s] = _res_conv_18_conv;
16405         }
16406         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16407         CVec_MessageSendEventZ_free(_res_constr);
16408 }
16409
16410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16411         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16412         CHECK_ACCESS(o_ptr);
16413         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
16414         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
16415         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16416         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
16417         return (int64_t)ret_conv;
16418 }
16419
16420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16421         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
16422         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16423         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
16424         return (int64_t)ret_conv;
16425 }
16426
16427 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16428         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
16429         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
16430         return ret_conv;
16431 }
16432
16433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16434         if ((_res & 1) != 0) return;
16435         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16436         CHECK_ACCESS(_res_ptr);
16437         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
16438         FREE((void*)_res);
16439         CResult_TxOutAccessErrorZ_free(_res_conv);
16440 }
16441
16442 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
16443         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16444         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
16445         return (int64_t)ret_conv;
16446 }
16447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16448         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
16449         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
16450         return ret_conv;
16451 }
16452
16453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16454         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
16455         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16456         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
16457         return (int64_t)ret_conv;
16458 }
16459
16460 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
16461         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
16462         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
16463         return ((int64_t)ret_conv);
16464 }
16465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16466         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
16467         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
16468         return ret_conv;
16469 }
16470
16471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16472         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
16473         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
16474         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
16475         return ((int64_t)ret_conv);
16476 }
16477
16478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
16479         LDKTransaction b_ref;
16480         b_ref.datalen = (*env)->GetArrayLength(env, b);
16481         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
16482         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
16483         b_ref.data_is_owned = true;
16484         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
16485         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
16486         return ((int64_t)ret_conv);
16487 }
16488
16489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16490         if ((_res & 1) != 0) return;
16491         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16492         CHECK_ACCESS(_res_ptr);
16493         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
16494         FREE((void*)_res);
16495         C2Tuple_usizeTransactionZ_free(_res_conv);
16496 }
16497
16498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16499         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
16500         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16501         if (_res_constr.datalen > 0)
16502                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
16503         else
16504                 _res_constr.data = NULL;
16505         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16506         for (size_t c = 0; c < _res_constr.datalen; c++) {
16507                 int64_t _res_conv_28 = _res_vals[c];
16508                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
16509                 CHECK_ACCESS(_res_conv_28_ptr);
16510                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
16511                 FREE((void*)_res_conv_28);
16512                 _res_constr.data[c] = _res_conv_28_conv;
16513         }
16514         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16515         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
16516 }
16517
16518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16519         LDKCVec_TxidZ _res_constr;
16520         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16521         if (_res_constr.datalen > 0)
16522                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
16523         else
16524                 _res_constr.data = NULL;
16525         for (size_t i = 0; i < _res_constr.datalen; i++) {
16526                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16527                 LDKThirtyTwoBytes _res_conv_8_ref;
16528                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
16529                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
16530                 _res_constr.data[i] = _res_conv_8_ref;
16531         }
16532         CVec_TxidZ_free(_res_constr);
16533 }
16534
16535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
16536         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
16537         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
16538         return (int64_t)ret_conv;
16539 }
16540
16541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
16542         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
16543         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
16544         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
16545         return (int64_t)ret_conv;
16546 }
16547
16548 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16549         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
16550         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
16551         return ret_conv;
16552 }
16553
16554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16555         if ((_res & 1) != 0) return;
16556         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16557         CHECK_ACCESS(_res_ptr);
16558         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
16559         FREE((void*)_res);
16560         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
16561 }
16562
16563 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
16564         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
16565         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
16566         return (int64_t)ret_conv;
16567 }
16568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16569         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
16570         int64_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
16571         return ret_conv;
16572 }
16573
16574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16575         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
16576         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
16577         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
16578         return (int64_t)ret_conv;
16579 }
16580
16581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16582         LDKCVec_MonitorEventZ _res_constr;
16583         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16584         if (_res_constr.datalen > 0)
16585                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
16586         else
16587                 _res_constr.data = NULL;
16588         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16589         for (size_t o = 0; o < _res_constr.datalen; o++) {
16590                 int64_t _res_conv_14 = _res_vals[o];
16591                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
16592                 CHECK_ACCESS(_res_conv_14_ptr);
16593                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
16594                 FREE((void*)_res_conv_14);
16595                 _res_constr.data[o] = _res_conv_14_conv;
16596         }
16597         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16598         CVec_MonitorEventZ_free(_res_constr);
16599 }
16600
16601 static inline uintptr_t C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR arg) {
16602         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
16603         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone(arg);
16604         return ((int64_t)ret_conv);
16605 }
16606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16607         LDKC2Tuple_OutPointCVec_MonitorEventZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(arg & ~1);
16608         int64_t ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(arg_conv);
16609         return ret_conv;
16610 }
16611
16612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16613         LDKC2Tuple_OutPointCVec_MonitorEventZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(orig & ~1);
16614         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
16615         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone(orig_conv);
16616         return ((int64_t)ret_conv);
16617 }
16618
16619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b) {
16620         LDKOutPoint a_conv;
16621         a_conv.inner = (void*)(a & (~1));
16622         a_conv.is_owned = (a & 1) || (a == 0);
16623         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16624         a_conv = OutPoint_clone(&a_conv);
16625         LDKCVec_MonitorEventZ b_constr;
16626         b_constr.datalen = (*env)->GetArrayLength(env, b);
16627         if (b_constr.datalen > 0)
16628                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
16629         else
16630                 b_constr.data = NULL;
16631         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
16632         for (size_t o = 0; o < b_constr.datalen; o++) {
16633                 int64_t b_conv_14 = b_vals[o];
16634                 void* b_conv_14_ptr = (void*)(((uintptr_t)b_conv_14) & ~1);
16635                 CHECK_ACCESS(b_conv_14_ptr);
16636                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
16637                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)b_conv_14) & ~1));
16638                 b_constr.data[o] = b_conv_14_conv;
16639         }
16640         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
16641         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
16642         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_new(a_conv, b_constr);
16643         return ((int64_t)ret_conv);
16644 }
16645
16646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16647         if ((_res & 1) != 0) return;
16648         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16649         CHECK_ACCESS(_res_ptr);
16650         LDKC2Tuple_OutPointCVec_MonitorEventZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(_res_ptr);
16651         FREE((void*)_res);
16652         C2Tuple_OutPointCVec_MonitorEventZZ_free(_res_conv);
16653 }
16654
16655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1OutPointCVec_1MonitorEventZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16656         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ _res_constr;
16657         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16658         if (_res_constr.datalen > 0)
16659                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ Elements");
16660         else
16661                 _res_constr.data = NULL;
16662         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16663         for (size_t m = 0; m < _res_constr.datalen; m++) {
16664                 int64_t _res_conv_38 = _res_vals[m];
16665                 void* _res_conv_38_ptr = (void*)(((uintptr_t)_res_conv_38) & ~1);
16666                 CHECK_ACCESS(_res_conv_38_ptr);
16667                 LDKC2Tuple_OutPointCVec_MonitorEventZZ _res_conv_38_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(_res_conv_38_ptr);
16668                 FREE((void*)_res_conv_38);
16669                 _res_constr.data[m] = _res_conv_38_conv;
16670         }
16671         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16672         CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_free(_res_constr);
16673 }
16674
16675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16676         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16677         CHECK_ACCESS(o_ptr);
16678         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
16679         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
16680         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
16681         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
16682         int64_t ret_ref = (uintptr_t)ret_copy;
16683         return ret_ref;
16684 }
16685
16686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
16687         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
16688         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
16689         int64_t ret_ref = (uintptr_t)ret_copy;
16690         return ret_ref;
16691 }
16692
16693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16694         if ((_res & 1) != 0) return;
16695         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16696         CHECK_ACCESS(_res_ptr);
16697         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
16698         FREE((void*)_res);
16699         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
16700 }
16701
16702 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
16703         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
16704         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
16705 int64_t ret_ref = (uintptr_t)ret_copy;
16706         return ret_ref;
16707 }
16708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16709         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
16710         int64_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
16711         return ret_conv;
16712 }
16713
16714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16715         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
16716         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
16717         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
16718         int64_t ret_ref = (uintptr_t)ret_copy;
16719         return ret_ref;
16720 }
16721
16722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16723         LDKFixedPenaltyScorer o_conv;
16724         o_conv.inner = (void*)(o & (~1));
16725         o_conv.is_owned = (o & 1) || (o == 0);
16726         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16727         o_conv = FixedPenaltyScorer_clone(&o_conv);
16728         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16729         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
16730         return (int64_t)ret_conv;
16731 }
16732
16733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16734         LDKDecodeError e_conv;
16735         e_conv.inner = (void*)(e & (~1));
16736         e_conv.is_owned = (e & 1) || (e == 0);
16737         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16738         e_conv = DecodeError_clone(&e_conv);
16739         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16740         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
16741         return (int64_t)ret_conv;
16742 }
16743
16744 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16745         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
16746         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
16747         return ret_conv;
16748 }
16749
16750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16751         if ((_res & 1) != 0) return;
16752         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16753         CHECK_ACCESS(_res_ptr);
16754         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
16755         FREE((void*)_res);
16756         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
16757 }
16758
16759 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
16760         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16761         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
16762         return (int64_t)ret_conv;
16763 }
16764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16765         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
16766         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
16767         return ret_conv;
16768 }
16769
16770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16771         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
16772         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16773         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
16774         return (int64_t)ret_conv;
16775 }
16776
16777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16778         LDKProbabilisticScorer o_conv;
16779         o_conv.inner = (void*)(o & (~1));
16780         o_conv.is_owned = (o & 1) || (o == 0);
16781         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16782         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
16783         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16784         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
16785         return (int64_t)ret_conv;
16786 }
16787
16788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16789         LDKDecodeError e_conv;
16790         e_conv.inner = (void*)(e & (~1));
16791         e_conv.is_owned = (e & 1) || (e == 0);
16792         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16793         e_conv = DecodeError_clone(&e_conv);
16794         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16795         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
16796         return (int64_t)ret_conv;
16797 }
16798
16799 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16800         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
16801         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
16802         return ret_conv;
16803 }
16804
16805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16806         if ((_res & 1) != 0) return;
16807         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16808         CHECK_ACCESS(_res_ptr);
16809         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
16810         FREE((void*)_res);
16811         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
16812 }
16813
16814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16815         LDKInitFeatures o_conv;
16816         o_conv.inner = (void*)(o & (~1));
16817         o_conv.is_owned = (o & 1) || (o == 0);
16818         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16819         o_conv = InitFeatures_clone(&o_conv);
16820         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16821         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
16822         return (int64_t)ret_conv;
16823 }
16824
16825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16826         LDKDecodeError e_conv;
16827         e_conv.inner = (void*)(e & (~1));
16828         e_conv.is_owned = (e & 1) || (e == 0);
16829         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16830         e_conv = DecodeError_clone(&e_conv);
16831         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16832         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
16833         return (int64_t)ret_conv;
16834 }
16835
16836 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16837         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
16838         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
16839         return ret_conv;
16840 }
16841
16842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16843         if ((_res & 1) != 0) return;
16844         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16845         CHECK_ACCESS(_res_ptr);
16846         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
16847         FREE((void*)_res);
16848         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
16849 }
16850
16851 static inline uintptr_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
16852         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16853         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
16854         return (int64_t)ret_conv;
16855 }
16856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16857         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
16858         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
16859         return ret_conv;
16860 }
16861
16862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16863         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(orig & ~1);
16864         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16865         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
16866         return (int64_t)ret_conv;
16867 }
16868
16869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16870         LDKChannelFeatures o_conv;
16871         o_conv.inner = (void*)(o & (~1));
16872         o_conv.is_owned = (o & 1) || (o == 0);
16873         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16874         o_conv = ChannelFeatures_clone(&o_conv);
16875         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16876         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
16877         return (int64_t)ret_conv;
16878 }
16879
16880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16881         LDKDecodeError e_conv;
16882         e_conv.inner = (void*)(e & (~1));
16883         e_conv.is_owned = (e & 1) || (e == 0);
16884         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16885         e_conv = DecodeError_clone(&e_conv);
16886         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16887         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
16888         return (int64_t)ret_conv;
16889 }
16890
16891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16892         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
16893         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
16894         return ret_conv;
16895 }
16896
16897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16898         if ((_res & 1) != 0) return;
16899         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16900         CHECK_ACCESS(_res_ptr);
16901         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
16902         FREE((void*)_res);
16903         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
16904 }
16905
16906 static inline uintptr_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
16907         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16908         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
16909         return (int64_t)ret_conv;
16910 }
16911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16912         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
16913         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
16914         return ret_conv;
16915 }
16916
16917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16918         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(orig & ~1);
16919         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16920         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
16921         return (int64_t)ret_conv;
16922 }
16923
16924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16925         LDKNodeFeatures o_conv;
16926         o_conv.inner = (void*)(o & (~1));
16927         o_conv.is_owned = (o & 1) || (o == 0);
16928         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16929         o_conv = NodeFeatures_clone(&o_conv);
16930         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16931         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
16932         return (int64_t)ret_conv;
16933 }
16934
16935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16936         LDKDecodeError e_conv;
16937         e_conv.inner = (void*)(e & (~1));
16938         e_conv.is_owned = (e & 1) || (e == 0);
16939         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16940         e_conv = DecodeError_clone(&e_conv);
16941         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16942         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
16943         return (int64_t)ret_conv;
16944 }
16945
16946 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16947         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
16948         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
16949         return ret_conv;
16950 }
16951
16952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16953         if ((_res & 1) != 0) return;
16954         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16955         CHECK_ACCESS(_res_ptr);
16956         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
16957         FREE((void*)_res);
16958         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
16959 }
16960
16961 static inline uintptr_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
16962         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16963         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
16964         return (int64_t)ret_conv;
16965 }
16966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16967         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
16968         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
16969         return ret_conv;
16970 }
16971
16972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16973         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(orig & ~1);
16974         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16975         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
16976         return (int64_t)ret_conv;
16977 }
16978
16979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16980         LDKInvoiceFeatures o_conv;
16981         o_conv.inner = (void*)(o & (~1));
16982         o_conv.is_owned = (o & 1) || (o == 0);
16983         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16984         o_conv = InvoiceFeatures_clone(&o_conv);
16985         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16986         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
16987         return (int64_t)ret_conv;
16988 }
16989
16990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16991         LDKDecodeError e_conv;
16992         e_conv.inner = (void*)(e & (~1));
16993         e_conv.is_owned = (e & 1) || (e == 0);
16994         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16995         e_conv = DecodeError_clone(&e_conv);
16996         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16997         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
16998         return (int64_t)ret_conv;
16999 }
17000
17001 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17002         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
17003         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
17004         return ret_conv;
17005 }
17006
17007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17008         if ((_res & 1) != 0) return;
17009         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17010         CHECK_ACCESS(_res_ptr);
17011         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
17012         FREE((void*)_res);
17013         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
17014 }
17015
17016 static inline uintptr_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17017         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17018         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
17019         return (int64_t)ret_conv;
17020 }
17021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17022         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
17023         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17024         return ret_conv;
17025 }
17026
17027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17028         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(orig & ~1);
17029         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17030         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
17031         return (int64_t)ret_conv;
17032 }
17033
17034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17035         LDKChannelTypeFeatures o_conv;
17036         o_conv.inner = (void*)(o & (~1));
17037         o_conv.is_owned = (o & 1) || (o == 0);
17038         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17039         o_conv = ChannelTypeFeatures_clone(&o_conv);
17040         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17041         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
17042         return (int64_t)ret_conv;
17043 }
17044
17045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17046         LDKDecodeError e_conv;
17047         e_conv.inner = (void*)(e & (~1));
17048         e_conv.is_owned = (e & 1) || (e == 0);
17049         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17050         e_conv = DecodeError_clone(&e_conv);
17051         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17052         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
17053         return (int64_t)ret_conv;
17054 }
17055
17056 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17057         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
17058         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
17059         return ret_conv;
17060 }
17061
17062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17063         if ((_res & 1) != 0) return;
17064         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17065         CHECK_ACCESS(_res_ptr);
17066         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
17067         FREE((void*)_res);
17068         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
17069 }
17070
17071 static inline uintptr_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17072         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17073         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
17074         return (int64_t)ret_conv;
17075 }
17076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17077         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
17078         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17079         return ret_conv;
17080 }
17081
17082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17083         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(orig & ~1);
17084         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17085         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
17086         return (int64_t)ret_conv;
17087 }
17088
17089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17090         LDKNodeId o_conv;
17091         o_conv.inner = (void*)(o & (~1));
17092         o_conv.is_owned = (o & 1) || (o == 0);
17093         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17094         o_conv = NodeId_clone(&o_conv);
17095         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17096         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
17097         return (int64_t)ret_conv;
17098 }
17099
17100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17101         LDKDecodeError e_conv;
17102         e_conv.inner = (void*)(e & (~1));
17103         e_conv.is_owned = (e & 1) || (e == 0);
17104         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17105         e_conv = DecodeError_clone(&e_conv);
17106         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17107         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
17108         return (int64_t)ret_conv;
17109 }
17110
17111 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17112         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
17113         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
17114         return ret_conv;
17115 }
17116
17117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17118         if ((_res & 1) != 0) return;
17119         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17120         CHECK_ACCESS(_res_ptr);
17121         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
17122         FREE((void*)_res);
17123         CResult_NodeIdDecodeErrorZ_free(_res_conv);
17124 }
17125
17126 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
17127         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17128         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
17129         return (int64_t)ret_conv;
17130 }
17131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17132         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
17133         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
17134         return ret_conv;
17135 }
17136
17137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17138         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
17139         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17140         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
17141         return (int64_t)ret_conv;
17142 }
17143
17144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17145         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17146         CHECK_ACCESS(o_ptr);
17147         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
17148         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
17149         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17150         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
17151         return (int64_t)ret_conv;
17152 }
17153
17154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17155         LDKDecodeError e_conv;
17156         e_conv.inner = (void*)(e & (~1));
17157         e_conv.is_owned = (e & 1) || (e == 0);
17158         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17159         e_conv = DecodeError_clone(&e_conv);
17160         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17161         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
17162         return (int64_t)ret_conv;
17163 }
17164
17165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17166         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
17167         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
17168         return ret_conv;
17169 }
17170
17171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17172         if ((_res & 1) != 0) return;
17173         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17174         CHECK_ACCESS(_res_ptr);
17175         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
17176         FREE((void*)_res);
17177         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
17178 }
17179
17180 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
17181         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17182         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
17183         return (int64_t)ret_conv;
17184 }
17185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17186         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
17187         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
17188         return ret_conv;
17189 }
17190
17191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17192         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
17193         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17194         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
17195         return (int64_t)ret_conv;
17196 }
17197
17198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17199         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17200         CHECK_ACCESS(o_ptr);
17201         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
17202         if (o_conv.free == LDKAccess_JCalls_free) {
17203                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17204                 LDKAccess_JCalls_cloned(&o_conv);
17205         }
17206         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17207         *ret_copy = COption_AccessZ_some(o_conv);
17208         int64_t ret_ref = (uintptr_t)ret_copy;
17209         return ret_ref;
17210 }
17211
17212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
17213         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17214         *ret_copy = COption_AccessZ_none();
17215         int64_t ret_ref = (uintptr_t)ret_copy;
17216         return ret_ref;
17217 }
17218
17219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17220         if ((_res & 1) != 0) return;
17221         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17222         CHECK_ACCESS(_res_ptr);
17223         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
17224         FREE((void*)_res);
17225         COption_AccessZ_free(_res_conv);
17226 }
17227
17228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
17229         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17230         *ret_conv = CResult_boolLightningErrorZ_ok(o);
17231         return (int64_t)ret_conv;
17232 }
17233
17234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17235         LDKLightningError e_conv;
17236         e_conv.inner = (void*)(e & (~1));
17237         e_conv.is_owned = (e & 1) || (e == 0);
17238         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17239         e_conv = LightningError_clone(&e_conv);
17240         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17241         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
17242         return (int64_t)ret_conv;
17243 }
17244
17245 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17246         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
17247         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
17248         return ret_conv;
17249 }
17250
17251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17252         if ((_res & 1) != 0) return;
17253         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17254         CHECK_ACCESS(_res_ptr);
17255         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
17256         FREE((void*)_res);
17257         CResult_boolLightningErrorZ_free(_res_conv);
17258 }
17259
17260 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
17261         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17262         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
17263         return (int64_t)ret_conv;
17264 }
17265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17266         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
17267         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
17268         return ret_conv;
17269 }
17270
17271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17272         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
17273         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17274         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
17275         return (int64_t)ret_conv;
17276 }
17277
17278 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
17279         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17280         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
17281         return ((int64_t)ret_conv);
17282 }
17283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17284         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
17285         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
17286         return ret_conv;
17287 }
17288
17289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17290         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
17291         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17292         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
17293         return ((int64_t)ret_conv);
17294 }
17295
17296 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) {
17297         LDKChannelAnnouncement a_conv;
17298         a_conv.inner = (void*)(a & (~1));
17299         a_conv.is_owned = (a & 1) || (a == 0);
17300         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17301         a_conv = ChannelAnnouncement_clone(&a_conv);
17302         LDKChannelUpdate b_conv;
17303         b_conv.inner = (void*)(b & (~1));
17304         b_conv.is_owned = (b & 1) || (b == 0);
17305         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17306         b_conv = ChannelUpdate_clone(&b_conv);
17307         LDKChannelUpdate c_conv;
17308         c_conv.inner = (void*)(c & (~1));
17309         c_conv.is_owned = (c & 1) || (c == 0);
17310         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
17311         c_conv = ChannelUpdate_clone(&c_conv);
17312         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17313         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
17314         return ((int64_t)ret_conv);
17315 }
17316
17317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17318         if ((_res & 1) != 0) return;
17319         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17320         CHECK_ACCESS(_res_ptr);
17321         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
17322         FREE((void*)_res);
17323         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
17324 }
17325
17326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17327         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
17328         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17329         if (_res_constr.datalen > 0)
17330                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
17331         else
17332                 _res_constr.data = NULL;
17333         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17334         for (size_t h = 0; h < _res_constr.datalen; h++) {
17335                 int64_t _res_conv_59 = _res_vals[h];
17336                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
17337                 CHECK_ACCESS(_res_conv_59_ptr);
17338                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
17339                 FREE((void*)_res_conv_59);
17340                 _res_constr.data[h] = _res_conv_59_conv;
17341         }
17342         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17343         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
17344 }
17345
17346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17347         LDKCVec_NodeAnnouncementZ _res_constr;
17348         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17349         if (_res_constr.datalen > 0)
17350                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
17351         else
17352                 _res_constr.data = NULL;
17353         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17354         for (size_t s = 0; s < _res_constr.datalen; s++) {
17355                 int64_t _res_conv_18 = _res_vals[s];
17356                 LDKNodeAnnouncement _res_conv_18_conv;
17357                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
17358                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
17359                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
17360                 _res_constr.data[s] = _res_conv_18_conv;
17361         }
17362         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17363         CVec_NodeAnnouncementZ_free(_res_constr);
17364 }
17365
17366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
17367         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
17368         *ret_conv = CResult_NoneLightningErrorZ_ok();
17369         return (int64_t)ret_conv;
17370 }
17371
17372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17373         LDKLightningError e_conv;
17374         e_conv.inner = (void*)(e & (~1));
17375         e_conv.is_owned = (e & 1) || (e == 0);
17376         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17377         e_conv = LightningError_clone(&e_conv);
17378         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
17379         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
17380         return (int64_t)ret_conv;
17381 }
17382
17383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17384         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
17385         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
17386         return ret_conv;
17387 }
17388
17389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17390         if ((_res & 1) != 0) return;
17391         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17392         CHECK_ACCESS(_res_ptr);
17393         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
17394         FREE((void*)_res);
17395         CResult_NoneLightningErrorZ_free(_res_conv);
17396 }
17397
17398 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
17399         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
17400         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
17401         return (int64_t)ret_conv;
17402 }
17403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17404         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
17405         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
17406         return ret_conv;
17407 }
17408
17409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17410         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
17411         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
17412         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
17413         return (int64_t)ret_conv;
17414 }
17415
17416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17417         LDKChannelUpdateInfo o_conv;
17418         o_conv.inner = (void*)(o & (~1));
17419         o_conv.is_owned = (o & 1) || (o == 0);
17420         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17421         o_conv = ChannelUpdateInfo_clone(&o_conv);
17422         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17423         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
17424         return (int64_t)ret_conv;
17425 }
17426
17427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17428         LDKDecodeError e_conv;
17429         e_conv.inner = (void*)(e & (~1));
17430         e_conv.is_owned = (e & 1) || (e == 0);
17431         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17432         e_conv = DecodeError_clone(&e_conv);
17433         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17434         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
17435         return (int64_t)ret_conv;
17436 }
17437
17438 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17439         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
17440         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
17441         return ret_conv;
17442 }
17443
17444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17445         if ((_res & 1) != 0) return;
17446         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17447         CHECK_ACCESS(_res_ptr);
17448         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
17449         FREE((void*)_res);
17450         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
17451 }
17452
17453 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
17454         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17455         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
17456         return (int64_t)ret_conv;
17457 }
17458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17459         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
17460         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
17461         return ret_conv;
17462 }
17463
17464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17465         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
17466         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17467         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
17468         return (int64_t)ret_conv;
17469 }
17470
17471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17472         LDKChannelInfo o_conv;
17473         o_conv.inner = (void*)(o & (~1));
17474         o_conv.is_owned = (o & 1) || (o == 0);
17475         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17476         o_conv = ChannelInfo_clone(&o_conv);
17477         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17478         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
17479         return (int64_t)ret_conv;
17480 }
17481
17482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17483         LDKDecodeError e_conv;
17484         e_conv.inner = (void*)(e & (~1));
17485         e_conv.is_owned = (e & 1) || (e == 0);
17486         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17487         e_conv = DecodeError_clone(&e_conv);
17488         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17489         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
17490         return (int64_t)ret_conv;
17491 }
17492
17493 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17494         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
17495         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
17496         return ret_conv;
17497 }
17498
17499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17500         if ((_res & 1) != 0) return;
17501         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17502         CHECK_ACCESS(_res_ptr);
17503         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
17504         FREE((void*)_res);
17505         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
17506 }
17507
17508 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
17509         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17510         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
17511         return (int64_t)ret_conv;
17512 }
17513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17514         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
17515         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
17516         return ret_conv;
17517 }
17518
17519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17520         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
17521         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17522         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
17523         return (int64_t)ret_conv;
17524 }
17525
17526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17527         LDKRoutingFees o_conv;
17528         o_conv.inner = (void*)(o & (~1));
17529         o_conv.is_owned = (o & 1) || (o == 0);
17530         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17531         o_conv = RoutingFees_clone(&o_conv);
17532         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17533         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
17534         return (int64_t)ret_conv;
17535 }
17536
17537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17538         LDKDecodeError e_conv;
17539         e_conv.inner = (void*)(e & (~1));
17540         e_conv.is_owned = (e & 1) || (e == 0);
17541         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17542         e_conv = DecodeError_clone(&e_conv);
17543         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17544         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
17545         return (int64_t)ret_conv;
17546 }
17547
17548 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17549         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
17550         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
17551         return ret_conv;
17552 }
17553
17554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17555         if ((_res & 1) != 0) return;
17556         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17557         CHECK_ACCESS(_res_ptr);
17558         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
17559         FREE((void*)_res);
17560         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
17561 }
17562
17563 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
17564         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17565         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
17566         return (int64_t)ret_conv;
17567 }
17568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17569         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
17570         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
17571         return ret_conv;
17572 }
17573
17574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17575         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
17576         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17577         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
17578         return (int64_t)ret_conv;
17579 }
17580
17581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17582         LDKCVec_NetAddressZ _res_constr;
17583         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17584         if (_res_constr.datalen > 0)
17585                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17586         else
17587                 _res_constr.data = NULL;
17588         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17589         for (size_t m = 0; m < _res_constr.datalen; m++) {
17590                 int64_t _res_conv_12 = _res_vals[m];
17591                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
17592                 CHECK_ACCESS(_res_conv_12_ptr);
17593                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
17594                 FREE((void*)_res_conv_12);
17595                 _res_constr.data[m] = _res_conv_12_conv;
17596         }
17597         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17598         CVec_NetAddressZ_free(_res_constr);
17599 }
17600
17601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17602         LDKNodeAnnouncementInfo o_conv;
17603         o_conv.inner = (void*)(o & (~1));
17604         o_conv.is_owned = (o & 1) || (o == 0);
17605         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17606         o_conv = NodeAnnouncementInfo_clone(&o_conv);
17607         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17608         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
17609         return (int64_t)ret_conv;
17610 }
17611
17612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17613         LDKDecodeError e_conv;
17614         e_conv.inner = (void*)(e & (~1));
17615         e_conv.is_owned = (e & 1) || (e == 0);
17616         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17617         e_conv = DecodeError_clone(&e_conv);
17618         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17619         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
17620         return (int64_t)ret_conv;
17621 }
17622
17623 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17624         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
17625         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
17626         return ret_conv;
17627 }
17628
17629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17630         if ((_res & 1) != 0) return;
17631         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17632         CHECK_ACCESS(_res_ptr);
17633         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
17634         FREE((void*)_res);
17635         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
17636 }
17637
17638 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
17639         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17640         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
17641         return (int64_t)ret_conv;
17642 }
17643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17644         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
17645         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
17646         return ret_conv;
17647 }
17648
17649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17650         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
17651         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17652         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
17653         return (int64_t)ret_conv;
17654 }
17655
17656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17657         LDKCVec_u64Z _res_constr;
17658         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17659         if (_res_constr.datalen > 0)
17660                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17661         else
17662                 _res_constr.data = NULL;
17663         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17664         for (size_t g = 0; g < _res_constr.datalen; g++) {
17665                 int64_t _res_conv_6 = _res_vals[g];
17666                 _res_constr.data[g] = _res_conv_6;
17667         }
17668         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17669         CVec_u64Z_free(_res_constr);
17670 }
17671
17672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17673         LDKNodeInfo o_conv;
17674         o_conv.inner = (void*)(o & (~1));
17675         o_conv.is_owned = (o & 1) || (o == 0);
17676         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17677         o_conv = NodeInfo_clone(&o_conv);
17678         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17679         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
17680         return (int64_t)ret_conv;
17681 }
17682
17683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17684         LDKDecodeError e_conv;
17685         e_conv.inner = (void*)(e & (~1));
17686         e_conv.is_owned = (e & 1) || (e == 0);
17687         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17688         e_conv = DecodeError_clone(&e_conv);
17689         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17690         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
17691         return (int64_t)ret_conv;
17692 }
17693
17694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17695         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
17696         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
17697         return ret_conv;
17698 }
17699
17700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17701         if ((_res & 1) != 0) return;
17702         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17703         CHECK_ACCESS(_res_ptr);
17704         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
17705         FREE((void*)_res);
17706         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
17707 }
17708
17709 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
17710         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17711         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
17712         return (int64_t)ret_conv;
17713 }
17714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17715         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
17716         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
17717         return ret_conv;
17718 }
17719
17720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17721         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
17722         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17723         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
17724         return (int64_t)ret_conv;
17725 }
17726
17727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17728         LDKNetworkGraph o_conv;
17729         o_conv.inner = (void*)(o & (~1));
17730         o_conv.is_owned = (o & 1) || (o == 0);
17731         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17732         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
17733         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17734         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
17735         return (int64_t)ret_conv;
17736 }
17737
17738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17739         LDKDecodeError e_conv;
17740         e_conv.inner = (void*)(e & (~1));
17741         e_conv.is_owned = (e & 1) || (e == 0);
17742         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17743         e_conv = DecodeError_clone(&e_conv);
17744         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17745         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
17746         return (int64_t)ret_conv;
17747 }
17748
17749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17750         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
17751         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
17752         return ret_conv;
17753 }
17754
17755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17756         if ((_res & 1) != 0) return;
17757         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17758         CHECK_ACCESS(_res_ptr);
17759         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
17760         FREE((void*)_res);
17761         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
17762 }
17763
17764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
17765         LDKCVec_NetAddressZ o_constr;
17766         o_constr.datalen = (*env)->GetArrayLength(env, o);
17767         if (o_constr.datalen > 0)
17768                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17769         else
17770                 o_constr.data = NULL;
17771         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
17772         for (size_t m = 0; m < o_constr.datalen; m++) {
17773                 int64_t o_conv_12 = o_vals[m];
17774                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
17775                 CHECK_ACCESS(o_conv_12_ptr);
17776                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
17777                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
17778                 o_constr.data[m] = o_conv_12_conv;
17779         }
17780         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
17781         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17782         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
17783         int64_t ret_ref = (uintptr_t)ret_copy;
17784         return ret_ref;
17785 }
17786
17787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
17788         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17789         *ret_copy = COption_CVec_NetAddressZZ_none();
17790         int64_t ret_ref = (uintptr_t)ret_copy;
17791         return ret_ref;
17792 }
17793
17794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17795         if ((_res & 1) != 0) return;
17796         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17797         CHECK_ACCESS(_res_ptr);
17798         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
17799         FREE((void*)_res);
17800         COption_CVec_NetAddressZZ_free(_res_conv);
17801 }
17802
17803 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
17804         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17805         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
17806 int64_t ret_ref = (uintptr_t)ret_copy;
17807         return ret_ref;
17808 }
17809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17810         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
17811         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
17812         return ret_conv;
17813 }
17814
17815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17816         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
17817         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17818         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
17819         int64_t ret_ref = (uintptr_t)ret_copy;
17820         return ret_ref;
17821 }
17822
17823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17824         LDKDelayedPaymentOutputDescriptor o_conv;
17825         o_conv.inner = (void*)(o & (~1));
17826         o_conv.is_owned = (o & 1) || (o == 0);
17827         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17828         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
17829         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
17830         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
17831         return (int64_t)ret_conv;
17832 }
17833
17834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17835         LDKDecodeError e_conv;
17836         e_conv.inner = (void*)(e & (~1));
17837         e_conv.is_owned = (e & 1) || (e == 0);
17838         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17839         e_conv = DecodeError_clone(&e_conv);
17840         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
17841         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
17842         return (int64_t)ret_conv;
17843 }
17844
17845 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17846         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
17847         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
17848         return ret_conv;
17849 }
17850
17851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17852         if ((_res & 1) != 0) return;
17853         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17854         CHECK_ACCESS(_res_ptr);
17855         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
17856         FREE((void*)_res);
17857         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
17858 }
17859
17860 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
17861         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
17862         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
17863         return (int64_t)ret_conv;
17864 }
17865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17866         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
17867         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
17868         return ret_conv;
17869 }
17870
17871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17872         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
17873         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
17874         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
17875         return (int64_t)ret_conv;
17876 }
17877
17878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17879         LDKStaticPaymentOutputDescriptor o_conv;
17880         o_conv.inner = (void*)(o & (~1));
17881         o_conv.is_owned = (o & 1) || (o == 0);
17882         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17883         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
17884         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
17885         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
17886         return (int64_t)ret_conv;
17887 }
17888
17889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17890         LDKDecodeError e_conv;
17891         e_conv.inner = (void*)(e & (~1));
17892         e_conv.is_owned = (e & 1) || (e == 0);
17893         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17894         e_conv = DecodeError_clone(&e_conv);
17895         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
17896         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
17897         return (int64_t)ret_conv;
17898 }
17899
17900 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17901         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
17902         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
17903         return ret_conv;
17904 }
17905
17906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17907         if ((_res & 1) != 0) return;
17908         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17909         CHECK_ACCESS(_res_ptr);
17910         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
17911         FREE((void*)_res);
17912         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
17913 }
17914
17915 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
17916         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
17917         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
17918         return (int64_t)ret_conv;
17919 }
17920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17921         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
17922         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
17923         return ret_conv;
17924 }
17925
17926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17927         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
17928         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
17929         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
17930         return (int64_t)ret_conv;
17931 }
17932
17933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17934         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17935         CHECK_ACCESS(o_ptr);
17936         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
17937         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
17938         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
17939         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
17940         return (int64_t)ret_conv;
17941 }
17942
17943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17944         LDKDecodeError e_conv;
17945         e_conv.inner = (void*)(e & (~1));
17946         e_conv.is_owned = (e & 1) || (e == 0);
17947         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17948         e_conv = DecodeError_clone(&e_conv);
17949         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
17950         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
17951         return (int64_t)ret_conv;
17952 }
17953
17954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17955         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
17956         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
17957         return ret_conv;
17958 }
17959
17960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17961         if ((_res & 1) != 0) return;
17962         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17963         CHECK_ACCESS(_res_ptr);
17964         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
17965         FREE((void*)_res);
17966         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
17967 }
17968
17969 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
17970         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
17971         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
17972         return (int64_t)ret_conv;
17973 }
17974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17975         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
17976         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
17977         return ret_conv;
17978 }
17979
17980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17981         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
17982         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
17983         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
17984         return (int64_t)ret_conv;
17985 }
17986
17987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17988         LDKCVec_PaymentPreimageZ _res_constr;
17989         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17990         if (_res_constr.datalen > 0)
17991                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
17992         else
17993                 _res_constr.data = NULL;
17994         for (size_t i = 0; i < _res_constr.datalen; i++) {
17995                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
17996                 LDKThirtyTwoBytes _res_conv_8_ref;
17997                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
17998                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
17999                 _res_constr.data[i] = _res_conv_8_ref;
18000         }
18001         CVec_PaymentPreimageZ_free(_res_constr);
18002 }
18003
18004 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
18005         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18006         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
18007         return ((int64_t)ret_conv);
18008 }
18009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18010         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
18011         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
18012         return ret_conv;
18013 }
18014
18015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18016         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
18017         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18018         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
18019         return ((int64_t)ret_conv);
18020 }
18021
18022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
18023         LDKSignature a_ref;
18024         CHECK((*env)->GetArrayLength(env, a) == 64);
18025         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
18026         LDKCVec_SignatureZ b_constr;
18027         b_constr.datalen = (*env)->GetArrayLength(env, b);
18028         if (b_constr.datalen > 0)
18029                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18030         else
18031                 b_constr.data = NULL;
18032         for (size_t i = 0; i < b_constr.datalen; i++) {
18033                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
18034                 LDKSignature b_conv_8_ref;
18035                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
18036                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
18037                 b_constr.data[i] = b_conv_8_ref;
18038         }
18039         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18040         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
18041         return ((int64_t)ret_conv);
18042 }
18043
18044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18045         if ((_res & 1) != 0) return;
18046         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18047         CHECK_ACCESS(_res_ptr);
18048         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
18049         FREE((void*)_res);
18050         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
18051 }
18052
18053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18054         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18055         CHECK_ACCESS(o_ptr);
18056         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
18057         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
18058         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18059         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
18060         return (int64_t)ret_conv;
18061 }
18062
18063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
18064         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18065         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
18066         return (int64_t)ret_conv;
18067 }
18068
18069 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18070         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
18071         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
18072         return ret_conv;
18073 }
18074
18075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18076         if ((_res & 1) != 0) return;
18077         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18078         CHECK_ACCESS(_res_ptr);
18079         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
18080         FREE((void*)_res);
18081         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
18082 }
18083
18084 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
18085         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18086         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
18087         return (int64_t)ret_conv;
18088 }
18089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18090         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
18091         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
18092         return ret_conv;
18093 }
18094
18095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18096         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
18097         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18098         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
18099         return (int64_t)ret_conv;
18100 }
18101
18102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18103         LDKSignature o_ref;
18104         CHECK((*env)->GetArrayLength(env, o) == 64);
18105         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
18106         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18107         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
18108         return (int64_t)ret_conv;
18109 }
18110
18111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
18112         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18113         *ret_conv = CResult_SignatureNoneZ_err();
18114         return (int64_t)ret_conv;
18115 }
18116
18117 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18118         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
18119         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
18120         return ret_conv;
18121 }
18122
18123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18124         if ((_res & 1) != 0) return;
18125         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18126         CHECK_ACCESS(_res_ptr);
18127         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
18128         FREE((void*)_res);
18129         CResult_SignatureNoneZ_free(_res_conv);
18130 }
18131
18132 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
18133         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18134         *ret_conv = CResult_SignatureNoneZ_clone(arg);
18135         return (int64_t)ret_conv;
18136 }
18137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18138         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
18139         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
18140         return ret_conv;
18141 }
18142
18143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18144         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
18145         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18146         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
18147         return (int64_t)ret_conv;
18148 }
18149
18150 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
18151         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18152         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
18153         return ((int64_t)ret_conv);
18154 }
18155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18156         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
18157         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
18158         return ret_conv;
18159 }
18160
18161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18162         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
18163         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18164         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
18165         return ((int64_t)ret_conv);
18166 }
18167
18168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
18169         LDKSignature a_ref;
18170         CHECK((*env)->GetArrayLength(env, a) == 64);
18171         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
18172         LDKSignature b_ref;
18173         CHECK((*env)->GetArrayLength(env, b) == 64);
18174         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
18175         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18176         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
18177         return ((int64_t)ret_conv);
18178 }
18179
18180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18181         if ((_res & 1) != 0) return;
18182         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18183         CHECK_ACCESS(_res_ptr);
18184         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
18185         FREE((void*)_res);
18186         C2Tuple_SignatureSignatureZ_free(_res_conv);
18187 }
18188
18189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18190         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18191         CHECK_ACCESS(o_ptr);
18192         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
18193         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
18194         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18195         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
18196         return (int64_t)ret_conv;
18197 }
18198
18199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
18200         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18201         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
18202         return (int64_t)ret_conv;
18203 }
18204
18205 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18206         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
18207         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
18208         return ret_conv;
18209 }
18210
18211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18212         if ((_res & 1) != 0) return;
18213         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18214         CHECK_ACCESS(_res_ptr);
18215         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
18216         FREE((void*)_res);
18217         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
18218 }
18219
18220 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
18221         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18222         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
18223         return (int64_t)ret_conv;
18224 }
18225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18226         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
18227         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
18228         return ret_conv;
18229 }
18230
18231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18232         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
18233         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18234         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
18235         return (int64_t)ret_conv;
18236 }
18237
18238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18239         LDKSecretKey o_ref;
18240         CHECK((*env)->GetArrayLength(env, o) == 32);
18241         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
18242         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18243         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
18244         return (int64_t)ret_conv;
18245 }
18246
18247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
18248         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18249         *ret_conv = CResult_SecretKeyNoneZ_err();
18250         return (int64_t)ret_conv;
18251 }
18252
18253 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18254         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
18255         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
18256         return ret_conv;
18257 }
18258
18259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18260         if ((_res & 1) != 0) return;
18261         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18262         CHECK_ACCESS(_res_ptr);
18263         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
18264         FREE((void*)_res);
18265         CResult_SecretKeyNoneZ_free(_res_conv);
18266 }
18267
18268 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
18269         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18270         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
18271         return (int64_t)ret_conv;
18272 }
18273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18274         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
18275         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
18276         return ret_conv;
18277 }
18278
18279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18280         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
18281         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18282         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
18283         return (int64_t)ret_conv;
18284 }
18285
18286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18287         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18288         CHECK_ACCESS(o_ptr);
18289         LDKSign o_conv = *(LDKSign*)(o_ptr);
18290         if (o_conv.free == LDKSign_JCalls_free) {
18291                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18292                 LDKSign_JCalls_cloned(&o_conv);
18293         }
18294         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18295         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
18296         return (int64_t)ret_conv;
18297 }
18298
18299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18300         LDKDecodeError e_conv;
18301         e_conv.inner = (void*)(e & (~1));
18302         e_conv.is_owned = (e & 1) || (e == 0);
18303         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18304         e_conv = DecodeError_clone(&e_conv);
18305         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18306         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
18307         return (int64_t)ret_conv;
18308 }
18309
18310 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18311         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
18312         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
18313         return ret_conv;
18314 }
18315
18316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18317         if ((_res & 1) != 0) return;
18318         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18319         CHECK_ACCESS(_res_ptr);
18320         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
18321         FREE((void*)_res);
18322         CResult_SignDecodeErrorZ_free(_res_conv);
18323 }
18324
18325 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
18326         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18327         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
18328         return (int64_t)ret_conv;
18329 }
18330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18331         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
18332         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
18333         return ret_conv;
18334 }
18335
18336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18337         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
18338         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18339         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
18340         return (int64_t)ret_conv;
18341 }
18342
18343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18344         LDKCVec_u5Z _res_constr;
18345         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18346         if (_res_constr.datalen > 0)
18347                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
18348         else
18349                 _res_constr.data = NULL;
18350         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
18351         for (size_t h = 0; h < _res_constr.datalen; h++) {
18352                 int8_t _res_conv_7 = _res_vals[h];
18353                 
18354                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
18355         }
18356         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
18357         CVec_u5Z_free(_res_constr);
18358 }
18359
18360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18361         LDKRecoverableSignature o_ref;
18362         CHECK((*env)->GetArrayLength(env, o) == 68);
18363         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
18364         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
18365         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
18366         return (int64_t)ret_conv;
18367 }
18368
18369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
18370         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
18371         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
18372         return (int64_t)ret_conv;
18373 }
18374
18375 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18376         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
18377         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
18378         return ret_conv;
18379 }
18380
18381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18382         if ((_res & 1) != 0) return;
18383         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18384         CHECK_ACCESS(_res_ptr);
18385         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
18386         FREE((void*)_res);
18387         CResult_RecoverableSignatureNoneZ_free(_res_conv);
18388 }
18389
18390 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
18391         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
18392         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
18393         return (int64_t)ret_conv;
18394 }
18395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18396         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
18397         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
18398         return ret_conv;
18399 }
18400
18401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18402         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
18403         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
18404         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
18405         return (int64_t)ret_conv;
18406 }
18407
18408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
18409         LDKCVec_u8Z _res_ref;
18410         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
18411         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
18412         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
18413         CVec_u8Z_free(_res_ref);
18414 }
18415
18416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18417         LDKCVec_CVec_u8ZZ _res_constr;
18418         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18419         if (_res_constr.datalen > 0)
18420                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
18421         else
18422                 _res_constr.data = NULL;
18423         for (size_t i = 0; i < _res_constr.datalen; i++) {
18424                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
18425                 LDKCVec_u8Z _res_conv_8_ref;
18426                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
18427                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
18428                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
18429                 _res_constr.data[i] = _res_conv_8_ref;
18430         }
18431         CVec_CVec_u8ZZ_free(_res_constr);
18432 }
18433
18434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
18435         LDKCVec_CVec_u8ZZ o_constr;
18436         o_constr.datalen = (*env)->GetArrayLength(env, o);
18437         if (o_constr.datalen > 0)
18438                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
18439         else
18440                 o_constr.data = NULL;
18441         for (size_t i = 0; i < o_constr.datalen; i++) {
18442                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
18443                 LDKCVec_u8Z o_conv_8_ref;
18444                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
18445                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
18446                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
18447                 o_constr.data[i] = o_conv_8_ref;
18448         }
18449         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18450         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
18451         return (int64_t)ret_conv;
18452 }
18453
18454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
18455         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18456         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
18457         return (int64_t)ret_conv;
18458 }
18459
18460 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18461         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
18462         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
18463         return ret_conv;
18464 }
18465
18466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18467         if ((_res & 1) != 0) return;
18468         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18469         CHECK_ACCESS(_res_ptr);
18470         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
18471         FREE((void*)_res);
18472         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
18473 }
18474
18475 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
18476         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18477         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
18478         return (int64_t)ret_conv;
18479 }
18480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18481         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
18482         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
18483         return ret_conv;
18484 }
18485
18486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18487         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
18488         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18489         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
18490         return (int64_t)ret_conv;
18491 }
18492
18493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18494         LDKInMemorySigner o_conv;
18495         o_conv.inner = (void*)(o & (~1));
18496         o_conv.is_owned = (o & 1) || (o == 0);
18497         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18498         o_conv = InMemorySigner_clone(&o_conv);
18499         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
18500         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
18501         return (int64_t)ret_conv;
18502 }
18503
18504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18505         LDKDecodeError e_conv;
18506         e_conv.inner = (void*)(e & (~1));
18507         e_conv.is_owned = (e & 1) || (e == 0);
18508         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18509         e_conv = DecodeError_clone(&e_conv);
18510         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
18511         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
18512         return (int64_t)ret_conv;
18513 }
18514
18515 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18516         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
18517         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
18518         return ret_conv;
18519 }
18520
18521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18522         if ((_res & 1) != 0) return;
18523         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18524         CHECK_ACCESS(_res_ptr);
18525         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
18526         FREE((void*)_res);
18527         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
18528 }
18529
18530 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
18531         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
18532         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
18533         return (int64_t)ret_conv;
18534 }
18535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18536         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
18537         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
18538         return ret_conv;
18539 }
18540
18541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18542         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
18543         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
18544         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
18545         return (int64_t)ret_conv;
18546 }
18547
18548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18549         LDKCVec_TxOutZ _res_constr;
18550         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18551         if (_res_constr.datalen > 0)
18552                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
18553         else
18554                 _res_constr.data = NULL;
18555         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18556         for (size_t h = 0; h < _res_constr.datalen; h++) {
18557                 int64_t _res_conv_7 = _res_vals[h];
18558                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
18559                 CHECK_ACCESS(_res_conv_7_ptr);
18560                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
18561                 FREE((void*)_res_conv_7);
18562                 _res_constr.data[h] = _res_conv_7_conv;
18563         }
18564         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18565         CVec_TxOutZ_free(_res_constr);
18566 }
18567
18568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18569         LDKTransaction o_ref;
18570         o_ref.datalen = (*env)->GetArrayLength(env, o);
18571         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
18572         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
18573         o_ref.data_is_owned = true;
18574         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18575         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
18576         return (int64_t)ret_conv;
18577 }
18578
18579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
18580         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18581         *ret_conv = CResult_TransactionNoneZ_err();
18582         return (int64_t)ret_conv;
18583 }
18584
18585 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18586         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
18587         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
18588         return ret_conv;
18589 }
18590
18591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18592         if ((_res & 1) != 0) return;
18593         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18594         CHECK_ACCESS(_res_ptr);
18595         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
18596         FREE((void*)_res);
18597         CResult_TransactionNoneZ_free(_res_conv);
18598 }
18599
18600 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
18601         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18602         *ret_conv = CResult_TransactionNoneZ_clone(arg);
18603         return (int64_t)ret_conv;
18604 }
18605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18606         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
18607         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
18608         return ret_conv;
18609 }
18610
18611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18612         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
18613         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18614         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
18615         return (int64_t)ret_conv;
18616 }
18617
18618 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
18619         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18620         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
18621         return ((int64_t)ret_conv);
18622 }
18623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18624         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
18625         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
18626         return ret_conv;
18627 }
18628
18629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18630         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
18631         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18632         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
18633         return ((int64_t)ret_conv);
18634 }
18635
18636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
18637         LDKThirtyTwoBytes a_ref;
18638         CHECK((*env)->GetArrayLength(env, a) == 32);
18639         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18640         LDKChannelMonitor b_conv;
18641         b_conv.inner = (void*)(b & (~1));
18642         b_conv.is_owned = (b & 1) || (b == 0);
18643         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18644         b_conv = ChannelMonitor_clone(&b_conv);
18645         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18646         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
18647         return ((int64_t)ret_conv);
18648 }
18649
18650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18651         if ((_res & 1) != 0) return;
18652         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18653         CHECK_ACCESS(_res_ptr);
18654         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
18655         FREE((void*)_res);
18656         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
18657 }
18658
18659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18660         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _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(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
18664         else
18665                 _res_constr.data = NULL;
18666         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18667         for (size_t j = 0; j < _res_constr.datalen; j++) {
18668                 int64_t _res_conv_35 = _res_vals[j];
18669                 void* _res_conv_35_ptr = (void*)(((uintptr_t)_res_conv_35) & ~1);
18670                 CHECK_ACCESS(_res_conv_35_ptr);
18671                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
18672                 FREE((void*)_res_conv_35);
18673                 _res_constr.data[j] = _res_conv_35_conv;
18674         }
18675         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18676         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
18677 }
18678
18679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
18680         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
18681         o_constr.datalen = (*env)->GetArrayLength(env, o);
18682         if (o_constr.datalen > 0)
18683                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
18684         else
18685                 o_constr.data = NULL;
18686         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
18687         for (size_t j = 0; j < o_constr.datalen; j++) {
18688                 int64_t o_conv_35 = o_vals[j];
18689                 void* o_conv_35_ptr = (void*)(((uintptr_t)o_conv_35) & ~1);
18690                 CHECK_ACCESS(o_conv_35_ptr);
18691                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
18692                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o_conv_35) & ~1));
18693                 o_constr.data[j] = o_conv_35_conv;
18694         }
18695         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
18696         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18697         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
18698         return (int64_t)ret_conv;
18699 }
18700
18701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18702         LDKIOError e_conv = LDKIOError_from_java(env, e);
18703         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18704         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
18705         return (int64_t)ret_conv;
18706 }
18707
18708 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18709         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
18710         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
18711         return ret_conv;
18712 }
18713
18714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18715         if ((_res & 1) != 0) return;
18716         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18717         CHECK_ACCESS(_res_ptr);
18718         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
18719         FREE((void*)_res);
18720         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
18721 }
18722
18723 static inline uintptr_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
18724         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18725         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
18726         return (int64_t)ret_conv;
18727 }
18728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18729         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
18730         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
18731         return ret_conv;
18732 }
18733
18734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18735         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
18736         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18737         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
18738         return (int64_t)ret_conv;
18739 }
18740
18741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
18742         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
18743         *ret_copy = COption_u16Z_some(o);
18744         int64_t ret_ref = (uintptr_t)ret_copy;
18745         return ret_ref;
18746 }
18747
18748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
18749         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
18750         *ret_copy = COption_u16Z_none();
18751         int64_t ret_ref = (uintptr_t)ret_copy;
18752         return ret_ref;
18753 }
18754
18755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18756         if ((_res & 1) != 0) return;
18757         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18758         CHECK_ACCESS(_res_ptr);
18759         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
18760         FREE((void*)_res);
18761         COption_u16Z_free(_res_conv);
18762 }
18763
18764 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
18765         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
18766         *ret_copy = COption_u16Z_clone(arg);
18767 int64_t ret_ref = (uintptr_t)ret_copy;
18768         return ret_ref;
18769 }
18770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18771         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
18772         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
18773         return ret_conv;
18774 }
18775
18776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18777         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
18778         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
18779         *ret_copy = COption_u16Z_clone(orig_conv);
18780         int64_t ret_ref = (uintptr_t)ret_copy;
18781         return ret_ref;
18782 }
18783
18784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
18785         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18786         *ret_conv = CResult_NoneAPIErrorZ_ok();
18787         return (int64_t)ret_conv;
18788 }
18789
18790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18791         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18792         CHECK_ACCESS(e_ptr);
18793         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18794         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
18795         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18796         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
18797         return (int64_t)ret_conv;
18798 }
18799
18800 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18801         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
18802         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
18803         return ret_conv;
18804 }
18805
18806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18807         if ((_res & 1) != 0) return;
18808         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18809         CHECK_ACCESS(_res_ptr);
18810         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
18811         FREE((void*)_res);
18812         CResult_NoneAPIErrorZ_free(_res_conv);
18813 }
18814
18815 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
18816         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18817         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
18818         return (int64_t)ret_conv;
18819 }
18820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18821         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
18822         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
18823         return ret_conv;
18824 }
18825
18826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18827         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
18828         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18829         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
18830         return (int64_t)ret_conv;
18831 }
18832
18833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18834         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
18835         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18836         if (_res_constr.datalen > 0)
18837                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
18838         else
18839                 _res_constr.data = NULL;
18840         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18841         for (size_t w = 0; w < _res_constr.datalen; w++) {
18842                 int64_t _res_conv_22 = _res_vals[w];
18843                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
18844                 CHECK_ACCESS(_res_conv_22_ptr);
18845                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
18846                 FREE((void*)_res_conv_22);
18847                 _res_constr.data[w] = _res_conv_22_conv;
18848         }
18849         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18850         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
18851 }
18852
18853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18854         LDKCVec_APIErrorZ _res_constr;
18855         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18856         if (_res_constr.datalen > 0)
18857                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
18858         else
18859                 _res_constr.data = NULL;
18860         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18861         for (size_t k = 0; k < _res_constr.datalen; k++) {
18862                 int64_t _res_conv_10 = _res_vals[k];
18863                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
18864                 CHECK_ACCESS(_res_conv_10_ptr);
18865                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
18866                 FREE((void*)_res_conv_10);
18867                 _res_constr.data[k] = _res_conv_10_conv;
18868         }
18869         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18870         CVec_APIErrorZ_free(_res_constr);
18871 }
18872
18873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18874         LDKThirtyTwoBytes o_ref;
18875         CHECK((*env)->GetArrayLength(env, o) == 32);
18876         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18877         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
18878         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
18879         return (int64_t)ret_conv;
18880 }
18881
18882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18883         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18884         CHECK_ACCESS(e_ptr);
18885         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18886         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
18887         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
18888         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
18889         return (int64_t)ret_conv;
18890 }
18891
18892 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18893         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
18894         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
18895         return ret_conv;
18896 }
18897
18898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18899         if ((_res & 1) != 0) return;
18900         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18901         CHECK_ACCESS(_res_ptr);
18902         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
18903         FREE((void*)_res);
18904         CResult__u832APIErrorZ_free(_res_conv);
18905 }
18906
18907 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
18908         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
18909         *ret_conv = CResult__u832APIErrorZ_clone(arg);
18910         return (int64_t)ret_conv;
18911 }
18912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18913         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
18914         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
18915         return ret_conv;
18916 }
18917
18918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18919         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
18920         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
18921         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
18922         return (int64_t)ret_conv;
18923 }
18924
18925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18926         LDKThirtyTwoBytes o_ref;
18927         CHECK((*env)->GetArrayLength(env, o) == 32);
18928         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18929         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
18930         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
18931         return (int64_t)ret_conv;
18932 }
18933
18934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18935         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18936         CHECK_ACCESS(e_ptr);
18937         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
18938         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
18939         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
18940         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
18941         return (int64_t)ret_conv;
18942 }
18943
18944 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18945         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
18946         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
18947         return ret_conv;
18948 }
18949
18950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18951         if ((_res & 1) != 0) return;
18952         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18953         CHECK_ACCESS(_res_ptr);
18954         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
18955         FREE((void*)_res);
18956         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
18957 }
18958
18959 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
18960         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
18961         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
18962         return (int64_t)ret_conv;
18963 }
18964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18965         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
18966         int64_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
18967         return ret_conv;
18968 }
18969
18970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18971         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
18972         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
18973         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
18974         return (int64_t)ret_conv;
18975 }
18976
18977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
18978         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
18979         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
18980         return (int64_t)ret_conv;
18981 }
18982
18983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18984         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18985         CHECK_ACCESS(e_ptr);
18986         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
18987         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
18988         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
18989         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
18990         return (int64_t)ret_conv;
18991 }
18992
18993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18994         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
18995         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
18996         return ret_conv;
18997 }
18998
18999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19000         if ((_res & 1) != 0) return;
19001         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19002         CHECK_ACCESS(_res_ptr);
19003         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
19004         FREE((void*)_res);
19005         CResult_NonePaymentSendFailureZ_free(_res_conv);
19006 }
19007
19008 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
19009         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19010         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
19011         return (int64_t)ret_conv;
19012 }
19013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19014         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
19015         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
19016         return ret_conv;
19017 }
19018
19019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19020         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
19021         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19022         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
19023         return (int64_t)ret_conv;
19024 }
19025
19026 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
19027         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19028         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
19029         return ((int64_t)ret_conv);
19030 }
19031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19032         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
19033         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
19034         return ret_conv;
19035 }
19036
19037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19038         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
19039         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19040         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
19041         return ((int64_t)ret_conv);
19042 }
19043
19044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19045         LDKThirtyTwoBytes a_ref;
19046         CHECK((*env)->GetArrayLength(env, a) == 32);
19047         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19048         LDKThirtyTwoBytes b_ref;
19049         CHECK((*env)->GetArrayLength(env, b) == 32);
19050         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19051         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19052         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
19053         return ((int64_t)ret_conv);
19054 }
19055
19056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19057         if ((_res & 1) != 0) return;
19058         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19059         CHECK_ACCESS(_res_ptr);
19060         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
19061         FREE((void*)_res);
19062         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
19063 }
19064
19065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19066         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19067         CHECK_ACCESS(o_ptr);
19068         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
19069         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
19070         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19071         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
19072         return (int64_t)ret_conv;
19073 }
19074
19075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19076         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19077         CHECK_ACCESS(e_ptr);
19078         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19079         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19080         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19081         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
19082         return (int64_t)ret_conv;
19083 }
19084
19085 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19086         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
19087         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
19088         return ret_conv;
19089 }
19090
19091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19092         if ((_res & 1) != 0) return;
19093         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19094         CHECK_ACCESS(_res_ptr);
19095         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
19096         FREE((void*)_res);
19097         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
19098 }
19099
19100 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
19101         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19102         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
19103         return (int64_t)ret_conv;
19104 }
19105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19106         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
19107         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
19108         return ret_conv;
19109 }
19110
19111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19112         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
19113         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19114         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
19115         return (int64_t)ret_conv;
19116 }
19117
19118 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
19119         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19120         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
19121         return ((int64_t)ret_conv);
19122 }
19123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19124         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
19125         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
19126         return ret_conv;
19127 }
19128
19129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19130         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
19131         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19132         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
19133         return ((int64_t)ret_conv);
19134 }
19135
19136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19137         LDKThirtyTwoBytes a_ref;
19138         CHECK((*env)->GetArrayLength(env, a) == 32);
19139         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19140         LDKThirtyTwoBytes b_ref;
19141         CHECK((*env)->GetArrayLength(env, b) == 32);
19142         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19143         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19144         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
19145         return ((int64_t)ret_conv);
19146 }
19147
19148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19149         if ((_res & 1) != 0) return;
19150         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19151         CHECK_ACCESS(_res_ptr);
19152         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
19153         FREE((void*)_res);
19154         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
19155 }
19156
19157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19158         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19159         CHECK_ACCESS(o_ptr);
19160         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
19161         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
19162         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19163         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
19164         return (int64_t)ret_conv;
19165 }
19166
19167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
19168         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19169         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
19170         return (int64_t)ret_conv;
19171 }
19172
19173 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19174         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
19175         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
19176         return ret_conv;
19177 }
19178
19179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19180         if ((_res & 1) != 0) return;
19181         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19182         CHECK_ACCESS(_res_ptr);
19183         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
19184         FREE((void*)_res);
19185         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
19186 }
19187
19188 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
19189         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19190         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
19191         return (int64_t)ret_conv;
19192 }
19193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19194         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
19195         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
19196         return ret_conv;
19197 }
19198
19199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19200         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
19201         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19202         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
19203         return (int64_t)ret_conv;
19204 }
19205
19206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19207         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19208         CHECK_ACCESS(o_ptr);
19209         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
19210         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
19211         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19212         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
19213         return (int64_t)ret_conv;
19214 }
19215
19216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19217         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19218         CHECK_ACCESS(e_ptr);
19219         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19220         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19221         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19222         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
19223         return (int64_t)ret_conv;
19224 }
19225
19226 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19227         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
19228         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
19229         return ret_conv;
19230 }
19231
19232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19233         if ((_res & 1) != 0) return;
19234         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19235         CHECK_ACCESS(_res_ptr);
19236         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
19237         FREE((void*)_res);
19238         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
19239 }
19240
19241 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
19242         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19243         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
19244         return (int64_t)ret_conv;
19245 }
19246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19247         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
19248         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
19249         return ret_conv;
19250 }
19251
19252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19253         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
19254         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19255         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
19256         return (int64_t)ret_conv;
19257 }
19258
19259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19260         LDKThirtyTwoBytes o_ref;
19261         CHECK((*env)->GetArrayLength(env, o) == 32);
19262         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19263         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19264         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
19265         return (int64_t)ret_conv;
19266 }
19267
19268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
19269         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19270         *ret_conv = CResult_PaymentSecretNoneZ_err();
19271         return (int64_t)ret_conv;
19272 }
19273
19274 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19275         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
19276         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
19277         return ret_conv;
19278 }
19279
19280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19281         if ((_res & 1) != 0) return;
19282         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19283         CHECK_ACCESS(_res_ptr);
19284         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
19285         FREE((void*)_res);
19286         CResult_PaymentSecretNoneZ_free(_res_conv);
19287 }
19288
19289 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
19290         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19291         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
19292         return (int64_t)ret_conv;
19293 }
19294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19295         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
19296         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
19297         return ret_conv;
19298 }
19299
19300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19301         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
19302         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19303         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
19304         return (int64_t)ret_conv;
19305 }
19306
19307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19308         LDKThirtyTwoBytes o_ref;
19309         CHECK((*env)->GetArrayLength(env, o) == 32);
19310         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19311         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19312         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
19313         return (int64_t)ret_conv;
19314 }
19315
19316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19317         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19318         CHECK_ACCESS(e_ptr);
19319         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19320         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19321         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19322         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
19323         return (int64_t)ret_conv;
19324 }
19325
19326 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19327         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
19328         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
19329         return ret_conv;
19330 }
19331
19332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19333         if ((_res & 1) != 0) return;
19334         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19335         CHECK_ACCESS(_res_ptr);
19336         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
19337         FREE((void*)_res);
19338         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
19339 }
19340
19341 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
19342         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19343         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
19344         return (int64_t)ret_conv;
19345 }
19346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19347         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
19348         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
19349         return ret_conv;
19350 }
19351
19352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19353         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
19354         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19355         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
19356         return (int64_t)ret_conv;
19357 }
19358
19359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19360         LDKThirtyTwoBytes o_ref;
19361         CHECK((*env)->GetArrayLength(env, o) == 32);
19362         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19363         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
19364         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
19365         return (int64_t)ret_conv;
19366 }
19367
19368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19369         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19370         CHECK_ACCESS(e_ptr);
19371         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19372         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19373         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
19374         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
19375         return (int64_t)ret_conv;
19376 }
19377
19378 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19379         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
19380         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
19381         return ret_conv;
19382 }
19383
19384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19385         if ((_res & 1) != 0) return;
19386         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19387         CHECK_ACCESS(_res_ptr);
19388         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
19389         FREE((void*)_res);
19390         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
19391 }
19392
19393 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
19394         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
19395         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
19396         return (int64_t)ret_conv;
19397 }
19398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19399         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
19400         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
19401         return ret_conv;
19402 }
19403
19404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19405         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
19406         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
19407         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
19408         return (int64_t)ret_conv;
19409 }
19410
19411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19412         LDKCounterpartyForwardingInfo o_conv;
19413         o_conv.inner = (void*)(o & (~1));
19414         o_conv.is_owned = (o & 1) || (o == 0);
19415         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19416         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
19417         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
19418         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
19419         return (int64_t)ret_conv;
19420 }
19421
19422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19423         LDKDecodeError e_conv;
19424         e_conv.inner = (void*)(e & (~1));
19425         e_conv.is_owned = (e & 1) || (e == 0);
19426         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19427         e_conv = DecodeError_clone(&e_conv);
19428         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
19429         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
19430         return (int64_t)ret_conv;
19431 }
19432
19433 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19434         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
19435         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
19436         return ret_conv;
19437 }
19438
19439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19440         if ((_res & 1) != 0) return;
19441         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19442         CHECK_ACCESS(_res_ptr);
19443         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
19444         FREE((void*)_res);
19445         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
19446 }
19447
19448 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
19449         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
19450         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
19451         return (int64_t)ret_conv;
19452 }
19453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19454         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
19455         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
19456         return ret_conv;
19457 }
19458
19459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19460         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
19461         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
19462         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
19463         return (int64_t)ret_conv;
19464 }
19465
19466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19467         LDKChannelCounterparty o_conv;
19468         o_conv.inner = (void*)(o & (~1));
19469         o_conv.is_owned = (o & 1) || (o == 0);
19470         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19471         o_conv = ChannelCounterparty_clone(&o_conv);
19472         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
19473         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
19474         return (int64_t)ret_conv;
19475 }
19476
19477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19478         LDKDecodeError e_conv;
19479         e_conv.inner = (void*)(e & (~1));
19480         e_conv.is_owned = (e & 1) || (e == 0);
19481         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19482         e_conv = DecodeError_clone(&e_conv);
19483         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
19484         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
19485         return (int64_t)ret_conv;
19486 }
19487
19488 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19489         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
19490         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
19491         return ret_conv;
19492 }
19493
19494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19495         if ((_res & 1) != 0) return;
19496         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19497         CHECK_ACCESS(_res_ptr);
19498         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
19499         FREE((void*)_res);
19500         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
19501 }
19502
19503 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
19504         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
19505         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
19506         return (int64_t)ret_conv;
19507 }
19508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19509         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
19510         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
19511         return ret_conv;
19512 }
19513
19514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19515         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
19516         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
19517         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
19518         return (int64_t)ret_conv;
19519 }
19520
19521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19522         LDKChannelDetails o_conv;
19523         o_conv.inner = (void*)(o & (~1));
19524         o_conv.is_owned = (o & 1) || (o == 0);
19525         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19526         o_conv = ChannelDetails_clone(&o_conv);
19527         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
19528         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
19529         return (int64_t)ret_conv;
19530 }
19531
19532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19533         LDKDecodeError e_conv;
19534         e_conv.inner = (void*)(e & (~1));
19535         e_conv.is_owned = (e & 1) || (e == 0);
19536         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19537         e_conv = DecodeError_clone(&e_conv);
19538         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
19539         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
19540         return (int64_t)ret_conv;
19541 }
19542
19543 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19544         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
19545         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
19546         return ret_conv;
19547 }
19548
19549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19550         if ((_res & 1) != 0) return;
19551         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19552         CHECK_ACCESS(_res_ptr);
19553         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
19554         FREE((void*)_res);
19555         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
19556 }
19557
19558 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
19559         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
19560         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
19561         return (int64_t)ret_conv;
19562 }
19563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19564         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
19565         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
19566         return ret_conv;
19567 }
19568
19569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19570         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
19571         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
19572         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
19573         return (int64_t)ret_conv;
19574 }
19575
19576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19577         LDKPhantomRouteHints o_conv;
19578         o_conv.inner = (void*)(o & (~1));
19579         o_conv.is_owned = (o & 1) || (o == 0);
19580         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19581         o_conv = PhantomRouteHints_clone(&o_conv);
19582         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19583         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
19584         return (int64_t)ret_conv;
19585 }
19586
19587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19588         LDKDecodeError e_conv;
19589         e_conv.inner = (void*)(e & (~1));
19590         e_conv.is_owned = (e & 1) || (e == 0);
19591         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19592         e_conv = DecodeError_clone(&e_conv);
19593         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19594         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
19595         return (int64_t)ret_conv;
19596 }
19597
19598 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19599         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
19600         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
19601         return ret_conv;
19602 }
19603
19604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19605         if ((_res & 1) != 0) return;
19606         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19607         CHECK_ACCESS(_res_ptr);
19608         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
19609         FREE((void*)_res);
19610         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
19611 }
19612
19613 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
19614         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19615         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
19616         return (int64_t)ret_conv;
19617 }
19618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19619         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
19620         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
19621         return ret_conv;
19622 }
19623
19624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19625         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
19626         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19627         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
19628         return (int64_t)ret_conv;
19629 }
19630
19631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19632         LDKCVec_ChannelMonitorZ _res_constr;
19633         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19634         if (_res_constr.datalen > 0)
19635                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
19636         else
19637                 _res_constr.data = NULL;
19638         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19639         for (size_t q = 0; q < _res_constr.datalen; q++) {
19640                 int64_t _res_conv_16 = _res_vals[q];
19641                 LDKChannelMonitor _res_conv_16_conv;
19642                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
19643                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
19644                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
19645                 _res_constr.data[q] = _res_conv_16_conv;
19646         }
19647         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19648         CVec_ChannelMonitorZ_free(_res_constr);
19649 }
19650
19651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
19652         LDKThirtyTwoBytes a_ref;
19653         CHECK((*env)->GetArrayLength(env, a) == 32);
19654         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19655         LDKChannelManager b_conv;
19656         b_conv.inner = (void*)(b & (~1));
19657         b_conv.is_owned = (b & 1) || (b == 0);
19658         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19659         // WARNING: we need a move here but no clone is available for LDKChannelManager
19660         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
19661         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
19662         return ((int64_t)ret_conv);
19663 }
19664
19665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19666         if ((_res & 1) != 0) return;
19667         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19668         CHECK_ACCESS(_res_ptr);
19669         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
19670         FREE((void*)_res);
19671         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
19672 }
19673
19674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19675         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19676         CHECK_ACCESS(o_ptr);
19677         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
19678         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
19679         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
19680         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
19681         return (int64_t)ret_conv;
19682 }
19683
19684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19685         LDKDecodeError e_conv;
19686         e_conv.inner = (void*)(e & (~1));
19687         e_conv.is_owned = (e & 1) || (e == 0);
19688         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19689         e_conv = DecodeError_clone(&e_conv);
19690         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
19691         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
19692         return (int64_t)ret_conv;
19693 }
19694
19695 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19696         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
19697         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
19698         return ret_conv;
19699 }
19700
19701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19702         if ((_res & 1) != 0) return;
19703         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19704         CHECK_ACCESS(_res_ptr);
19705         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
19706         FREE((void*)_res);
19707         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
19708 }
19709
19710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19711         LDKChannelConfig o_conv;
19712         o_conv.inner = (void*)(o & (~1));
19713         o_conv.is_owned = (o & 1) || (o == 0);
19714         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19715         o_conv = ChannelConfig_clone(&o_conv);
19716         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
19717         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
19718         return (int64_t)ret_conv;
19719 }
19720
19721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19722         LDKDecodeError e_conv;
19723         e_conv.inner = (void*)(e & (~1));
19724         e_conv.is_owned = (e & 1) || (e == 0);
19725         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19726         e_conv = DecodeError_clone(&e_conv);
19727         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
19728         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
19729         return (int64_t)ret_conv;
19730 }
19731
19732 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19733         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
19734         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
19735         return ret_conv;
19736 }
19737
19738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19739         if ((_res & 1) != 0) return;
19740         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19741         CHECK_ACCESS(_res_ptr);
19742         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
19743         FREE((void*)_res);
19744         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
19745 }
19746
19747 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
19748         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
19749         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
19750         return (int64_t)ret_conv;
19751 }
19752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19753         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
19754         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
19755         return ret_conv;
19756 }
19757
19758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19759         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
19760         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
19761         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
19762         return (int64_t)ret_conv;
19763 }
19764
19765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19766         LDKOutPoint o_conv;
19767         o_conv.inner = (void*)(o & (~1));
19768         o_conv.is_owned = (o & 1) || (o == 0);
19769         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19770         o_conv = OutPoint_clone(&o_conv);
19771         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19772         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
19773         return (int64_t)ret_conv;
19774 }
19775
19776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19777         LDKDecodeError e_conv;
19778         e_conv.inner = (void*)(e & (~1));
19779         e_conv.is_owned = (e & 1) || (e == 0);
19780         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19781         e_conv = DecodeError_clone(&e_conv);
19782         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19783         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
19784         return (int64_t)ret_conv;
19785 }
19786
19787 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19788         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
19789         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
19790         return ret_conv;
19791 }
19792
19793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19794         if ((_res & 1) != 0) return;
19795         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19796         CHECK_ACCESS(_res_ptr);
19797         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
19798         FREE((void*)_res);
19799         CResult_OutPointDecodeErrorZ_free(_res_conv);
19800 }
19801
19802 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
19803         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19804         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
19805         return (int64_t)ret_conv;
19806 }
19807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19808         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
19809         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
19810         return ret_conv;
19811 }
19812
19813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19814         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
19815         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19816         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
19817         return (int64_t)ret_conv;
19818 }
19819
19820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19821         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19822         CHECK_ACCESS(o_ptr);
19823         LDKType o_conv = *(LDKType*)(o_ptr);
19824         if (o_conv.free == LDKType_JCalls_free) {
19825                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19826                 LDKType_JCalls_cloned(&o_conv);
19827         }
19828         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
19829         *ret_copy = COption_TypeZ_some(o_conv);
19830         int64_t ret_ref = (uintptr_t)ret_copy;
19831         return ret_ref;
19832 }
19833
19834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
19835         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
19836         *ret_copy = COption_TypeZ_none();
19837         int64_t ret_ref = (uintptr_t)ret_copy;
19838         return ret_ref;
19839 }
19840
19841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19842         if ((_res & 1) != 0) return;
19843         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19844         CHECK_ACCESS(_res_ptr);
19845         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
19846         FREE((void*)_res);
19847         COption_TypeZ_free(_res_conv);
19848 }
19849
19850 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
19851         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
19852         *ret_copy = COption_TypeZ_clone(arg);
19853 int64_t ret_ref = (uintptr_t)ret_copy;
19854         return ret_ref;
19855 }
19856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19857         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
19858         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
19859         return ret_conv;
19860 }
19861
19862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19863         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
19864         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
19865         *ret_copy = COption_TypeZ_clone(orig_conv);
19866         int64_t ret_ref = (uintptr_t)ret_copy;
19867         return ret_ref;
19868 }
19869
19870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19871         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19872         CHECK_ACCESS(o_ptr);
19873         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
19874         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
19875         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
19876         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
19877         return (int64_t)ret_conv;
19878 }
19879
19880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19881         LDKDecodeError e_conv;
19882         e_conv.inner = (void*)(e & (~1));
19883         e_conv.is_owned = (e & 1) || (e == 0);
19884         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19885         e_conv = DecodeError_clone(&e_conv);
19886         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
19887         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
19888         return (int64_t)ret_conv;
19889 }
19890
19891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19892         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
19893         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
19894         return ret_conv;
19895 }
19896
19897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19898         if ((_res & 1) != 0) return;
19899         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19900         CHECK_ACCESS(_res_ptr);
19901         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
19902         FREE((void*)_res);
19903         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
19904 }
19905
19906 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
19907         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
19908         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
19909         return (int64_t)ret_conv;
19910 }
19911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19912         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
19913         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
19914         return ret_conv;
19915 }
19916
19917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19918         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
19919         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
19920         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
19921         return (int64_t)ret_conv;
19922 }
19923
19924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19925         LDKThirtyTwoBytes o_ref;
19926         CHECK((*env)->GetArrayLength(env, o) == 32);
19927         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19928         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
19929         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
19930         return (int64_t)ret_conv;
19931 }
19932
19933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19934         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19935         CHECK_ACCESS(e_ptr);
19936         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
19937         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
19938         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
19939         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
19940         return (int64_t)ret_conv;
19941 }
19942
19943 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19944         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
19945         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
19946         return ret_conv;
19947 }
19948
19949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19950         if ((_res & 1) != 0) return;
19951         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19952         CHECK_ACCESS(_res_ptr);
19953         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
19954         FREE((void*)_res);
19955         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
19956 }
19957
19958 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
19959         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
19960         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
19961         return (int64_t)ret_conv;
19962 }
19963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19964         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
19965         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
19966         return ret_conv;
19967 }
19968
19969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19970         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
19971         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
19972         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
19973         return (int64_t)ret_conv;
19974 }
19975
19976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
19977         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
19978         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
19979         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
19980         return (int64_t)ret_conv;
19981 }
19982
19983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19984         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19985         CHECK_ACCESS(e_ptr);
19986         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
19987         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
19988         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
19989         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
19990         return (int64_t)ret_conv;
19991 }
19992
19993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19994         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
19995         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
19996         return ret_conv;
19997 }
19998
19999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20000         if ((_res & 1) != 0) return;
20001         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20002         CHECK_ACCESS(_res_ptr);
20003         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
20004         FREE((void*)_res);
20005         CResult_SiPrefixParseErrorZ_free(_res_conv);
20006 }
20007
20008 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
20009         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20010         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
20011         return (int64_t)ret_conv;
20012 }
20013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20014         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
20015         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
20016         return ret_conv;
20017 }
20018
20019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20020         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
20021         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20022         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
20023         return (int64_t)ret_conv;
20024 }
20025
20026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20027         LDKInvoice o_conv;
20028         o_conv.inner = (void*)(o & (~1));
20029         o_conv.is_owned = (o & 1) || (o == 0);
20030         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20031         o_conv = Invoice_clone(&o_conv);
20032         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20033         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
20034         return (int64_t)ret_conv;
20035 }
20036
20037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20038         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20039         CHECK_ACCESS(e_ptr);
20040         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
20041         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
20042         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20043         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
20044         return (int64_t)ret_conv;
20045 }
20046
20047 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20048         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
20049         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
20050         return ret_conv;
20051 }
20052
20053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20054         if ((_res & 1) != 0) return;
20055         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20056         CHECK_ACCESS(_res_ptr);
20057         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
20058         FREE((void*)_res);
20059         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
20060 }
20061
20062 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
20063         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20064         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
20065         return (int64_t)ret_conv;
20066 }
20067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20068         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
20069         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
20070         return ret_conv;
20071 }
20072
20073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20074         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
20075         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20076         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
20077         return (int64_t)ret_conv;
20078 }
20079
20080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20081         LDKSignedRawInvoice o_conv;
20082         o_conv.inner = (void*)(o & (~1));
20083         o_conv.is_owned = (o & 1) || (o == 0);
20084         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20085         o_conv = SignedRawInvoice_clone(&o_conv);
20086         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20087         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
20088         return (int64_t)ret_conv;
20089 }
20090
20091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20092         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20093         CHECK_ACCESS(e_ptr);
20094         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
20095         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
20096         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20097         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
20098         return (int64_t)ret_conv;
20099 }
20100
20101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20102         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
20103         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
20104         return ret_conv;
20105 }
20106
20107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20108         if ((_res & 1) != 0) return;
20109         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20110         CHECK_ACCESS(_res_ptr);
20111         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
20112         FREE((void*)_res);
20113         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
20114 }
20115
20116 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
20117         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20118         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
20119         return (int64_t)ret_conv;
20120 }
20121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20122         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
20123         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
20124         return ret_conv;
20125 }
20126
20127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20128         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
20129         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20130         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
20131         return (int64_t)ret_conv;
20132 }
20133
20134 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
20135         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20136         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
20137         return ((int64_t)ret_conv);
20138 }
20139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20140         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
20141         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
20142         return ret_conv;
20143 }
20144
20145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20146         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
20147         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20148         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
20149         return ((int64_t)ret_conv);
20150 }
20151
20152 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) {
20153         LDKRawInvoice a_conv;
20154         a_conv.inner = (void*)(a & (~1));
20155         a_conv.is_owned = (a & 1) || (a == 0);
20156         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20157         a_conv = RawInvoice_clone(&a_conv);
20158         LDKThirtyTwoBytes b_ref;
20159         CHECK((*env)->GetArrayLength(env, b) == 32);
20160         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
20161         LDKInvoiceSignature c_conv;
20162         c_conv.inner = (void*)(c & (~1));
20163         c_conv.is_owned = (c & 1) || (c == 0);
20164         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
20165         c_conv = InvoiceSignature_clone(&c_conv);
20166         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20167         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
20168         return ((int64_t)ret_conv);
20169 }
20170
20171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20172         if ((_res & 1) != 0) return;
20173         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20174         CHECK_ACCESS(_res_ptr);
20175         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
20176         FREE((void*)_res);
20177         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
20178 }
20179
20180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20181         LDKPayeePubKey o_conv;
20182         o_conv.inner = (void*)(o & (~1));
20183         o_conv.is_owned = (o & 1) || (o == 0);
20184         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20185         o_conv = PayeePubKey_clone(&o_conv);
20186         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20187         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
20188         return (int64_t)ret_conv;
20189 }
20190
20191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20192         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
20193         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20194         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
20195         return (int64_t)ret_conv;
20196 }
20197
20198 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20199         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
20200         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
20201         return ret_conv;
20202 }
20203
20204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20205         if ((_res & 1) != 0) return;
20206         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20207         CHECK_ACCESS(_res_ptr);
20208         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
20209         FREE((void*)_res);
20210         CResult_PayeePubKeyErrorZ_free(_res_conv);
20211 }
20212
20213 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
20214         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20215         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
20216         return (int64_t)ret_conv;
20217 }
20218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20219         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
20220         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
20221         return ret_conv;
20222 }
20223
20224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20225         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
20226         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20227         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
20228         return (int64_t)ret_conv;
20229 }
20230
20231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20232         LDKCVec_PrivateRouteZ _res_constr;
20233         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20234         if (_res_constr.datalen > 0)
20235                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
20236         else
20237                 _res_constr.data = NULL;
20238         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20239         for (size_t o = 0; o < _res_constr.datalen; o++) {
20240                 int64_t _res_conv_14 = _res_vals[o];
20241                 LDKPrivateRoute _res_conv_14_conv;
20242                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
20243                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
20244                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
20245                 _res_constr.data[o] = _res_conv_14_conv;
20246         }
20247         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20248         CVec_PrivateRouteZ_free(_res_constr);
20249 }
20250
20251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20252         LDKPositiveTimestamp o_conv;
20253         o_conv.inner = (void*)(o & (~1));
20254         o_conv.is_owned = (o & 1) || (o == 0);
20255         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20256         o_conv = PositiveTimestamp_clone(&o_conv);
20257         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20258         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
20259         return (int64_t)ret_conv;
20260 }
20261
20262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20263         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
20264         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20265         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
20266         return (int64_t)ret_conv;
20267 }
20268
20269 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20270         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
20271         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
20272         return ret_conv;
20273 }
20274
20275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20276         if ((_res & 1) != 0) return;
20277         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20278         CHECK_ACCESS(_res_ptr);
20279         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
20280         FREE((void*)_res);
20281         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
20282 }
20283
20284 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
20285         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20286         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
20287         return (int64_t)ret_conv;
20288 }
20289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20290         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
20291         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
20292         return ret_conv;
20293 }
20294
20295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20296         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
20297         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20298         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
20299         return (int64_t)ret_conv;
20300 }
20301
20302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
20303         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
20304         *ret_conv = CResult_NoneSemanticErrorZ_ok();
20305         return (int64_t)ret_conv;
20306 }
20307
20308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20309         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
20310         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
20311         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
20312         return (int64_t)ret_conv;
20313 }
20314
20315 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20316         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
20317         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
20318         return ret_conv;
20319 }
20320
20321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20322         if ((_res & 1) != 0) return;
20323         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20324         CHECK_ACCESS(_res_ptr);
20325         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
20326         FREE((void*)_res);
20327         CResult_NoneSemanticErrorZ_free(_res_conv);
20328 }
20329
20330 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
20331         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
20332         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
20333         return (int64_t)ret_conv;
20334 }
20335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20336         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
20337         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
20338         return ret_conv;
20339 }
20340
20341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20342         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
20343         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
20344         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
20345         return (int64_t)ret_conv;
20346 }
20347
20348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20349         LDKInvoice o_conv;
20350         o_conv.inner = (void*)(o & (~1));
20351         o_conv.is_owned = (o & 1) || (o == 0);
20352         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20353         o_conv = Invoice_clone(&o_conv);
20354         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
20355         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
20356         return (int64_t)ret_conv;
20357 }
20358
20359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20360         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
20361         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
20362         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
20363         return (int64_t)ret_conv;
20364 }
20365
20366 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20367         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
20368         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
20369         return ret_conv;
20370 }
20371
20372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20373         if ((_res & 1) != 0) return;
20374         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20375         CHECK_ACCESS(_res_ptr);
20376         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
20377         FREE((void*)_res);
20378         CResult_InvoiceSemanticErrorZ_free(_res_conv);
20379 }
20380
20381 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
20382         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
20383         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
20384         return (int64_t)ret_conv;
20385 }
20386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20387         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
20388         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
20389         return ret_conv;
20390 }
20391
20392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20393         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
20394         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
20395         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
20396         return (int64_t)ret_conv;
20397 }
20398
20399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20400         LDKDescription o_conv;
20401         o_conv.inner = (void*)(o & (~1));
20402         o_conv.is_owned = (o & 1) || (o == 0);
20403         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20404         o_conv = Description_clone(&o_conv);
20405         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
20406         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
20407         return (int64_t)ret_conv;
20408 }
20409
20410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20411         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
20412         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
20413         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
20414         return (int64_t)ret_conv;
20415 }
20416
20417 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20418         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
20419         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
20420         return ret_conv;
20421 }
20422
20423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20424         if ((_res & 1) != 0) return;
20425         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20426         CHECK_ACCESS(_res_ptr);
20427         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
20428         FREE((void*)_res);
20429         CResult_DescriptionCreationErrorZ_free(_res_conv);
20430 }
20431
20432 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
20433         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
20434         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
20435         return (int64_t)ret_conv;
20436 }
20437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20438         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
20439         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
20440         return ret_conv;
20441 }
20442
20443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20444         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
20445         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
20446         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
20447         return (int64_t)ret_conv;
20448 }
20449
20450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20451         LDKPrivateRoute o_conv;
20452         o_conv.inner = (void*)(o & (~1));
20453         o_conv.is_owned = (o & 1) || (o == 0);
20454         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20455         o_conv = PrivateRoute_clone(&o_conv);
20456         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
20457         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
20458         return (int64_t)ret_conv;
20459 }
20460
20461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20462         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
20463         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
20464         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
20465         return (int64_t)ret_conv;
20466 }
20467
20468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20469         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
20470         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
20471         return ret_conv;
20472 }
20473
20474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20475         if ((_res & 1) != 0) return;
20476         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20477         CHECK_ACCESS(_res_ptr);
20478         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
20479         FREE((void*)_res);
20480         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
20481 }
20482
20483 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
20484         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
20485         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
20486         return (int64_t)ret_conv;
20487 }
20488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20489         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
20490         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
20491         return ret_conv;
20492 }
20493
20494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20495         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
20496         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
20497         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
20498         return (int64_t)ret_conv;
20499 }
20500
20501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
20502         LDKStr o_conv = java_to_owned_str(env, o);
20503         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20504         *ret_conv = CResult_StringErrorZ_ok(o_conv);
20505         return (int64_t)ret_conv;
20506 }
20507
20508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20509         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
20510         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20511         *ret_conv = CResult_StringErrorZ_err(e_conv);
20512         return (int64_t)ret_conv;
20513 }
20514
20515 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20516         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
20517         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
20518         return ret_conv;
20519 }
20520
20521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20522         if ((_res & 1) != 0) return;
20523         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20524         CHECK_ACCESS(_res_ptr);
20525         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
20526         FREE((void*)_res);
20527         CResult_StringErrorZ_free(_res_conv);
20528 }
20529
20530 static inline uintptr_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
20531         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20532         *ret_conv = CResult_StringErrorZ_clone(arg);
20533         return (int64_t)ret_conv;
20534 }
20535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20536         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)(arg & ~1);
20537         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
20538         return ret_conv;
20539 }
20540
20541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20542         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)(orig & ~1);
20543         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20544         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
20545         return (int64_t)ret_conv;
20546 }
20547
20548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20549         LDKChannelMonitorUpdate o_conv;
20550         o_conv.inner = (void*)(o & (~1));
20551         o_conv.is_owned = (o & 1) || (o == 0);
20552         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20553         o_conv = ChannelMonitorUpdate_clone(&o_conv);
20554         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20555         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
20556         return (int64_t)ret_conv;
20557 }
20558
20559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20560         LDKDecodeError e_conv;
20561         e_conv.inner = (void*)(e & (~1));
20562         e_conv.is_owned = (e & 1) || (e == 0);
20563         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20564         e_conv = DecodeError_clone(&e_conv);
20565         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20566         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
20567         return (int64_t)ret_conv;
20568 }
20569
20570 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20571         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
20572         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
20573         return ret_conv;
20574 }
20575
20576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20577         if ((_res & 1) != 0) return;
20578         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20579         CHECK_ACCESS(_res_ptr);
20580         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
20581         FREE((void*)_res);
20582         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
20583 }
20584
20585 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
20586         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20587         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
20588         return (int64_t)ret_conv;
20589 }
20590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20591         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
20592         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
20593         return ret_conv;
20594 }
20595
20596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20597         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
20598         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20599         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
20600         return (int64_t)ret_conv;
20601 }
20602
20603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20604         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20605         CHECK_ACCESS(o_ptr);
20606         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
20607         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
20608         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20609         *ret_copy = COption_MonitorEventZ_some(o_conv);
20610         int64_t ret_ref = (uintptr_t)ret_copy;
20611         return ret_ref;
20612 }
20613
20614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
20615         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20616         *ret_copy = COption_MonitorEventZ_none();
20617         int64_t ret_ref = (uintptr_t)ret_copy;
20618         return ret_ref;
20619 }
20620
20621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20622         if ((_res & 1) != 0) return;
20623         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20624         CHECK_ACCESS(_res_ptr);
20625         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
20626         FREE((void*)_res);
20627         COption_MonitorEventZ_free(_res_conv);
20628 }
20629
20630 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
20631         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20632         *ret_copy = COption_MonitorEventZ_clone(arg);
20633 int64_t ret_ref = (uintptr_t)ret_copy;
20634         return ret_ref;
20635 }
20636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20637         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
20638         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
20639         return ret_conv;
20640 }
20641
20642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20643         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
20644         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20645         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
20646         int64_t ret_ref = (uintptr_t)ret_copy;
20647         return ret_ref;
20648 }
20649
20650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20651         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20652         CHECK_ACCESS(o_ptr);
20653         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
20654         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
20655         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20656         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
20657         return (int64_t)ret_conv;
20658 }
20659
20660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20661         LDKDecodeError e_conv;
20662         e_conv.inner = (void*)(e & (~1));
20663         e_conv.is_owned = (e & 1) || (e == 0);
20664         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20665         e_conv = DecodeError_clone(&e_conv);
20666         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20667         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
20668         return (int64_t)ret_conv;
20669 }
20670
20671 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20672         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
20673         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
20674         return ret_conv;
20675 }
20676
20677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20678         if ((_res & 1) != 0) return;
20679         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20680         CHECK_ACCESS(_res_ptr);
20681         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
20682         FREE((void*)_res);
20683         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
20684 }
20685
20686 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
20687         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20688         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
20689         return (int64_t)ret_conv;
20690 }
20691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20692         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
20693         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
20694         return ret_conv;
20695 }
20696
20697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20698         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
20699         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20700         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
20701         return (int64_t)ret_conv;
20702 }
20703
20704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20705         LDKHTLCUpdate o_conv;
20706         o_conv.inner = (void*)(o & (~1));
20707         o_conv.is_owned = (o & 1) || (o == 0);
20708         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20709         o_conv = HTLCUpdate_clone(&o_conv);
20710         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
20711         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
20712         return (int64_t)ret_conv;
20713 }
20714
20715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20716         LDKDecodeError e_conv;
20717         e_conv.inner = (void*)(e & (~1));
20718         e_conv.is_owned = (e & 1) || (e == 0);
20719         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20720         e_conv = DecodeError_clone(&e_conv);
20721         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
20722         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
20723         return (int64_t)ret_conv;
20724 }
20725
20726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20727         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
20728         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
20729         return ret_conv;
20730 }
20731
20732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20733         if ((_res & 1) != 0) return;
20734         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20735         CHECK_ACCESS(_res_ptr);
20736         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
20737         FREE((void*)_res);
20738         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
20739 }
20740
20741 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
20742         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
20743         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
20744         return (int64_t)ret_conv;
20745 }
20746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20747         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
20748         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
20749         return ret_conv;
20750 }
20751
20752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20753         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
20754         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
20755         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
20756         return (int64_t)ret_conv;
20757 }
20758
20759 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
20760         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
20761         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
20762         return ((int64_t)ret_conv);
20763 }
20764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20765         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
20766         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
20767         return ret_conv;
20768 }
20769
20770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20771         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
20772         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
20773         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
20774         return ((int64_t)ret_conv);
20775 }
20776
20777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
20778         LDKOutPoint a_conv;
20779         a_conv.inner = (void*)(a & (~1));
20780         a_conv.is_owned = (a & 1) || (a == 0);
20781         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20782         a_conv = OutPoint_clone(&a_conv);
20783         LDKCVec_u8Z b_ref;
20784         b_ref.datalen = (*env)->GetArrayLength(env, b);
20785         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
20786         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
20787         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
20788         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
20789         return ((int64_t)ret_conv);
20790 }
20791
20792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20793         if ((_res & 1) != 0) return;
20794         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20795         CHECK_ACCESS(_res_ptr);
20796         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
20797         FREE((void*)_res);
20798         C2Tuple_OutPointScriptZ_free(_res_conv);
20799 }
20800
20801 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
20802         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
20803         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
20804         return ((int64_t)ret_conv);
20805 }
20806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20807         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
20808         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
20809         return ret_conv;
20810 }
20811
20812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20813         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
20814         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
20815         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
20816         return ((int64_t)ret_conv);
20817 }
20818
20819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
20820         LDKCVec_u8Z b_ref;
20821         b_ref.datalen = (*env)->GetArrayLength(env, b);
20822         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
20823         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
20824         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
20825         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
20826         return ((int64_t)ret_conv);
20827 }
20828
20829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20830         if ((_res & 1) != 0) return;
20831         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20832         CHECK_ACCESS(_res_ptr);
20833         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
20834         FREE((void*)_res);
20835         C2Tuple_u32ScriptZ_free(_res_conv);
20836 }
20837
20838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20839         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
20840         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20841         if (_res_constr.datalen > 0)
20842                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
20843         else
20844                 _res_constr.data = NULL;
20845         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20846         for (size_t v = 0; v < _res_constr.datalen; v++) {
20847                 int64_t _res_conv_21 = _res_vals[v];
20848                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
20849                 CHECK_ACCESS(_res_conv_21_ptr);
20850                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
20851                 FREE((void*)_res_conv_21);
20852                 _res_constr.data[v] = _res_conv_21_conv;
20853         }
20854         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20855         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
20856 }
20857
20858 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
20859         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
20860         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
20861         return ((int64_t)ret_conv);
20862 }
20863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20864         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
20865         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
20866         return ret_conv;
20867 }
20868
20869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20870         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
20871         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
20872         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
20873         return ((int64_t)ret_conv);
20874 }
20875
20876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
20877         LDKThirtyTwoBytes a_ref;
20878         CHECK((*env)->GetArrayLength(env, a) == 32);
20879         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20880         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
20881         b_constr.datalen = (*env)->GetArrayLength(env, b);
20882         if (b_constr.datalen > 0)
20883                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
20884         else
20885                 b_constr.data = NULL;
20886         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
20887         for (size_t v = 0; v < b_constr.datalen; v++) {
20888                 int64_t b_conv_21 = b_vals[v];
20889                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
20890                 CHECK_ACCESS(b_conv_21_ptr);
20891                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
20892                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
20893                 b_constr.data[v] = b_conv_21_conv;
20894         }
20895         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
20896         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
20897         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
20898         return ((int64_t)ret_conv);
20899 }
20900
20901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20902         if ((_res & 1) != 0) return;
20903         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20904         CHECK_ACCESS(_res_ptr);
20905         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
20906         FREE((void*)_res);
20907         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
20908 }
20909
20910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20911         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
20912         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20913         if (_res_constr.datalen > 0)
20914                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
20915         else
20916                 _res_constr.data = NULL;
20917         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20918         for (size_t o = 0; o < _res_constr.datalen; o++) {
20919                 int64_t _res_conv_40 = _res_vals[o];
20920                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
20921                 CHECK_ACCESS(_res_conv_40_ptr);
20922                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
20923                 FREE((void*)_res_conv_40);
20924                 _res_constr.data[o] = _res_conv_40_conv;
20925         }
20926         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20927         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
20928 }
20929
20930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20931         LDKCVec_EventZ _res_constr;
20932         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20933         if (_res_constr.datalen > 0)
20934                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
20935         else
20936                 _res_constr.data = NULL;
20937         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20938         for (size_t h = 0; h < _res_constr.datalen; h++) {
20939                 int64_t _res_conv_7 = _res_vals[h];
20940                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
20941                 CHECK_ACCESS(_res_conv_7_ptr);
20942                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
20943                 FREE((void*)_res_conv_7);
20944                 _res_constr.data[h] = _res_conv_7_conv;
20945         }
20946         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20947         CVec_EventZ_free(_res_constr);
20948 }
20949
20950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20951         LDKCVec_TransactionZ _res_constr;
20952         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20953         if (_res_constr.datalen > 0)
20954                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
20955         else
20956                 _res_constr.data = NULL;
20957         for (size_t i = 0; i < _res_constr.datalen; i++) {
20958                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20959                 LDKTransaction _res_conv_8_ref;
20960                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
20961                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
20962                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
20963                 _res_conv_8_ref.data_is_owned = true;
20964                 _res_constr.data[i] = _res_conv_8_ref;
20965         }
20966         CVec_TransactionZ_free(_res_constr);
20967 }
20968
20969 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
20970         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
20971         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
20972         return ((int64_t)ret_conv);
20973 }
20974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20975         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
20976         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
20977         return ret_conv;
20978 }
20979
20980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20981         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
20982         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
20983         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
20984         return ((int64_t)ret_conv);
20985 }
20986
20987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
20988         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
20989         CHECK_ACCESS(b_ptr);
20990         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
20991         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
20992         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
20993         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
20994         return ((int64_t)ret_conv);
20995 }
20996
20997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20998         if ((_res & 1) != 0) return;
20999         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21000         CHECK_ACCESS(_res_ptr);
21001         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
21002         FREE((void*)_res);
21003         C2Tuple_u32TxOutZ_free(_res_conv);
21004 }
21005
21006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21007         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
21008         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21009         if (_res_constr.datalen > 0)
21010                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
21011         else
21012                 _res_constr.data = NULL;
21013         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21014         for (size_t u = 0; u < _res_constr.datalen; u++) {
21015                 int64_t _res_conv_20 = _res_vals[u];
21016                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
21017                 CHECK_ACCESS(_res_conv_20_ptr);
21018                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
21019                 FREE((void*)_res_conv_20);
21020                 _res_constr.data[u] = _res_conv_20_conv;
21021         }
21022         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21023         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
21024 }
21025
21026 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
21027         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21028         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
21029         return ((int64_t)ret_conv);
21030 }
21031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21032         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
21033         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
21034         return ret_conv;
21035 }
21036
21037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21038         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
21039         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21040         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
21041         return ((int64_t)ret_conv);
21042 }
21043
21044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
21045         LDKThirtyTwoBytes a_ref;
21046         CHECK((*env)->GetArrayLength(env, a) == 32);
21047         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21048         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
21049         b_constr.datalen = (*env)->GetArrayLength(env, b);
21050         if (b_constr.datalen > 0)
21051                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
21052         else
21053                 b_constr.data = NULL;
21054         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
21055         for (size_t u = 0; u < b_constr.datalen; u++) {
21056                 int64_t b_conv_20 = b_vals[u];
21057                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
21058                 CHECK_ACCESS(b_conv_20_ptr);
21059                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
21060                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
21061                 b_constr.data[u] = b_conv_20_conv;
21062         }
21063         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
21064         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21065         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
21066         return ((int64_t)ret_conv);
21067 }
21068
21069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21070         if ((_res & 1) != 0) return;
21071         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21072         CHECK_ACCESS(_res_ptr);
21073         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
21074         FREE((void*)_res);
21075         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
21076 }
21077
21078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21079         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
21080         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21081         if (_res_constr.datalen > 0)
21082                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
21083         else
21084                 _res_constr.data = NULL;
21085         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21086         for (size_t n = 0; n < _res_constr.datalen; n++) {
21087                 int64_t _res_conv_39 = _res_vals[n];
21088                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
21089                 CHECK_ACCESS(_res_conv_39_ptr);
21090                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
21091                 FREE((void*)_res_conv_39);
21092                 _res_constr.data[n] = _res_conv_39_conv;
21093         }
21094         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21095         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
21096 }
21097
21098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21099         LDKCVec_BalanceZ _res_constr;
21100         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21101         if (_res_constr.datalen > 0)
21102                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
21103         else
21104                 _res_constr.data = NULL;
21105         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21106         for (size_t j = 0; j < _res_constr.datalen; j++) {
21107                 int64_t _res_conv_9 = _res_vals[j];
21108                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
21109                 CHECK_ACCESS(_res_conv_9_ptr);
21110                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
21111                 FREE((void*)_res_conv_9);
21112                 _res_constr.data[j] = _res_conv_9_conv;
21113         }
21114         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21115         CVec_BalanceZ_free(_res_constr);
21116 }
21117
21118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21119         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21120         CHECK_ACCESS(o_ptr);
21121         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
21122         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
21123         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21124         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
21125         return (int64_t)ret_conv;
21126 }
21127
21128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21129         LDKDecodeError e_conv;
21130         e_conv.inner = (void*)(e & (~1));
21131         e_conv.is_owned = (e & 1) || (e == 0);
21132         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21133         e_conv = DecodeError_clone(&e_conv);
21134         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21135         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
21136         return (int64_t)ret_conv;
21137 }
21138
21139 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21140         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
21141         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
21142         return ret_conv;
21143 }
21144
21145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21146         if ((_res & 1) != 0) return;
21147         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21148         CHECK_ACCESS(_res_ptr);
21149         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
21150         FREE((void*)_res);
21151         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
21152 }
21153
21154 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
21155         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21156         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
21157         return (int64_t)ret_conv;
21158 }
21159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21160         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
21161         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
21162         return ret_conv;
21163 }
21164
21165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21166         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
21167         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21168         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
21169         return (int64_t)ret_conv;
21170 }
21171
21172 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
21173         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21174         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
21175         return ((int64_t)ret_conv);
21176 }
21177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21178         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
21179         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
21180         return ret_conv;
21181 }
21182
21183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21184         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
21185         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21186         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
21187         return ((int64_t)ret_conv);
21188 }
21189
21190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21191         LDKPublicKey a_ref;
21192         CHECK((*env)->GetArrayLength(env, a) == 33);
21193         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
21194         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
21195         CHECK_ACCESS(b_ptr);
21196         LDKType b_conv = *(LDKType*)(b_ptr);
21197         if (b_conv.free == LDKType_JCalls_free) {
21198                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21199                 LDKType_JCalls_cloned(&b_conv);
21200         }
21201         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21202         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
21203         return ((int64_t)ret_conv);
21204 }
21205
21206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_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         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
21211         FREE((void*)_res);
21212         C2Tuple_PublicKeyTypeZ_free(_res_conv);
21213 }
21214
21215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21216         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
21217         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21218         if (_res_constr.datalen > 0)
21219                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
21220         else
21221                 _res_constr.data = NULL;
21222         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21223         for (size_t z = 0; z < _res_constr.datalen; z++) {
21224                 int64_t _res_conv_25 = _res_vals[z];
21225                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
21226                 CHECK_ACCESS(_res_conv_25_ptr);
21227                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
21228                 FREE((void*)_res_conv_25);
21229                 _res_constr.data[z] = _res_conv_25_conv;
21230         }
21231         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21232         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
21233 }
21234
21235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21236         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21237         CHECK_ACCESS(o_ptr);
21238         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
21239         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
21240         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21241         *ret_copy = COption_NetAddressZ_some(o_conv);
21242         int64_t ret_ref = (uintptr_t)ret_copy;
21243         return ret_ref;
21244 }
21245
21246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
21247         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21248         *ret_copy = COption_NetAddressZ_none();
21249         int64_t ret_ref = (uintptr_t)ret_copy;
21250         return ret_ref;
21251 }
21252
21253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21254         if ((_res & 1) != 0) return;
21255         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21256         CHECK_ACCESS(_res_ptr);
21257         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
21258         FREE((void*)_res);
21259         COption_NetAddressZ_free(_res_conv);
21260 }
21261
21262 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
21263         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21264         *ret_copy = COption_NetAddressZ_clone(arg);
21265 int64_t ret_ref = (uintptr_t)ret_copy;
21266         return ret_ref;
21267 }
21268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21269         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
21270         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
21271         return ret_conv;
21272 }
21273
21274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21275         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
21276         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21277         *ret_copy = COption_NetAddressZ_clone(orig_conv);
21278         int64_t ret_ref = (uintptr_t)ret_copy;
21279         return ret_ref;
21280 }
21281
21282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21283         LDKCVec_u8Z o_ref;
21284         o_ref.datalen = (*env)->GetArrayLength(env, o);
21285         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
21286         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
21287         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21288         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
21289         return (int64_t)ret_conv;
21290 }
21291
21292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21293         LDKPeerHandleError e_conv;
21294         e_conv.inner = (void*)(e & (~1));
21295         e_conv.is_owned = (e & 1) || (e == 0);
21296         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21297         e_conv = PeerHandleError_clone(&e_conv);
21298         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21299         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
21300         return (int64_t)ret_conv;
21301 }
21302
21303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21304         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
21305         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
21306         return ret_conv;
21307 }
21308
21309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21310         if ((_res & 1) != 0) return;
21311         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21312         CHECK_ACCESS(_res_ptr);
21313         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
21314         FREE((void*)_res);
21315         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
21316 }
21317
21318 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
21319         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21320         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
21321         return (int64_t)ret_conv;
21322 }
21323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21324         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
21325         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
21326         return ret_conv;
21327 }
21328
21329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21330         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
21331         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21332         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
21333         return (int64_t)ret_conv;
21334 }
21335
21336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
21337         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21338         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
21339         return (int64_t)ret_conv;
21340 }
21341
21342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21343         LDKPeerHandleError e_conv;
21344         e_conv.inner = (void*)(e & (~1));
21345         e_conv.is_owned = (e & 1) || (e == 0);
21346         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21347         e_conv = PeerHandleError_clone(&e_conv);
21348         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21349         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
21350         return (int64_t)ret_conv;
21351 }
21352
21353 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21354         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
21355         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
21356         return ret_conv;
21357 }
21358
21359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21360         if ((_res & 1) != 0) return;
21361         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21362         CHECK_ACCESS(_res_ptr);
21363         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
21364         FREE((void*)_res);
21365         CResult_NonePeerHandleErrorZ_free(_res_conv);
21366 }
21367
21368 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
21369         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21370         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
21371         return (int64_t)ret_conv;
21372 }
21373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21374         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
21375         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
21376         return ret_conv;
21377 }
21378
21379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21380         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
21381         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21382         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
21383         return (int64_t)ret_conv;
21384 }
21385
21386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
21387         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21388         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
21389         return (int64_t)ret_conv;
21390 }
21391
21392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21393         LDKPeerHandleError e_conv;
21394         e_conv.inner = (void*)(e & (~1));
21395         e_conv.is_owned = (e & 1) || (e == 0);
21396         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21397         e_conv = PeerHandleError_clone(&e_conv);
21398         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21399         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
21400         return (int64_t)ret_conv;
21401 }
21402
21403 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21404         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
21405         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
21406         return ret_conv;
21407 }
21408
21409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21410         if ((_res & 1) != 0) return;
21411         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21412         CHECK_ACCESS(_res_ptr);
21413         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
21414         FREE((void*)_res);
21415         CResult_boolPeerHandleErrorZ_free(_res_conv);
21416 }
21417
21418 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
21419         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21420         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
21421         return (int64_t)ret_conv;
21422 }
21423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21424         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
21425         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
21426         return ret_conv;
21427 }
21428
21429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21430         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
21431         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21432         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
21433         return (int64_t)ret_conv;
21434 }
21435
21436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
21437         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
21438         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
21439         return (int64_t)ret_conv;
21440 }
21441
21442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21443         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
21444         CHECK_ACCESS(e_ptr);
21445         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
21446         e_conv = GraphSyncError_clone((LDKGraphSyncError*)(((uintptr_t)e) & ~1));
21447         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
21448         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
21449         return (int64_t)ret_conv;
21450 }
21451
21452 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21453         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)(o & ~1);
21454         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
21455         return ret_conv;
21456 }
21457
21458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21459         if ((_res & 1) != 0) return;
21460         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21461         CHECK_ACCESS(_res_ptr);
21462         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
21463         FREE((void*)_res);
21464         CResult_u32GraphSyncErrorZ_free(_res_conv);
21465 }
21466
21467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21468         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21469         CHECK_ACCESS(o_ptr);
21470         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
21471         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
21472         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21473         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
21474         return (int64_t)ret_conv;
21475 }
21476
21477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21478         LDKDecodeError e_conv;
21479         e_conv.inner = (void*)(e & (~1));
21480         e_conv.is_owned = (e & 1) || (e == 0);
21481         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21482         e_conv = DecodeError_clone(&e_conv);
21483         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21484         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
21485         return (int64_t)ret_conv;
21486 }
21487
21488 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21489         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
21490         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
21491         return ret_conv;
21492 }
21493
21494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21495         if ((_res & 1) != 0) return;
21496         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21497         CHECK_ACCESS(_res_ptr);
21498         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
21499         FREE((void*)_res);
21500         CResult_NetAddressDecodeErrorZ_free(_res_conv);
21501 }
21502
21503 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
21504         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21505         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
21506         return (int64_t)ret_conv;
21507 }
21508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21509         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
21510         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
21511         return ret_conv;
21512 }
21513
21514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21515         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
21516         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21517         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
21518         return (int64_t)ret_conv;
21519 }
21520
21521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21522         LDKCVec_UpdateAddHTLCZ _res_constr;
21523         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21524         if (_res_constr.datalen > 0)
21525                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
21526         else
21527                 _res_constr.data = NULL;
21528         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21529         for (size_t p = 0; p < _res_constr.datalen; p++) {
21530                 int64_t _res_conv_15 = _res_vals[p];
21531                 LDKUpdateAddHTLC _res_conv_15_conv;
21532                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
21533                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
21534                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
21535                 _res_constr.data[p] = _res_conv_15_conv;
21536         }
21537         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21538         CVec_UpdateAddHTLCZ_free(_res_constr);
21539 }
21540
21541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21542         LDKCVec_UpdateFulfillHTLCZ _res_constr;
21543         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21544         if (_res_constr.datalen > 0)
21545                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
21546         else
21547                 _res_constr.data = NULL;
21548         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21549         for (size_t t = 0; t < _res_constr.datalen; t++) {
21550                 int64_t _res_conv_19 = _res_vals[t];
21551                 LDKUpdateFulfillHTLC _res_conv_19_conv;
21552                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
21553                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
21554                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
21555                 _res_constr.data[t] = _res_conv_19_conv;
21556         }
21557         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21558         CVec_UpdateFulfillHTLCZ_free(_res_constr);
21559 }
21560
21561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21562         LDKCVec_UpdateFailHTLCZ _res_constr;
21563         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21564         if (_res_constr.datalen > 0)
21565                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
21566         else
21567                 _res_constr.data = NULL;
21568         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21569         for (size_t q = 0; q < _res_constr.datalen; q++) {
21570                 int64_t _res_conv_16 = _res_vals[q];
21571                 LDKUpdateFailHTLC _res_conv_16_conv;
21572                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
21573                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
21574                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
21575                 _res_constr.data[q] = _res_conv_16_conv;
21576         }
21577         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21578         CVec_UpdateFailHTLCZ_free(_res_constr);
21579 }
21580
21581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21582         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
21583         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21584         if (_res_constr.datalen > 0)
21585                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
21586         else
21587                 _res_constr.data = NULL;
21588         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21589         for (size_t z = 0; z < _res_constr.datalen; z++) {
21590                 int64_t _res_conv_25 = _res_vals[z];
21591                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
21592                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
21593                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
21594                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
21595                 _res_constr.data[z] = _res_conv_25_conv;
21596         }
21597         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21598         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
21599 }
21600
21601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21602         LDKAcceptChannel o_conv;
21603         o_conv.inner = (void*)(o & (~1));
21604         o_conv.is_owned = (o & 1) || (o == 0);
21605         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21606         o_conv = AcceptChannel_clone(&o_conv);
21607         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21608         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
21609         return (int64_t)ret_conv;
21610 }
21611
21612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21613         LDKDecodeError e_conv;
21614         e_conv.inner = (void*)(e & (~1));
21615         e_conv.is_owned = (e & 1) || (e == 0);
21616         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21617         e_conv = DecodeError_clone(&e_conv);
21618         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21619         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
21620         return (int64_t)ret_conv;
21621 }
21622
21623 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21624         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
21625         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
21626         return ret_conv;
21627 }
21628
21629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21630         if ((_res & 1) != 0) return;
21631         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21632         CHECK_ACCESS(_res_ptr);
21633         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
21634         FREE((void*)_res);
21635         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
21636 }
21637
21638 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
21639         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21640         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
21641         return (int64_t)ret_conv;
21642 }
21643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21644         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
21645         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
21646         return ret_conv;
21647 }
21648
21649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21650         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
21651         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21652         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
21653         return (int64_t)ret_conv;
21654 }
21655
21656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21657         LDKAnnouncementSignatures o_conv;
21658         o_conv.inner = (void*)(o & (~1));
21659         o_conv.is_owned = (o & 1) || (o == 0);
21660         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21661         o_conv = AnnouncementSignatures_clone(&o_conv);
21662         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21663         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
21664         return (int64_t)ret_conv;
21665 }
21666
21667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21668         LDKDecodeError e_conv;
21669         e_conv.inner = (void*)(e & (~1));
21670         e_conv.is_owned = (e & 1) || (e == 0);
21671         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21672         e_conv = DecodeError_clone(&e_conv);
21673         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21674         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
21675         return (int64_t)ret_conv;
21676 }
21677
21678 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21679         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
21680         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
21681         return ret_conv;
21682 }
21683
21684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21685         if ((_res & 1) != 0) return;
21686         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21687         CHECK_ACCESS(_res_ptr);
21688         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
21689         FREE((void*)_res);
21690         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
21691 }
21692
21693 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
21694         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21695         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
21696         return (int64_t)ret_conv;
21697 }
21698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21699         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
21700         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
21701         return ret_conv;
21702 }
21703
21704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21705         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
21706         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21707         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
21708         return (int64_t)ret_conv;
21709 }
21710
21711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21712         LDKChannelReestablish o_conv;
21713         o_conv.inner = (void*)(o & (~1));
21714         o_conv.is_owned = (o & 1) || (o == 0);
21715         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21716         o_conv = ChannelReestablish_clone(&o_conv);
21717         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21718         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
21719         return (int64_t)ret_conv;
21720 }
21721
21722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21723         LDKDecodeError e_conv;
21724         e_conv.inner = (void*)(e & (~1));
21725         e_conv.is_owned = (e & 1) || (e == 0);
21726         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21727         e_conv = DecodeError_clone(&e_conv);
21728         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21729         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
21730         return (int64_t)ret_conv;
21731 }
21732
21733 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21734         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
21735         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
21736         return ret_conv;
21737 }
21738
21739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21740         if ((_res & 1) != 0) return;
21741         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21742         CHECK_ACCESS(_res_ptr);
21743         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
21744         FREE((void*)_res);
21745         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
21746 }
21747
21748 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
21749         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21750         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
21751         return (int64_t)ret_conv;
21752 }
21753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21754         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
21755         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
21756         return ret_conv;
21757 }
21758
21759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21760         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
21761         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21762         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
21763         return (int64_t)ret_conv;
21764 }
21765
21766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21767         LDKClosingSigned o_conv;
21768         o_conv.inner = (void*)(o & (~1));
21769         o_conv.is_owned = (o & 1) || (o == 0);
21770         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21771         o_conv = ClosingSigned_clone(&o_conv);
21772         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21773         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
21774         return (int64_t)ret_conv;
21775 }
21776
21777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21778         LDKDecodeError e_conv;
21779         e_conv.inner = (void*)(e & (~1));
21780         e_conv.is_owned = (e & 1) || (e == 0);
21781         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21782         e_conv = DecodeError_clone(&e_conv);
21783         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21784         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
21785         return (int64_t)ret_conv;
21786 }
21787
21788 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21789         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
21790         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
21791         return ret_conv;
21792 }
21793
21794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21795         if ((_res & 1) != 0) return;
21796         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21797         CHECK_ACCESS(_res_ptr);
21798         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
21799         FREE((void*)_res);
21800         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
21801 }
21802
21803 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
21804         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21805         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
21806         return (int64_t)ret_conv;
21807 }
21808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21809         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
21810         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
21811         return ret_conv;
21812 }
21813
21814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21815         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
21816         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21817         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
21818         return (int64_t)ret_conv;
21819 }
21820
21821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21822         LDKClosingSignedFeeRange o_conv;
21823         o_conv.inner = (void*)(o & (~1));
21824         o_conv.is_owned = (o & 1) || (o == 0);
21825         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21826         o_conv = ClosingSignedFeeRange_clone(&o_conv);
21827         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21828         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
21829         return (int64_t)ret_conv;
21830 }
21831
21832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21833         LDKDecodeError e_conv;
21834         e_conv.inner = (void*)(e & (~1));
21835         e_conv.is_owned = (e & 1) || (e == 0);
21836         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21837         e_conv = DecodeError_clone(&e_conv);
21838         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21839         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
21840         return (int64_t)ret_conv;
21841 }
21842
21843 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21844         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
21845         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
21846         return ret_conv;
21847 }
21848
21849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21850         if ((_res & 1) != 0) return;
21851         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21852         CHECK_ACCESS(_res_ptr);
21853         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
21854         FREE((void*)_res);
21855         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
21856 }
21857
21858 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
21859         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21860         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
21861         return (int64_t)ret_conv;
21862 }
21863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21864         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
21865         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
21866         return ret_conv;
21867 }
21868
21869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21870         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
21871         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21872         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
21873         return (int64_t)ret_conv;
21874 }
21875
21876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21877         LDKCommitmentSigned o_conv;
21878         o_conv.inner = (void*)(o & (~1));
21879         o_conv.is_owned = (o & 1) || (o == 0);
21880         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21881         o_conv = CommitmentSigned_clone(&o_conv);
21882         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21883         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
21884         return (int64_t)ret_conv;
21885 }
21886
21887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21888         LDKDecodeError e_conv;
21889         e_conv.inner = (void*)(e & (~1));
21890         e_conv.is_owned = (e & 1) || (e == 0);
21891         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21892         e_conv = DecodeError_clone(&e_conv);
21893         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21894         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
21895         return (int64_t)ret_conv;
21896 }
21897
21898 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21899         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
21900         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
21901         return ret_conv;
21902 }
21903
21904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21905         if ((_res & 1) != 0) return;
21906         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21907         CHECK_ACCESS(_res_ptr);
21908         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
21909         FREE((void*)_res);
21910         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
21911 }
21912
21913 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
21914         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21915         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
21916         return (int64_t)ret_conv;
21917 }
21918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21919         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
21920         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
21921         return ret_conv;
21922 }
21923
21924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21925         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
21926         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21927         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
21928         return (int64_t)ret_conv;
21929 }
21930
21931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21932         LDKFundingCreated o_conv;
21933         o_conv.inner = (void*)(o & (~1));
21934         o_conv.is_owned = (o & 1) || (o == 0);
21935         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21936         o_conv = FundingCreated_clone(&o_conv);
21937         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21938         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
21939         return (int64_t)ret_conv;
21940 }
21941
21942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21943         LDKDecodeError e_conv;
21944         e_conv.inner = (void*)(e & (~1));
21945         e_conv.is_owned = (e & 1) || (e == 0);
21946         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21947         e_conv = DecodeError_clone(&e_conv);
21948         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21949         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
21950         return (int64_t)ret_conv;
21951 }
21952
21953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21954         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
21955         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
21956         return ret_conv;
21957 }
21958
21959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21960         if ((_res & 1) != 0) return;
21961         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21962         CHECK_ACCESS(_res_ptr);
21963         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
21964         FREE((void*)_res);
21965         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
21966 }
21967
21968 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
21969         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21970         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
21971         return (int64_t)ret_conv;
21972 }
21973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21974         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
21975         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
21976         return ret_conv;
21977 }
21978
21979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21980         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
21981         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21982         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
21983         return (int64_t)ret_conv;
21984 }
21985
21986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21987         LDKFundingSigned o_conv;
21988         o_conv.inner = (void*)(o & (~1));
21989         o_conv.is_owned = (o & 1) || (o == 0);
21990         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21991         o_conv = FundingSigned_clone(&o_conv);
21992         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21993         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
21994         return (int64_t)ret_conv;
21995 }
21996
21997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21998         LDKDecodeError e_conv;
21999         e_conv.inner = (void*)(e & (~1));
22000         e_conv.is_owned = (e & 1) || (e == 0);
22001         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22002         e_conv = DecodeError_clone(&e_conv);
22003         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22004         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
22005         return (int64_t)ret_conv;
22006 }
22007
22008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22009         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
22010         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
22011         return ret_conv;
22012 }
22013
22014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22015         if ((_res & 1) != 0) return;
22016         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22017         CHECK_ACCESS(_res_ptr);
22018         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
22019         FREE((void*)_res);
22020         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
22021 }
22022
22023 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
22024         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22025         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
22026         return (int64_t)ret_conv;
22027 }
22028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22029         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
22030         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
22031         return ret_conv;
22032 }
22033
22034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22035         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
22036         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22037         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
22038         return (int64_t)ret_conv;
22039 }
22040
22041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22042         LDKChannelReady o_conv;
22043         o_conv.inner = (void*)(o & (~1));
22044         o_conv.is_owned = (o & 1) || (o == 0);
22045         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22046         o_conv = ChannelReady_clone(&o_conv);
22047         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22048         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
22049         return (int64_t)ret_conv;
22050 }
22051
22052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22053         LDKDecodeError e_conv;
22054         e_conv.inner = (void*)(e & (~1));
22055         e_conv.is_owned = (e & 1) || (e == 0);
22056         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22057         e_conv = DecodeError_clone(&e_conv);
22058         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22059         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
22060         return (int64_t)ret_conv;
22061 }
22062
22063 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22064         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(o & ~1);
22065         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
22066         return ret_conv;
22067 }
22068
22069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22070         if ((_res & 1) != 0) return;
22071         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22072         CHECK_ACCESS(_res_ptr);
22073         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
22074         FREE((void*)_res);
22075         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
22076 }
22077
22078 static inline uintptr_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
22079         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22080         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
22081         return (int64_t)ret_conv;
22082 }
22083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22084         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(arg & ~1);
22085         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
22086         return ret_conv;
22087 }
22088
22089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22090         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(orig & ~1);
22091         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22092         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
22093         return (int64_t)ret_conv;
22094 }
22095
22096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22097         LDKInit o_conv;
22098         o_conv.inner = (void*)(o & (~1));
22099         o_conv.is_owned = (o & 1) || (o == 0);
22100         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22101         o_conv = Init_clone(&o_conv);
22102         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22103         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
22104         return (int64_t)ret_conv;
22105 }
22106
22107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22108         LDKDecodeError e_conv;
22109         e_conv.inner = (void*)(e & (~1));
22110         e_conv.is_owned = (e & 1) || (e == 0);
22111         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22112         e_conv = DecodeError_clone(&e_conv);
22113         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22114         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
22115         return (int64_t)ret_conv;
22116 }
22117
22118 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22119         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
22120         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
22121         return ret_conv;
22122 }
22123
22124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22125         if ((_res & 1) != 0) return;
22126         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22127         CHECK_ACCESS(_res_ptr);
22128         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
22129         FREE((void*)_res);
22130         CResult_InitDecodeErrorZ_free(_res_conv);
22131 }
22132
22133 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
22134         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22135         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
22136         return (int64_t)ret_conv;
22137 }
22138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22139         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
22140         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
22141         return ret_conv;
22142 }
22143
22144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22145         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
22146         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22147         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
22148         return (int64_t)ret_conv;
22149 }
22150
22151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22152         LDKOpenChannel o_conv;
22153         o_conv.inner = (void*)(o & (~1));
22154         o_conv.is_owned = (o & 1) || (o == 0);
22155         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22156         o_conv = OpenChannel_clone(&o_conv);
22157         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22158         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
22159         return (int64_t)ret_conv;
22160 }
22161
22162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22163         LDKDecodeError e_conv;
22164         e_conv.inner = (void*)(e & (~1));
22165         e_conv.is_owned = (e & 1) || (e == 0);
22166         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22167         e_conv = DecodeError_clone(&e_conv);
22168         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22169         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
22170         return (int64_t)ret_conv;
22171 }
22172
22173 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22174         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
22175         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
22176         return ret_conv;
22177 }
22178
22179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22180         if ((_res & 1) != 0) return;
22181         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22182         CHECK_ACCESS(_res_ptr);
22183         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
22184         FREE((void*)_res);
22185         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
22186 }
22187
22188 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
22189         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22190         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
22191         return (int64_t)ret_conv;
22192 }
22193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22194         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
22195         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
22196         return ret_conv;
22197 }
22198
22199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22200         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
22201         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22202         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
22203         return (int64_t)ret_conv;
22204 }
22205
22206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22207         LDKRevokeAndACK o_conv;
22208         o_conv.inner = (void*)(o & (~1));
22209         o_conv.is_owned = (o & 1) || (o == 0);
22210         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22211         o_conv = RevokeAndACK_clone(&o_conv);
22212         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22213         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
22214         return (int64_t)ret_conv;
22215 }
22216
22217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22218         LDKDecodeError e_conv;
22219         e_conv.inner = (void*)(e & (~1));
22220         e_conv.is_owned = (e & 1) || (e == 0);
22221         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22222         e_conv = DecodeError_clone(&e_conv);
22223         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22224         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
22225         return (int64_t)ret_conv;
22226 }
22227
22228 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22229         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
22230         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
22231         return ret_conv;
22232 }
22233
22234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22235         if ((_res & 1) != 0) return;
22236         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22237         CHECK_ACCESS(_res_ptr);
22238         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
22239         FREE((void*)_res);
22240         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
22241 }
22242
22243 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
22244         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22245         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
22246         return (int64_t)ret_conv;
22247 }
22248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22249         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
22250         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
22251         return ret_conv;
22252 }
22253
22254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22255         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
22256         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22257         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
22258         return (int64_t)ret_conv;
22259 }
22260
22261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22262         LDKShutdown o_conv;
22263         o_conv.inner = (void*)(o & (~1));
22264         o_conv.is_owned = (o & 1) || (o == 0);
22265         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22266         o_conv = Shutdown_clone(&o_conv);
22267         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22268         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
22269         return (int64_t)ret_conv;
22270 }
22271
22272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22273         LDKDecodeError e_conv;
22274         e_conv.inner = (void*)(e & (~1));
22275         e_conv.is_owned = (e & 1) || (e == 0);
22276         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22277         e_conv = DecodeError_clone(&e_conv);
22278         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22279         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
22280         return (int64_t)ret_conv;
22281 }
22282
22283 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22284         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
22285         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
22286         return ret_conv;
22287 }
22288
22289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22290         if ((_res & 1) != 0) return;
22291         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22292         CHECK_ACCESS(_res_ptr);
22293         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
22294         FREE((void*)_res);
22295         CResult_ShutdownDecodeErrorZ_free(_res_conv);
22296 }
22297
22298 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
22299         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22300         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
22301         return (int64_t)ret_conv;
22302 }
22303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22304         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
22305         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
22306         return ret_conv;
22307 }
22308
22309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22310         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
22311         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22312         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
22313         return (int64_t)ret_conv;
22314 }
22315
22316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22317         LDKUpdateFailHTLC o_conv;
22318         o_conv.inner = (void*)(o & (~1));
22319         o_conv.is_owned = (o & 1) || (o == 0);
22320         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22321         o_conv = UpdateFailHTLC_clone(&o_conv);
22322         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
22323         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
22324         return (int64_t)ret_conv;
22325 }
22326
22327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22328         LDKDecodeError e_conv;
22329         e_conv.inner = (void*)(e & (~1));
22330         e_conv.is_owned = (e & 1) || (e == 0);
22331         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22332         e_conv = DecodeError_clone(&e_conv);
22333         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
22334         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
22335         return (int64_t)ret_conv;
22336 }
22337
22338 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22339         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
22340         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
22341         return ret_conv;
22342 }
22343
22344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22345         if ((_res & 1) != 0) return;
22346         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22347         CHECK_ACCESS(_res_ptr);
22348         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
22349         FREE((void*)_res);
22350         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
22351 }
22352
22353 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
22354         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
22355         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
22356         return (int64_t)ret_conv;
22357 }
22358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22359         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
22360         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
22361         return ret_conv;
22362 }
22363
22364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22365         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
22366         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
22367         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
22368         return (int64_t)ret_conv;
22369 }
22370
22371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22372         LDKUpdateFailMalformedHTLC o_conv;
22373         o_conv.inner = (void*)(o & (~1));
22374         o_conv.is_owned = (o & 1) || (o == 0);
22375         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22376         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
22377         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
22378         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
22379         return (int64_t)ret_conv;
22380 }
22381
22382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22383         LDKDecodeError e_conv;
22384         e_conv.inner = (void*)(e & (~1));
22385         e_conv.is_owned = (e & 1) || (e == 0);
22386         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22387         e_conv = DecodeError_clone(&e_conv);
22388         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
22389         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
22390         return (int64_t)ret_conv;
22391 }
22392
22393 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22394         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
22395         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
22396         return ret_conv;
22397 }
22398
22399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22400         if ((_res & 1) != 0) return;
22401         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22402         CHECK_ACCESS(_res_ptr);
22403         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
22404         FREE((void*)_res);
22405         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
22406 }
22407
22408 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
22409         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
22410         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
22411         return (int64_t)ret_conv;
22412 }
22413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22414         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
22415         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
22416         return ret_conv;
22417 }
22418
22419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22420         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
22421         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
22422         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
22423         return (int64_t)ret_conv;
22424 }
22425
22426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22427         LDKUpdateFee o_conv;
22428         o_conv.inner = (void*)(o & (~1));
22429         o_conv.is_owned = (o & 1) || (o == 0);
22430         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22431         o_conv = UpdateFee_clone(&o_conv);
22432         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22433         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
22434         return (int64_t)ret_conv;
22435 }
22436
22437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22438         LDKDecodeError e_conv;
22439         e_conv.inner = (void*)(e & (~1));
22440         e_conv.is_owned = (e & 1) || (e == 0);
22441         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22442         e_conv = DecodeError_clone(&e_conv);
22443         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22444         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
22445         return (int64_t)ret_conv;
22446 }
22447
22448 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22449         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
22450         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
22451         return ret_conv;
22452 }
22453
22454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22455         if ((_res & 1) != 0) return;
22456         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22457         CHECK_ACCESS(_res_ptr);
22458         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
22459         FREE((void*)_res);
22460         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
22461 }
22462
22463 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
22464         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22465         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
22466         return (int64_t)ret_conv;
22467 }
22468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22469         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
22470         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
22471         return ret_conv;
22472 }
22473
22474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22475         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
22476         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22477         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
22478         return (int64_t)ret_conv;
22479 }
22480
22481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22482         LDKUpdateFulfillHTLC o_conv;
22483         o_conv.inner = (void*)(o & (~1));
22484         o_conv.is_owned = (o & 1) || (o == 0);
22485         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22486         o_conv = UpdateFulfillHTLC_clone(&o_conv);
22487         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22488         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
22489         return (int64_t)ret_conv;
22490 }
22491
22492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22493         LDKDecodeError e_conv;
22494         e_conv.inner = (void*)(e & (~1));
22495         e_conv.is_owned = (e & 1) || (e == 0);
22496         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22497         e_conv = DecodeError_clone(&e_conv);
22498         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22499         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
22500         return (int64_t)ret_conv;
22501 }
22502
22503 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22504         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
22505         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
22506         return ret_conv;
22507 }
22508
22509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22510         if ((_res & 1) != 0) return;
22511         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22512         CHECK_ACCESS(_res_ptr);
22513         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
22514         FREE((void*)_res);
22515         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
22516 }
22517
22518 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
22519         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22520         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
22521         return (int64_t)ret_conv;
22522 }
22523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22524         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
22525         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
22526         return ret_conv;
22527 }
22528
22529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22530         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
22531         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22532         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
22533         return (int64_t)ret_conv;
22534 }
22535
22536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22537         LDKUpdateAddHTLC o_conv;
22538         o_conv.inner = (void*)(o & (~1));
22539         o_conv.is_owned = (o & 1) || (o == 0);
22540         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22541         o_conv = UpdateAddHTLC_clone(&o_conv);
22542         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22543         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
22544         return (int64_t)ret_conv;
22545 }
22546
22547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22548         LDKDecodeError e_conv;
22549         e_conv.inner = (void*)(e & (~1));
22550         e_conv.is_owned = (e & 1) || (e == 0);
22551         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22552         e_conv = DecodeError_clone(&e_conv);
22553         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22554         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
22555         return (int64_t)ret_conv;
22556 }
22557
22558 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22559         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
22560         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
22561         return ret_conv;
22562 }
22563
22564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22565         if ((_res & 1) != 0) return;
22566         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22567         CHECK_ACCESS(_res_ptr);
22568         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
22569         FREE((void*)_res);
22570         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
22571 }
22572
22573 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
22574         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22575         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
22576         return (int64_t)ret_conv;
22577 }
22578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22579         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
22580         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
22581         return ret_conv;
22582 }
22583
22584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22585         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
22586         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22587         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
22588         return (int64_t)ret_conv;
22589 }
22590
22591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22592         LDKPing o_conv;
22593         o_conv.inner = (void*)(o & (~1));
22594         o_conv.is_owned = (o & 1) || (o == 0);
22595         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22596         o_conv = Ping_clone(&o_conv);
22597         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22598         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
22599         return (int64_t)ret_conv;
22600 }
22601
22602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22603         LDKDecodeError e_conv;
22604         e_conv.inner = (void*)(e & (~1));
22605         e_conv.is_owned = (e & 1) || (e == 0);
22606         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22607         e_conv = DecodeError_clone(&e_conv);
22608         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22609         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
22610         return (int64_t)ret_conv;
22611 }
22612
22613 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22614         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
22615         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
22616         return ret_conv;
22617 }
22618
22619 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22620         if ((_res & 1) != 0) return;
22621         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22622         CHECK_ACCESS(_res_ptr);
22623         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
22624         FREE((void*)_res);
22625         CResult_PingDecodeErrorZ_free(_res_conv);
22626 }
22627
22628 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
22629         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22630         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
22631         return (int64_t)ret_conv;
22632 }
22633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22634         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
22635         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
22636         return ret_conv;
22637 }
22638
22639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22640         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
22641         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22642         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
22643         return (int64_t)ret_conv;
22644 }
22645
22646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22647         LDKPong o_conv;
22648         o_conv.inner = (void*)(o & (~1));
22649         o_conv.is_owned = (o & 1) || (o == 0);
22650         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22651         o_conv = Pong_clone(&o_conv);
22652         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22653         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
22654         return (int64_t)ret_conv;
22655 }
22656
22657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22658         LDKDecodeError e_conv;
22659         e_conv.inner = (void*)(e & (~1));
22660         e_conv.is_owned = (e & 1) || (e == 0);
22661         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22662         e_conv = DecodeError_clone(&e_conv);
22663         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22664         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
22665         return (int64_t)ret_conv;
22666 }
22667
22668 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22669         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
22670         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
22671         return ret_conv;
22672 }
22673
22674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22675         if ((_res & 1) != 0) return;
22676         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22677         CHECK_ACCESS(_res_ptr);
22678         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
22679         FREE((void*)_res);
22680         CResult_PongDecodeErrorZ_free(_res_conv);
22681 }
22682
22683 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
22684         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22685         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
22686         return (int64_t)ret_conv;
22687 }
22688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22689         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
22690         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
22691         return ret_conv;
22692 }
22693
22694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22695         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
22696         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22697         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
22698         return (int64_t)ret_conv;
22699 }
22700
22701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22702         LDKUnsignedChannelAnnouncement o_conv;
22703         o_conv.inner = (void*)(o & (~1));
22704         o_conv.is_owned = (o & 1) || (o == 0);
22705         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22706         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
22707         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22708         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
22709         return (int64_t)ret_conv;
22710 }
22711
22712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22713         LDKDecodeError e_conv;
22714         e_conv.inner = (void*)(e & (~1));
22715         e_conv.is_owned = (e & 1) || (e == 0);
22716         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22717         e_conv = DecodeError_clone(&e_conv);
22718         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22719         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
22720         return (int64_t)ret_conv;
22721 }
22722
22723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22724         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
22725         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
22726         return ret_conv;
22727 }
22728
22729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22730         if ((_res & 1) != 0) return;
22731         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22732         CHECK_ACCESS(_res_ptr);
22733         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
22734         FREE((void*)_res);
22735         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
22736 }
22737
22738 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22739         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22740         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
22741         return (int64_t)ret_conv;
22742 }
22743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22744         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
22745         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22746         return ret_conv;
22747 }
22748
22749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22750         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
22751         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22752         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
22753         return (int64_t)ret_conv;
22754 }
22755
22756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22757         LDKChannelAnnouncement o_conv;
22758         o_conv.inner = (void*)(o & (~1));
22759         o_conv.is_owned = (o & 1) || (o == 0);
22760         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22761         o_conv = ChannelAnnouncement_clone(&o_conv);
22762         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22763         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
22764         return (int64_t)ret_conv;
22765 }
22766
22767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22768         LDKDecodeError e_conv;
22769         e_conv.inner = (void*)(e & (~1));
22770         e_conv.is_owned = (e & 1) || (e == 0);
22771         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22772         e_conv = DecodeError_clone(&e_conv);
22773         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22774         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
22775         return (int64_t)ret_conv;
22776 }
22777
22778 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22779         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
22780         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
22781         return ret_conv;
22782 }
22783
22784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22785         if ((_res & 1) != 0) return;
22786         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22787         CHECK_ACCESS(_res_ptr);
22788         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
22789         FREE((void*)_res);
22790         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
22791 }
22792
22793 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22794         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22795         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
22796         return (int64_t)ret_conv;
22797 }
22798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22799         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
22800         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22801         return ret_conv;
22802 }
22803
22804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22805         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
22806         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22807         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
22808         return (int64_t)ret_conv;
22809 }
22810
22811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22812         LDKUnsignedChannelUpdate o_conv;
22813         o_conv.inner = (void*)(o & (~1));
22814         o_conv.is_owned = (o & 1) || (o == 0);
22815         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22816         o_conv = UnsignedChannelUpdate_clone(&o_conv);
22817         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22818         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
22819         return (int64_t)ret_conv;
22820 }
22821
22822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22823         LDKDecodeError e_conv;
22824         e_conv.inner = (void*)(e & (~1));
22825         e_conv.is_owned = (e & 1) || (e == 0);
22826         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22827         e_conv = DecodeError_clone(&e_conv);
22828         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22829         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
22830         return (int64_t)ret_conv;
22831 }
22832
22833 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22834         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
22835         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
22836         return ret_conv;
22837 }
22838
22839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22840         if ((_res & 1) != 0) return;
22841         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22842         CHECK_ACCESS(_res_ptr);
22843         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
22844         FREE((void*)_res);
22845         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
22846 }
22847
22848 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
22849         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22850         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
22851         return (int64_t)ret_conv;
22852 }
22853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22854         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
22855         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
22856         return ret_conv;
22857 }
22858
22859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22860         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
22861         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22862         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
22863         return (int64_t)ret_conv;
22864 }
22865
22866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22867         LDKChannelUpdate o_conv;
22868         o_conv.inner = (void*)(o & (~1));
22869         o_conv.is_owned = (o & 1) || (o == 0);
22870         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22871         o_conv = ChannelUpdate_clone(&o_conv);
22872         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22873         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
22874         return (int64_t)ret_conv;
22875 }
22876
22877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22878         LDKDecodeError e_conv;
22879         e_conv.inner = (void*)(e & (~1));
22880         e_conv.is_owned = (e & 1) || (e == 0);
22881         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22882         e_conv = DecodeError_clone(&e_conv);
22883         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22884         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
22885         return (int64_t)ret_conv;
22886 }
22887
22888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22889         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
22890         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
22891         return ret_conv;
22892 }
22893
22894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22895         if ((_res & 1) != 0) return;
22896         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22897         CHECK_ACCESS(_res_ptr);
22898         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
22899         FREE((void*)_res);
22900         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
22901 }
22902
22903 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
22904         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22905         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
22906         return (int64_t)ret_conv;
22907 }
22908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22909         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
22910         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
22911         return ret_conv;
22912 }
22913
22914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22915         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
22916         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22917         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
22918         return (int64_t)ret_conv;
22919 }
22920
22921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22922         LDKErrorMessage o_conv;
22923         o_conv.inner = (void*)(o & (~1));
22924         o_conv.is_owned = (o & 1) || (o == 0);
22925         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22926         o_conv = ErrorMessage_clone(&o_conv);
22927         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22928         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
22929         return (int64_t)ret_conv;
22930 }
22931
22932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22933         LDKDecodeError e_conv;
22934         e_conv.inner = (void*)(e & (~1));
22935         e_conv.is_owned = (e & 1) || (e == 0);
22936         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22937         e_conv = DecodeError_clone(&e_conv);
22938         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22939         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
22940         return (int64_t)ret_conv;
22941 }
22942
22943 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22944         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
22945         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
22946         return ret_conv;
22947 }
22948
22949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22950         if ((_res & 1) != 0) return;
22951         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22952         CHECK_ACCESS(_res_ptr);
22953         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
22954         FREE((void*)_res);
22955         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
22956 }
22957
22958 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
22959         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22960         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
22961         return (int64_t)ret_conv;
22962 }
22963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22964         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
22965         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
22966         return ret_conv;
22967 }
22968
22969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22970         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
22971         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22972         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
22973         return (int64_t)ret_conv;
22974 }
22975
22976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22977         LDKWarningMessage o_conv;
22978         o_conv.inner = (void*)(o & (~1));
22979         o_conv.is_owned = (o & 1) || (o == 0);
22980         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22981         o_conv = WarningMessage_clone(&o_conv);
22982         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22983         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
22984         return (int64_t)ret_conv;
22985 }
22986
22987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22988         LDKDecodeError e_conv;
22989         e_conv.inner = (void*)(e & (~1));
22990         e_conv.is_owned = (e & 1) || (e == 0);
22991         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22992         e_conv = DecodeError_clone(&e_conv);
22993         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22994         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
22995         return (int64_t)ret_conv;
22996 }
22997
22998 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22999         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
23000         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
23001         return ret_conv;
23002 }
23003
23004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23005         if ((_res & 1) != 0) return;
23006         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23007         CHECK_ACCESS(_res_ptr);
23008         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
23009         FREE((void*)_res);
23010         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
23011 }
23012
23013 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
23014         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23015         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
23016         return (int64_t)ret_conv;
23017 }
23018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23019         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
23020         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
23021         return ret_conv;
23022 }
23023
23024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23025         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
23026         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23027         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
23028         return (int64_t)ret_conv;
23029 }
23030
23031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23032         LDKUnsignedNodeAnnouncement o_conv;
23033         o_conv.inner = (void*)(o & (~1));
23034         o_conv.is_owned = (o & 1) || (o == 0);
23035         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23036         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
23037         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23038         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
23039         return (int64_t)ret_conv;
23040 }
23041
23042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23043         LDKDecodeError e_conv;
23044         e_conv.inner = (void*)(e & (~1));
23045         e_conv.is_owned = (e & 1) || (e == 0);
23046         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23047         e_conv = DecodeError_clone(&e_conv);
23048         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23049         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
23050         return (int64_t)ret_conv;
23051 }
23052
23053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23054         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
23055         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
23056         return ret_conv;
23057 }
23058
23059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23060         if ((_res & 1) != 0) return;
23061         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23062         CHECK_ACCESS(_res_ptr);
23063         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
23064         FREE((void*)_res);
23065         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
23066 }
23067
23068 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23069         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23070         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
23071         return (int64_t)ret_conv;
23072 }
23073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23074         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
23075         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23076         return ret_conv;
23077 }
23078
23079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23080         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
23081         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23082         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
23083         return (int64_t)ret_conv;
23084 }
23085
23086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23087         LDKNodeAnnouncement o_conv;
23088         o_conv.inner = (void*)(o & (~1));
23089         o_conv.is_owned = (o & 1) || (o == 0);
23090         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23091         o_conv = NodeAnnouncement_clone(&o_conv);
23092         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23093         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
23094         return (int64_t)ret_conv;
23095 }
23096
23097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23098         LDKDecodeError e_conv;
23099         e_conv.inner = (void*)(e & (~1));
23100         e_conv.is_owned = (e & 1) || (e == 0);
23101         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23102         e_conv = DecodeError_clone(&e_conv);
23103         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23104         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
23105         return (int64_t)ret_conv;
23106 }
23107
23108 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23109         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
23110         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
23111         return ret_conv;
23112 }
23113
23114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23115         if ((_res & 1) != 0) return;
23116         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23117         CHECK_ACCESS(_res_ptr);
23118         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
23119         FREE((void*)_res);
23120         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
23121 }
23122
23123 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23124         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23125         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
23126         return (int64_t)ret_conv;
23127 }
23128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23129         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
23130         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23131         return ret_conv;
23132 }
23133
23134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23135         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
23136         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23137         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
23138         return (int64_t)ret_conv;
23139 }
23140
23141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23142         LDKQueryShortChannelIds o_conv;
23143         o_conv.inner = (void*)(o & (~1));
23144         o_conv.is_owned = (o & 1) || (o == 0);
23145         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23146         o_conv = QueryShortChannelIds_clone(&o_conv);
23147         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23148         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
23149         return (int64_t)ret_conv;
23150 }
23151
23152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23153         LDKDecodeError e_conv;
23154         e_conv.inner = (void*)(e & (~1));
23155         e_conv.is_owned = (e & 1) || (e == 0);
23156         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23157         e_conv = DecodeError_clone(&e_conv);
23158         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23159         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
23160         return (int64_t)ret_conv;
23161 }
23162
23163 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23164         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
23165         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
23166         return ret_conv;
23167 }
23168
23169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23170         if ((_res & 1) != 0) return;
23171         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23172         CHECK_ACCESS(_res_ptr);
23173         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
23174         FREE((void*)_res);
23175         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
23176 }
23177
23178 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
23179         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23180         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
23181         return (int64_t)ret_conv;
23182 }
23183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23184         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
23185         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
23186         return ret_conv;
23187 }
23188
23189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23190         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
23191         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23192         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
23193         return (int64_t)ret_conv;
23194 }
23195
23196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23197         LDKReplyShortChannelIdsEnd o_conv;
23198         o_conv.inner = (void*)(o & (~1));
23199         o_conv.is_owned = (o & 1) || (o == 0);
23200         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23201         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
23202         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23203         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
23204         return (int64_t)ret_conv;
23205 }
23206
23207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23208         LDKDecodeError e_conv;
23209         e_conv.inner = (void*)(e & (~1));
23210         e_conv.is_owned = (e & 1) || (e == 0);
23211         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23212         e_conv = DecodeError_clone(&e_conv);
23213         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23214         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
23215         return (int64_t)ret_conv;
23216 }
23217
23218 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23219         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
23220         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
23221         return ret_conv;
23222 }
23223
23224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23225         if ((_res & 1) != 0) return;
23226         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23227         CHECK_ACCESS(_res_ptr);
23228         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
23229         FREE((void*)_res);
23230         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
23231 }
23232
23233 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
23234         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23235         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
23236         return (int64_t)ret_conv;
23237 }
23238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23239         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
23240         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
23241         return ret_conv;
23242 }
23243
23244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23245         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
23246         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23247         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
23248         return (int64_t)ret_conv;
23249 }
23250
23251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23252         LDKQueryChannelRange o_conv;
23253         o_conv.inner = (void*)(o & (~1));
23254         o_conv.is_owned = (o & 1) || (o == 0);
23255         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23256         o_conv = QueryChannelRange_clone(&o_conv);
23257         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23258         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
23259         return (int64_t)ret_conv;
23260 }
23261
23262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23263         LDKDecodeError e_conv;
23264         e_conv.inner = (void*)(e & (~1));
23265         e_conv.is_owned = (e & 1) || (e == 0);
23266         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23267         e_conv = DecodeError_clone(&e_conv);
23268         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23269         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
23270         return (int64_t)ret_conv;
23271 }
23272
23273 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23274         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
23275         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
23276         return ret_conv;
23277 }
23278
23279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23280         if ((_res & 1) != 0) return;
23281         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23282         CHECK_ACCESS(_res_ptr);
23283         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
23284         FREE((void*)_res);
23285         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
23286 }
23287
23288 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
23289         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23290         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
23291         return (int64_t)ret_conv;
23292 }
23293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23294         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
23295         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
23296         return ret_conv;
23297 }
23298
23299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23300         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
23301         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23302         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
23303         return (int64_t)ret_conv;
23304 }
23305
23306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23307         LDKReplyChannelRange o_conv;
23308         o_conv.inner = (void*)(o & (~1));
23309         o_conv.is_owned = (o & 1) || (o == 0);
23310         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23311         o_conv = ReplyChannelRange_clone(&o_conv);
23312         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23313         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
23314         return (int64_t)ret_conv;
23315 }
23316
23317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23318         LDKDecodeError e_conv;
23319         e_conv.inner = (void*)(e & (~1));
23320         e_conv.is_owned = (e & 1) || (e == 0);
23321         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23322         e_conv = DecodeError_clone(&e_conv);
23323         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23324         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
23325         return (int64_t)ret_conv;
23326 }
23327
23328 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23329         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
23330         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
23331         return ret_conv;
23332 }
23333
23334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23335         if ((_res & 1) != 0) return;
23336         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23337         CHECK_ACCESS(_res_ptr);
23338         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
23339         FREE((void*)_res);
23340         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
23341 }
23342
23343 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
23344         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23345         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
23346         return (int64_t)ret_conv;
23347 }
23348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23349         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
23350         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
23351         return ret_conv;
23352 }
23353
23354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23355         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
23356         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23357         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
23358         return (int64_t)ret_conv;
23359 }
23360
23361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23362         LDKGossipTimestampFilter o_conv;
23363         o_conv.inner = (void*)(o & (~1));
23364         o_conv.is_owned = (o & 1) || (o == 0);
23365         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23366         o_conv = GossipTimestampFilter_clone(&o_conv);
23367         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
23368         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
23369         return (int64_t)ret_conv;
23370 }
23371
23372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23373         LDKDecodeError e_conv;
23374         e_conv.inner = (void*)(e & (~1));
23375         e_conv.is_owned = (e & 1) || (e == 0);
23376         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23377         e_conv = DecodeError_clone(&e_conv);
23378         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
23379         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
23380         return (int64_t)ret_conv;
23381 }
23382
23383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23384         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
23385         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
23386         return ret_conv;
23387 }
23388
23389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23390         if ((_res & 1) != 0) return;
23391         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23392         CHECK_ACCESS(_res_ptr);
23393         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
23394         FREE((void*)_res);
23395         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
23396 }
23397
23398 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
23399         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
23400         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
23401         return (int64_t)ret_conv;
23402 }
23403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23404         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
23405         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
23406         return ret_conv;
23407 }
23408
23409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23410         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
23411         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
23412         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
23413         return (int64_t)ret_conv;
23414 }
23415
23416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23417         LDKCVec_PhantomRouteHintsZ _res_constr;
23418         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23419         if (_res_constr.datalen > 0)
23420                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
23421         else
23422                 _res_constr.data = NULL;
23423         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23424         for (size_t t = 0; t < _res_constr.datalen; t++) {
23425                 int64_t _res_conv_19 = _res_vals[t];
23426                 LDKPhantomRouteHints _res_conv_19_conv;
23427                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
23428                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
23429                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
23430                 _res_constr.data[t] = _res_conv_19_conv;
23431         }
23432         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23433         CVec_PhantomRouteHintsZ_free(_res_constr);
23434 }
23435
23436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23437         LDKInvoice o_conv;
23438         o_conv.inner = (void*)(o & (~1));
23439         o_conv.is_owned = (o & 1) || (o == 0);
23440         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23441         o_conv = Invoice_clone(&o_conv);
23442         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23443         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
23444         return (int64_t)ret_conv;
23445 }
23446
23447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23448         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
23449         CHECK_ACCESS(e_ptr);
23450         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
23451         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
23452         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23453         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
23454         return (int64_t)ret_conv;
23455 }
23456
23457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23458         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
23459         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
23460         return ret_conv;
23461 }
23462
23463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23464         if ((_res & 1) != 0) return;
23465         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23466         CHECK_ACCESS(_res_ptr);
23467         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
23468         FREE((void*)_res);
23469         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
23470 }
23471
23472 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
23473         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23474         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
23475         return (int64_t)ret_conv;
23476 }
23477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23478         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
23479         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
23480         return ret_conv;
23481 }
23482
23483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23484         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
23485         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23486         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
23487         return (int64_t)ret_conv;
23488 }
23489
23490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23491         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
23492         CHECK_ACCESS(o_ptr);
23493         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
23494         if (o_conv.free == LDKFilter_JCalls_free) {
23495                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23496                 LDKFilter_JCalls_cloned(&o_conv);
23497         }
23498         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
23499         *ret_copy = COption_FilterZ_some(o_conv);
23500         int64_t ret_ref = (uintptr_t)ret_copy;
23501         return ret_ref;
23502 }
23503
23504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
23505         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
23506         *ret_copy = COption_FilterZ_none();
23507         int64_t ret_ref = (uintptr_t)ret_copy;
23508         return ret_ref;
23509 }
23510
23511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23512         if ((_res & 1) != 0) return;
23513         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23514         CHECK_ACCESS(_res_ptr);
23515         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
23516         FREE((void*)_res);
23517         COption_FilterZ_free(_res_conv);
23518 }
23519
23520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23521         LDKLockedChannelMonitor o_conv;
23522         o_conv.inner = (void*)(o & (~1));
23523         o_conv.is_owned = (o & 1) || (o == 0);
23524         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23525         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
23526         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23527         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
23528         return (int64_t)ret_conv;
23529 }
23530
23531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
23532         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23533         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
23534         return (int64_t)ret_conv;
23535 }
23536
23537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23538         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
23539         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
23540         return ret_conv;
23541 }
23542
23543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23544         if ((_res & 1) != 0) return;
23545         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23546         CHECK_ACCESS(_res_ptr);
23547         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
23548         FREE((void*)_res);
23549         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
23550 }
23551
23552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23553         LDKCVec_OutPointZ _res_constr;
23554         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23555         if (_res_constr.datalen > 0)
23556                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
23557         else
23558                 _res_constr.data = NULL;
23559         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23560         for (size_t k = 0; k < _res_constr.datalen; k++) {
23561                 int64_t _res_conv_10 = _res_vals[k];
23562                 LDKOutPoint _res_conv_10_conv;
23563                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
23564                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
23565                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
23566                 _res_constr.data[k] = _res_conv_10_conv;
23567         }
23568         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23569         CVec_OutPointZ_free(_res_constr);
23570 }
23571
23572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23573         if ((this_ptr & 1) != 0) return;
23574         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23575         CHECK_ACCESS(this_ptr_ptr);
23576         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
23577         FREE((void*)this_ptr);
23578         PaymentPurpose_free(this_ptr_conv);
23579 }
23580
23581 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
23582         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23583         *ret_copy = PaymentPurpose_clone(arg);
23584 int64_t ret_ref = (uintptr_t)ret_copy;
23585         return ret_ref;
23586 }
23587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23588         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
23589         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
23590         return ret_conv;
23591 }
23592
23593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23594         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
23595         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23596         *ret_copy = PaymentPurpose_clone(orig_conv);
23597         int64_t ret_ref = (uintptr_t)ret_copy;
23598         return ret_ref;
23599 }
23600
23601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
23602         LDKThirtyTwoBytes payment_preimage_ref;
23603         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
23604         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
23605         LDKThirtyTwoBytes payment_secret_ref;
23606         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
23607         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
23608         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23609         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
23610         int64_t ret_ref = (uintptr_t)ret_copy;
23611         return ret_ref;
23612 }
23613
23614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
23615         LDKThirtyTwoBytes a_ref;
23616         CHECK((*env)->GetArrayLength(env, a) == 32);
23617         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23618         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23619         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
23620         int64_t ret_ref = (uintptr_t)ret_copy;
23621         return ret_ref;
23622 }
23623
23624 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
23625         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)obj;
23626         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
23627         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23628         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23629         CVec_u8Z_free(ret_var);
23630         return ret_arr;
23631 }
23632
23633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23634         LDKu8slice ser_ref;
23635         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23636         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23637         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
23638         *ret_conv = PaymentPurpose_read(ser_ref);
23639         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23640         return (int64_t)ret_conv;
23641 }
23642
23643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23644         if ((this_ptr & 1) != 0) return;
23645         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23646         CHECK_ACCESS(this_ptr_ptr);
23647         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
23648         FREE((void*)this_ptr);
23649         ClosureReason_free(this_ptr_conv);
23650 }
23651
23652 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
23653         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23654         *ret_copy = ClosureReason_clone(arg);
23655 int64_t ret_ref = (uintptr_t)ret_copy;
23656         return ret_ref;
23657 }
23658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23659         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
23660         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
23661         return ret_conv;
23662 }
23663
23664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23665         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
23666         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23667         *ret_copy = ClosureReason_clone(orig_conv);
23668         int64_t ret_ref = (uintptr_t)ret_copy;
23669         return ret_ref;
23670 }
23671
23672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
23673         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
23674         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23675         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
23676         int64_t ret_ref = (uintptr_t)ret_copy;
23677         return ret_ref;
23678 }
23679
23680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
23681         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23682         *ret_copy = ClosureReason_holder_force_closed();
23683         int64_t ret_ref = (uintptr_t)ret_copy;
23684         return ret_ref;
23685 }
23686
23687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
23688         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23689         *ret_copy = ClosureReason_cooperative_closure();
23690         int64_t ret_ref = (uintptr_t)ret_copy;
23691         return ret_ref;
23692 }
23693
23694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
23695         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23696         *ret_copy = ClosureReason_commitment_tx_confirmed();
23697         int64_t ret_ref = (uintptr_t)ret_copy;
23698         return ret_ref;
23699 }
23700
23701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
23702         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23703         *ret_copy = ClosureReason_funding_timed_out();
23704         int64_t ret_ref = (uintptr_t)ret_copy;
23705         return ret_ref;
23706 }
23707
23708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
23709         LDKStr err_conv = java_to_owned_str(env, err);
23710         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23711         *ret_copy = ClosureReason_processing_error(err_conv);
23712         int64_t ret_ref = (uintptr_t)ret_copy;
23713         return ret_ref;
23714 }
23715
23716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
23717         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23718         *ret_copy = ClosureReason_disconnected_peer();
23719         int64_t ret_ref = (uintptr_t)ret_copy;
23720         return ret_ref;
23721 }
23722
23723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
23724         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23725         *ret_copy = ClosureReason_outdated_channel_manager();
23726         int64_t ret_ref = (uintptr_t)ret_copy;
23727         return ret_ref;
23728 }
23729
23730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
23731         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
23732         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
23733         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23734         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23735         CVec_u8Z_free(ret_var);
23736         return ret_arr;
23737 }
23738
23739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23740         LDKu8slice ser_ref;
23741         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23742         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23743         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
23744         *ret_conv = ClosureReason_read(ser_ref);
23745         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23746         return (int64_t)ret_conv;
23747 }
23748
23749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23750         if ((this_ptr & 1) != 0) return;
23751         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23752         CHECK_ACCESS(this_ptr_ptr);
23753         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
23754         FREE((void*)this_ptr);
23755         Event_free(this_ptr_conv);
23756 }
23757
23758 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
23759         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23760         *ret_copy = Event_clone(arg);
23761 int64_t ret_ref = (uintptr_t)ret_copy;
23762         return ret_ref;
23763 }
23764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23765         LDKEvent* arg_conv = (LDKEvent*)arg;
23766         int64_t ret_conv = Event_clone_ptr(arg_conv);
23767         return ret_conv;
23768 }
23769
23770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23771         LDKEvent* orig_conv = (LDKEvent*)orig;
23772         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23773         *ret_copy = Event_clone(orig_conv);
23774         int64_t ret_ref = (uintptr_t)ret_copy;
23775         return ret_ref;
23776 }
23777
23778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
23779         LDKThirtyTwoBytes temporary_channel_id_ref;
23780         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
23781         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
23782         LDKPublicKey counterparty_node_id_ref;
23783         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
23784         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
23785         LDKCVec_u8Z output_script_ref;
23786         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
23787         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
23788         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
23789         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23790         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
23791         int64_t ret_ref = (uintptr_t)ret_copy;
23792         return ret_ref;
23793 }
23794
23795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose) {
23796         LDKThirtyTwoBytes payment_hash_ref;
23797         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23798         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23799         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
23800         CHECK_ACCESS(purpose_ptr);
23801         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
23802         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
23803         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23804         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
23805         int64_t ret_ref = (uintptr_t)ret_copy;
23806         return ret_ref;
23807 }
23808
23809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1claimed(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose) {
23810         LDKThirtyTwoBytes payment_hash_ref;
23811         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23812         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23813         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
23814         CHECK_ACCESS(purpose_ptr);
23815         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
23816         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
23817         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23818         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
23819         int64_t ret_ref = (uintptr_t)ret_copy;
23820         return ret_ref;
23821 }
23822
23823 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) {
23824         LDKThirtyTwoBytes payment_id_ref;
23825         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23826         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23827         LDKThirtyTwoBytes payment_preimage_ref;
23828         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
23829         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
23830         LDKThirtyTwoBytes payment_hash_ref;
23831         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23832         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23833         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
23834         CHECK_ACCESS(fee_paid_msat_ptr);
23835         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
23836         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
23837         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23838         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
23839         int64_t ret_ref = (uintptr_t)ret_copy;
23840         return ret_ref;
23841 }
23842
23843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
23844         LDKThirtyTwoBytes payment_id_ref;
23845         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23846         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23847         LDKThirtyTwoBytes payment_hash_ref;
23848         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23849         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23850         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23851         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
23852         int64_t ret_ref = (uintptr_t)ret_copy;
23853         return ret_ref;
23854 }
23855
23856 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) {
23857         LDKThirtyTwoBytes payment_id_ref;
23858         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23859         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23860         LDKThirtyTwoBytes payment_hash_ref;
23861         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23862         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23863         LDKCVec_RouteHopZ path_constr;
23864         path_constr.datalen = (*env)->GetArrayLength(env, path);
23865         if (path_constr.datalen > 0)
23866                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23867         else
23868                 path_constr.data = NULL;
23869         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
23870         for (size_t k = 0; k < path_constr.datalen; k++) {
23871                 int64_t path_conv_10 = path_vals[k];
23872                 LDKRouteHop path_conv_10_conv;
23873                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
23874                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
23875                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
23876                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
23877                 path_constr.data[k] = path_conv_10_conv;
23878         }
23879         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
23880         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23881         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
23882         int64_t ret_ref = (uintptr_t)ret_copy;
23883         return ret_ref;
23884 }
23885
23886 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) {
23887         LDKThirtyTwoBytes payment_id_ref;
23888         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23889         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23890         LDKThirtyTwoBytes payment_hash_ref;
23891         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23892         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23893         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
23894         CHECK_ACCESS(network_update_ptr);
23895         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
23896         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
23897         LDKCVec_RouteHopZ path_constr;
23898         path_constr.datalen = (*env)->GetArrayLength(env, path);
23899         if (path_constr.datalen > 0)
23900                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23901         else
23902                 path_constr.data = NULL;
23903         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
23904         for (size_t k = 0; k < path_constr.datalen; k++) {
23905                 int64_t path_conv_10 = path_vals[k];
23906                 LDKRouteHop path_conv_10_conv;
23907                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
23908                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
23909                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
23910                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
23911                 path_constr.data[k] = path_conv_10_conv;
23912         }
23913         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
23914         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
23915         CHECK_ACCESS(short_channel_id_ptr);
23916         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
23917         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
23918         LDKRouteParameters retry_conv;
23919         retry_conv.inner = (void*)(retry & (~1));
23920         retry_conv.is_owned = (retry & 1) || (retry == 0);
23921         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
23922         retry_conv = RouteParameters_clone(&retry_conv);
23923         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23924         *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);
23925         int64_t ret_ref = (uintptr_t)ret_copy;
23926         return ret_ref;
23927 }
23928
23929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
23930         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23931         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
23932         int64_t ret_ref = (uintptr_t)ret_copy;
23933         return ret_ref;
23934 }
23935
23936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
23937         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
23938         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
23939         if (outputs_constr.datalen > 0)
23940                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23941         else
23942                 outputs_constr.data = NULL;
23943         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
23944         for (size_t b = 0; b < outputs_constr.datalen; b++) {
23945                 int64_t outputs_conv_27 = outputs_vals[b];
23946                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
23947                 CHECK_ACCESS(outputs_conv_27_ptr);
23948                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
23949                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
23950                 outputs_constr.data[b] = outputs_conv_27_conv;
23951         }
23952         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
23953         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23954         *ret_copy = Event_spendable_outputs(outputs_constr);
23955         int64_t ret_ref = (uintptr_t)ret_copy;
23956         return ret_ref;
23957 }
23958
23959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int8_tArray prev_channel_id, int8_tArray next_channel_id, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
23960         LDKThirtyTwoBytes prev_channel_id_ref;
23961         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
23962         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
23963         LDKThirtyTwoBytes next_channel_id_ref;
23964         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
23965         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
23966         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
23967         CHECK_ACCESS(fee_earned_msat_ptr);
23968         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
23969         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
23970         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23971         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
23972         int64_t ret_ref = (uintptr_t)ret_copy;
23973         return ret_ref;
23974 }
23975
23976 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) {
23977         LDKThirtyTwoBytes channel_id_ref;
23978         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
23979         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
23980         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
23981         CHECK_ACCESS(reason_ptr);
23982         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
23983         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
23984         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23985         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
23986         int64_t ret_ref = (uintptr_t)ret_copy;
23987         return ret_ref;
23988 }
23989
23990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
23991         LDKThirtyTwoBytes channel_id_ref;
23992         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
23993         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
23994         LDKTransaction transaction_ref;
23995         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
23996         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
23997         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
23998         transaction_ref.data_is_owned = true;
23999         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24000         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
24001         int64_t ret_ref = (uintptr_t)ret_copy;
24002         return ret_ref;
24003 }
24004
24005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1open_1channel_1request(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t funding_satoshis, int64_t push_msat, int64_t channel_type) {
24006         LDKThirtyTwoBytes temporary_channel_id_ref;
24007         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
24008         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
24009         LDKPublicKey counterparty_node_id_ref;
24010         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
24011         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
24012         LDKChannelTypeFeatures channel_type_conv;
24013         channel_type_conv.inner = (void*)(channel_type & (~1));
24014         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
24015         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
24016         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
24017         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24018         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
24019         int64_t ret_ref = (uintptr_t)ret_copy;
24020         return ret_ref;
24021 }
24022
24023 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
24024         LDKEvent* obj_conv = (LDKEvent*)obj;
24025         LDKCVec_u8Z ret_var = Event_write(obj_conv);
24026         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24027         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24028         CVec_u8Z_free(ret_var);
24029         return ret_arr;
24030 }
24031
24032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24033         LDKu8slice ser_ref;
24034         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24035         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24036         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
24037         *ret_conv = Event_read(ser_ref);
24038         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24039         return (int64_t)ret_conv;
24040 }
24041
24042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24043         if ((this_ptr & 1) != 0) return;
24044         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24045         CHECK_ACCESS(this_ptr_ptr);
24046         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
24047         FREE((void*)this_ptr);
24048         MessageSendEvent_free(this_ptr_conv);
24049 }
24050
24051 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
24052         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24053         *ret_copy = MessageSendEvent_clone(arg);
24054 int64_t ret_ref = (uintptr_t)ret_copy;
24055         return ret_ref;
24056 }
24057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24058         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
24059         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
24060         return ret_conv;
24061 }
24062
24063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24064         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
24065         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24066         *ret_copy = MessageSendEvent_clone(orig_conv);
24067         int64_t ret_ref = (uintptr_t)ret_copy;
24068         return ret_ref;
24069 }
24070
24071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24072         LDKPublicKey node_id_ref;
24073         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24074         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24075         LDKAcceptChannel msg_conv;
24076         msg_conv.inner = (void*)(msg & (~1));
24077         msg_conv.is_owned = (msg & 1) || (msg == 0);
24078         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24079         msg_conv = AcceptChannel_clone(&msg_conv);
24080         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24081         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
24082         int64_t ret_ref = (uintptr_t)ret_copy;
24083         return ret_ref;
24084 }
24085
24086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24087         LDKPublicKey node_id_ref;
24088         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24089         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24090         LDKOpenChannel msg_conv;
24091         msg_conv.inner = (void*)(msg & (~1));
24092         msg_conv.is_owned = (msg & 1) || (msg == 0);
24093         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24094         msg_conv = OpenChannel_clone(&msg_conv);
24095         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24096         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
24097         int64_t ret_ref = (uintptr_t)ret_copy;
24098         return ret_ref;
24099 }
24100
24101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24102         LDKPublicKey node_id_ref;
24103         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24104         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24105         LDKFundingCreated msg_conv;
24106         msg_conv.inner = (void*)(msg & (~1));
24107         msg_conv.is_owned = (msg & 1) || (msg == 0);
24108         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24109         msg_conv = FundingCreated_clone(&msg_conv);
24110         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24111         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
24112         int64_t ret_ref = (uintptr_t)ret_copy;
24113         return ret_ref;
24114 }
24115
24116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24117         LDKPublicKey node_id_ref;
24118         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24119         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24120         LDKFundingSigned msg_conv;
24121         msg_conv.inner = (void*)(msg & (~1));
24122         msg_conv.is_owned = (msg & 1) || (msg == 0);
24123         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24124         msg_conv = FundingSigned_clone(&msg_conv);
24125         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24126         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
24127         int64_t ret_ref = (uintptr_t)ret_copy;
24128         return ret_ref;
24129 }
24130
24131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24132         LDKPublicKey node_id_ref;
24133         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24134         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24135         LDKChannelReady msg_conv;
24136         msg_conv.inner = (void*)(msg & (~1));
24137         msg_conv.is_owned = (msg & 1) || (msg == 0);
24138         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24139         msg_conv = ChannelReady_clone(&msg_conv);
24140         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24141         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
24142         int64_t ret_ref = (uintptr_t)ret_copy;
24143         return ret_ref;
24144 }
24145
24146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24147         LDKPublicKey node_id_ref;
24148         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24149         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24150         LDKAnnouncementSignatures msg_conv;
24151         msg_conv.inner = (void*)(msg & (~1));
24152         msg_conv.is_owned = (msg & 1) || (msg == 0);
24153         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24154         msg_conv = AnnouncementSignatures_clone(&msg_conv);
24155         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24156         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
24157         int64_t ret_ref = (uintptr_t)ret_copy;
24158         return ret_ref;
24159 }
24160
24161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
24162         LDKPublicKey node_id_ref;
24163         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24164         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24165         LDKCommitmentUpdate updates_conv;
24166         updates_conv.inner = (void*)(updates & (~1));
24167         updates_conv.is_owned = (updates & 1) || (updates == 0);
24168         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
24169         updates_conv = CommitmentUpdate_clone(&updates_conv);
24170         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24171         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
24172         int64_t ret_ref = (uintptr_t)ret_copy;
24173         return ret_ref;
24174 }
24175
24176 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) {
24177         LDKPublicKey node_id_ref;
24178         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24179         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24180         LDKRevokeAndACK msg_conv;
24181         msg_conv.inner = (void*)(msg & (~1));
24182         msg_conv.is_owned = (msg & 1) || (msg == 0);
24183         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24184         msg_conv = RevokeAndACK_clone(&msg_conv);
24185         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24186         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
24187         int64_t ret_ref = (uintptr_t)ret_copy;
24188         return ret_ref;
24189 }
24190
24191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24192         LDKPublicKey node_id_ref;
24193         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24194         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24195         LDKClosingSigned msg_conv;
24196         msg_conv.inner = (void*)(msg & (~1));
24197         msg_conv.is_owned = (msg & 1) || (msg == 0);
24198         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24199         msg_conv = ClosingSigned_clone(&msg_conv);
24200         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24201         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
24202         int64_t ret_ref = (uintptr_t)ret_copy;
24203         return ret_ref;
24204 }
24205
24206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24207         LDKPublicKey node_id_ref;
24208         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24209         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24210         LDKShutdown msg_conv;
24211         msg_conv.inner = (void*)(msg & (~1));
24212         msg_conv.is_owned = (msg & 1) || (msg == 0);
24213         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24214         msg_conv = Shutdown_clone(&msg_conv);
24215         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24216         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
24217         int64_t ret_ref = (uintptr_t)ret_copy;
24218         return ret_ref;
24219 }
24220
24221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24222         LDKPublicKey node_id_ref;
24223         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24224         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24225         LDKChannelReestablish msg_conv;
24226         msg_conv.inner = (void*)(msg & (~1));
24227         msg_conv.is_owned = (msg & 1) || (msg == 0);
24228         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24229         msg_conv = ChannelReestablish_clone(&msg_conv);
24230         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24231         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
24232         int64_t ret_ref = (uintptr_t)ret_copy;
24233         return ret_ref;
24234 }
24235
24236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
24237         LDKChannelAnnouncement msg_conv;
24238         msg_conv.inner = (void*)(msg & (~1));
24239         msg_conv.is_owned = (msg & 1) || (msg == 0);
24240         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24241         msg_conv = ChannelAnnouncement_clone(&msg_conv);
24242         LDKChannelUpdate update_msg_conv;
24243         update_msg_conv.inner = (void*)(update_msg & (~1));
24244         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
24245         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
24246         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
24247         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24248         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
24249         int64_t ret_ref = (uintptr_t)ret_copy;
24250         return ret_ref;
24251 }
24252
24253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
24254         LDKNodeAnnouncement msg_conv;
24255         msg_conv.inner = (void*)(msg & (~1));
24256         msg_conv.is_owned = (msg & 1) || (msg == 0);
24257         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24258         msg_conv = NodeAnnouncement_clone(&msg_conv);
24259         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24260         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
24261         int64_t ret_ref = (uintptr_t)ret_copy;
24262         return ret_ref;
24263 }
24264
24265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
24266         LDKChannelUpdate msg_conv;
24267         msg_conv.inner = (void*)(msg & (~1));
24268         msg_conv.is_owned = (msg & 1) || (msg == 0);
24269         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24270         msg_conv = ChannelUpdate_clone(&msg_conv);
24271         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24272         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
24273         int64_t ret_ref = (uintptr_t)ret_copy;
24274         return ret_ref;
24275 }
24276
24277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24278         LDKPublicKey node_id_ref;
24279         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24280         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24281         LDKChannelUpdate msg_conv;
24282         msg_conv.inner = (void*)(msg & (~1));
24283         msg_conv.is_owned = (msg & 1) || (msg == 0);
24284         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24285         msg_conv = ChannelUpdate_clone(&msg_conv);
24286         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24287         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
24288         int64_t ret_ref = (uintptr_t)ret_copy;
24289         return ret_ref;
24290 }
24291
24292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
24293         LDKPublicKey node_id_ref;
24294         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24295         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24296         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
24297         CHECK_ACCESS(action_ptr);
24298         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
24299         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
24300         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24301         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
24302         int64_t ret_ref = (uintptr_t)ret_copy;
24303         return ret_ref;
24304 }
24305
24306 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) {
24307         LDKPublicKey node_id_ref;
24308         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24309         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24310         LDKQueryChannelRange msg_conv;
24311         msg_conv.inner = (void*)(msg & (~1));
24312         msg_conv.is_owned = (msg & 1) || (msg == 0);
24313         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24314         msg_conv = QueryChannelRange_clone(&msg_conv);
24315         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24316         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
24317         int64_t ret_ref = (uintptr_t)ret_copy;
24318         return ret_ref;
24319 }
24320
24321 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) {
24322         LDKPublicKey node_id_ref;
24323         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24324         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24325         LDKQueryShortChannelIds msg_conv;
24326         msg_conv.inner = (void*)(msg & (~1));
24327         msg_conv.is_owned = (msg & 1) || (msg == 0);
24328         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24329         msg_conv = QueryShortChannelIds_clone(&msg_conv);
24330         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24331         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
24332         int64_t ret_ref = (uintptr_t)ret_copy;
24333         return ret_ref;
24334 }
24335
24336 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) {
24337         LDKPublicKey node_id_ref;
24338         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24339         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24340         LDKReplyChannelRange msg_conv;
24341         msg_conv.inner = (void*)(msg & (~1));
24342         msg_conv.is_owned = (msg & 1) || (msg == 0);
24343         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24344         msg_conv = ReplyChannelRange_clone(&msg_conv);
24345         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24346         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
24347         int64_t ret_ref = (uintptr_t)ret_copy;
24348         return ret_ref;
24349 }
24350
24351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1gossip_1timestamp_1filter(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24352         LDKPublicKey node_id_ref;
24353         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24354         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24355         LDKGossipTimestampFilter msg_conv;
24356         msg_conv.inner = (void*)(msg & (~1));
24357         msg_conv.is_owned = (msg & 1) || (msg == 0);
24358         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24359         msg_conv = GossipTimestampFilter_clone(&msg_conv);
24360         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24361         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
24362         int64_t ret_ref = (uintptr_t)ret_copy;
24363         return ret_ref;
24364 }
24365
24366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24367         if ((this_ptr & 1) != 0) return;
24368         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24369         CHECK_ACCESS(this_ptr_ptr);
24370         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
24371         FREE((void*)this_ptr);
24372         MessageSendEventsProvider_free(this_ptr_conv);
24373 }
24374
24375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24376         if ((this_ptr & 1) != 0) return;
24377         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24378         CHECK_ACCESS(this_ptr_ptr);
24379         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
24380         FREE((void*)this_ptr);
24381         EventsProvider_free(this_ptr_conv);
24382 }
24383
24384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24385         if ((this_ptr & 1) != 0) return;
24386         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24387         CHECK_ACCESS(this_ptr_ptr);
24388         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
24389         FREE((void*)this_ptr);
24390         EventHandler_free(this_ptr_conv);
24391 }
24392
24393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24394         if ((this_ptr & 1) != 0) return;
24395         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24396         CHECK_ACCESS(this_ptr_ptr);
24397         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
24398         FREE((void*)this_ptr);
24399         APIError_free(this_ptr_conv);
24400 }
24401
24402 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
24403         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24404         *ret_copy = APIError_clone(arg);
24405 int64_t ret_ref = (uintptr_t)ret_copy;
24406         return ret_ref;
24407 }
24408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24409         LDKAPIError* arg_conv = (LDKAPIError*)arg;
24410         int64_t ret_conv = APIError_clone_ptr(arg_conv);
24411         return ret_conv;
24412 }
24413
24414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24415         LDKAPIError* orig_conv = (LDKAPIError*)orig;
24416         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24417         *ret_copy = APIError_clone(orig_conv);
24418         int64_t ret_ref = (uintptr_t)ret_copy;
24419         return ret_ref;
24420 }
24421
24422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
24423         LDKStr err_conv = java_to_owned_str(env, err);
24424         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24425         *ret_copy = APIError_apimisuse_error(err_conv);
24426         int64_t ret_ref = (uintptr_t)ret_copy;
24427         return ret_ref;
24428 }
24429
24430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
24431         LDKStr err_conv = java_to_owned_str(env, err);
24432         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24433         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
24434         int64_t ret_ref = (uintptr_t)ret_copy;
24435         return ret_ref;
24436 }
24437
24438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
24439         LDKStr err_conv = java_to_owned_str(env, err);
24440         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24441         *ret_copy = APIError_route_error(err_conv);
24442         int64_t ret_ref = (uintptr_t)ret_copy;
24443         return ret_ref;
24444 }
24445
24446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
24447         LDKStr err_conv = java_to_owned_str(env, err);
24448         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24449         *ret_copy = APIError_channel_unavailable(err_conv);
24450         int64_t ret_ref = (uintptr_t)ret_copy;
24451         return ret_ref;
24452 }
24453
24454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
24455         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24456         *ret_copy = APIError_monitor_update_failed();
24457         int64_t ret_ref = (uintptr_t)ret_copy;
24458         return ret_ref;
24459 }
24460
24461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
24462         LDKShutdownScript script_conv;
24463         script_conv.inner = (void*)(script & (~1));
24464         script_conv.is_owned = (script & 1) || (script == 0);
24465         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
24466         script_conv = ShutdownScript_clone(&script_conv);
24467         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24468         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
24469         int64_t ret_ref = (uintptr_t)ret_copy;
24470         return ret_ref;
24471 }
24472
24473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24474         LDKBigSize this_obj_conv;
24475         this_obj_conv.inner = (void*)(this_obj & (~1));
24476         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24478         BigSize_free(this_obj_conv);
24479 }
24480
24481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
24482         LDKBigSize this_ptr_conv;
24483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24484         this_ptr_conv.is_owned = false;
24485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24486         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
24487         return ret_conv;
24488 }
24489
24490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24491         LDKBigSize this_ptr_conv;
24492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24493         this_ptr_conv.is_owned = false;
24494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24495         BigSize_set_a(&this_ptr_conv, val);
24496 }
24497
24498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
24499         LDKBigSize ret_var = BigSize_new(a_arg);
24500         int64_t ret_ref = 0;
24501         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24502         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24504         ret_ref = (uintptr_t)ret_var.inner;
24505         if (ret_var.is_owned) {
24506                 ret_ref |= 1;
24507         }
24508         return ret_ref;
24509 }
24510
24511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
24512         LDKu8slice msg_ref;
24513         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
24514         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
24515         unsigned char sk_arr[32];
24516         CHECK((*env)->GetArrayLength(env, sk) == 32);
24517         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
24518         unsigned char (*sk_ref)[32] = &sk_arr;
24519         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
24520         *ret_conv = sign(msg_ref, sk_ref);
24521         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24522         return (int64_t)ret_conv;
24523 }
24524
24525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
24526         LDKu8slice msg_ref;
24527         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
24528         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
24529         LDKStr sig_conv = java_to_owned_str(env, sig);
24530         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
24531         *ret_conv = recover_pk(msg_ref, sig_conv);
24532         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24533         return (int64_t)ret_conv;
24534 }
24535
24536 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
24537         LDKu8slice msg_ref;
24538         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
24539         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
24540         LDKStr sig_conv = java_to_owned_str(env, sig);
24541         LDKPublicKey pk_ref;
24542         CHECK((*env)->GetArrayLength(env, pk) == 33);
24543         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
24544         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
24545         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24546         return ret_conv;
24547 }
24548
24549 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
24550         LDKu8slice hrp_bytes_ref;
24551         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
24552         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
24553         LDKCVec_u5Z data_without_signature_constr;
24554         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
24555         if (data_without_signature_constr.datalen > 0)
24556                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
24557         else
24558                 data_without_signature_constr.data = NULL;
24559         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
24560         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
24561                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
24562                 
24563                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
24564         }
24565         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
24566         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
24567         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24568         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24569         CVec_u8Z_free(ret_var);
24570         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
24571         return ret_arr;
24572 }
24573
24574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24575         if ((this_ptr & 1) != 0) return;
24576         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24577         CHECK_ACCESS(this_ptr_ptr);
24578         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
24579         FREE((void*)this_ptr);
24580         Persister_free(this_ptr_conv);
24581 }
24582
24583 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24584         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
24585         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
24586         return ret_conv;
24587 }
24588
24589 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
24590         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
24591         return ret_conv;
24592 }
24593
24594 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
24595         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
24596         return ret_conv;
24597 }
24598
24599 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
24600         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
24601         return ret_conv;
24602 }
24603
24604 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
24605         jclass ret_conv = LDKLevel_to_java(env, Level_info());
24606         return ret_conv;
24607 }
24608
24609 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
24610         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
24611         return ret_conv;
24612 }
24613
24614 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
24615         jclass ret_conv = LDKLevel_to_java(env, Level_error());
24616         return ret_conv;
24617 }
24618
24619 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24620         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
24621         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
24622         jboolean ret_conv = Level_eq(a_conv, b_conv);
24623         return ret_conv;
24624 }
24625
24626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
24627         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
24628         int64_t ret_conv = Level_hash(o_conv);
24629         return ret_conv;
24630 }
24631
24632 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
24633         jclass ret_conv = LDKLevel_to_java(env, Level_max());
24634         return ret_conv;
24635 }
24636
24637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24638         LDKRecord this_obj_conv;
24639         this_obj_conv.inner = (void*)(this_obj & (~1));
24640         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24642         Record_free(this_obj_conv);
24643 }
24644
24645 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
24646         LDKRecord this_ptr_conv;
24647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24648         this_ptr_conv.is_owned = false;
24649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24650         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
24651         return ret_conv;
24652 }
24653
24654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
24655         LDKRecord this_ptr_conv;
24656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24657         this_ptr_conv.is_owned = false;
24658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24659         LDKLevel val_conv = LDKLevel_from_java(env, val);
24660         Record_set_level(&this_ptr_conv, val_conv);
24661 }
24662
24663 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
24664         LDKRecord this_ptr_conv;
24665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24666         this_ptr_conv.is_owned = false;
24667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24668         LDKStr ret_str = Record_get_args(&this_ptr_conv);
24669         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24670         Str_free(ret_str);
24671         return ret_conv;
24672 }
24673
24674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24675         LDKRecord this_ptr_conv;
24676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24677         this_ptr_conv.is_owned = false;
24678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24679         LDKStr val_conv = java_to_owned_str(env, val);
24680         Record_set_args(&this_ptr_conv, val_conv);
24681 }
24682
24683 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
24684         LDKRecord this_ptr_conv;
24685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24686         this_ptr_conv.is_owned = false;
24687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24688         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
24689         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24690         Str_free(ret_str);
24691         return ret_conv;
24692 }
24693
24694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24695         LDKRecord this_ptr_conv;
24696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24697         this_ptr_conv.is_owned = false;
24698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24699         LDKStr val_conv = java_to_owned_str(env, val);
24700         Record_set_module_path(&this_ptr_conv, val_conv);
24701 }
24702
24703 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
24704         LDKRecord this_ptr_conv;
24705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24706         this_ptr_conv.is_owned = false;
24707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24708         LDKStr ret_str = Record_get_file(&this_ptr_conv);
24709         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24710         Str_free(ret_str);
24711         return ret_conv;
24712 }
24713
24714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24715         LDKRecord this_ptr_conv;
24716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24717         this_ptr_conv.is_owned = false;
24718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24719         LDKStr val_conv = java_to_owned_str(env, val);
24720         Record_set_file(&this_ptr_conv, val_conv);
24721 }
24722
24723 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
24724         LDKRecord this_ptr_conv;
24725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24726         this_ptr_conv.is_owned = false;
24727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24728         int32_t ret_conv = Record_get_line(&this_ptr_conv);
24729         return ret_conv;
24730 }
24731
24732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24733         LDKRecord this_ptr_conv;
24734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24735         this_ptr_conv.is_owned = false;
24736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24737         Record_set_line(&this_ptr_conv, val);
24738 }
24739
24740 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
24741         LDKRecord ret_var = Record_clone(arg);
24742 int64_t ret_ref = 0;
24743 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24744 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24745 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24746 ret_ref = (uintptr_t)ret_var.inner;
24747 if (ret_var.is_owned) {
24748         ret_ref |= 1;
24749 }
24750         return ret_ref;
24751 }
24752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24753         LDKRecord arg_conv;
24754         arg_conv.inner = (void*)(arg & (~1));
24755         arg_conv.is_owned = false;
24756         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24757         int64_t ret_conv = Record_clone_ptr(&arg_conv);
24758         return ret_conv;
24759 }
24760
24761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24762         LDKRecord orig_conv;
24763         orig_conv.inner = (void*)(orig & (~1));
24764         orig_conv.is_owned = false;
24765         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24766         LDKRecord ret_var = Record_clone(&orig_conv);
24767         int64_t ret_ref = 0;
24768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24771         ret_ref = (uintptr_t)ret_var.inner;
24772         if (ret_var.is_owned) {
24773                 ret_ref |= 1;
24774         }
24775         return ret_ref;
24776 }
24777
24778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24779         if ((this_ptr & 1) != 0) return;
24780         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24781         CHECK_ACCESS(this_ptr_ptr);
24782         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
24783         FREE((void*)this_ptr);
24784         Logger_free(this_ptr_conv);
24785 }
24786
24787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24788         LDKChannelHandshakeConfig this_obj_conv;
24789         this_obj_conv.inner = (void*)(this_obj & (~1));
24790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24792         ChannelHandshakeConfig_free(this_obj_conv);
24793 }
24794
24795 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
24796         LDKChannelHandshakeConfig this_ptr_conv;
24797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24798         this_ptr_conv.is_owned = false;
24799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24800         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
24801         return ret_conv;
24802 }
24803
24804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24805         LDKChannelHandshakeConfig this_ptr_conv;
24806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24807         this_ptr_conv.is_owned = false;
24808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24809         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
24810 }
24811
24812 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
24813         LDKChannelHandshakeConfig this_ptr_conv;
24814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24815         this_ptr_conv.is_owned = false;
24816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24817         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
24818         return ret_conv;
24819 }
24820
24821 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) {
24822         LDKChannelHandshakeConfig this_ptr_conv;
24823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24824         this_ptr_conv.is_owned = false;
24825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24826         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
24827 }
24828
24829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24830         LDKChannelHandshakeConfig this_ptr_conv;
24831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24832         this_ptr_conv.is_owned = false;
24833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24834         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
24835         return ret_conv;
24836 }
24837
24838 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) {
24839         LDKChannelHandshakeConfig this_ptr_conv;
24840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24841         this_ptr_conv.is_owned = false;
24842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24843         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
24844 }
24845
24846 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1max_1inbound_1htlc_1value_1in_1flight_1percent_1of_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
24847         LDKChannelHandshakeConfig this_ptr_conv;
24848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24849         this_ptr_conv.is_owned = false;
24850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24851         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
24852         return ret_conv;
24853 }
24854
24855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1max_1inbound_1htlc_1value_1in_1flight_1percent_1of_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
24856         LDKChannelHandshakeConfig this_ptr_conv;
24857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24858         this_ptr_conv.is_owned = false;
24859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24860         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
24861 }
24862
24863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
24864         LDKChannelHandshakeConfig this_ptr_conv;
24865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24866         this_ptr_conv.is_owned = false;
24867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24868         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
24869         return ret_conv;
24870 }
24871
24872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24873         LDKChannelHandshakeConfig this_ptr_conv;
24874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24875         this_ptr_conv.is_owned = false;
24876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24877         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
24878 }
24879
24880 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, int8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, jboolean negotiate_scid_privacy_arg) {
24881         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy_arg);
24882         int64_t ret_ref = 0;
24883         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24884         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24886         ret_ref = (uintptr_t)ret_var.inner;
24887         if (ret_var.is_owned) {
24888                 ret_ref |= 1;
24889         }
24890         return ret_ref;
24891 }
24892
24893 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
24894         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
24895 int64_t ret_ref = 0;
24896 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24897 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24898 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24899 ret_ref = (uintptr_t)ret_var.inner;
24900 if (ret_var.is_owned) {
24901         ret_ref |= 1;
24902 }
24903         return ret_ref;
24904 }
24905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24906         LDKChannelHandshakeConfig arg_conv;
24907         arg_conv.inner = (void*)(arg & (~1));
24908         arg_conv.is_owned = false;
24909         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24910         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
24911         return ret_conv;
24912 }
24913
24914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24915         LDKChannelHandshakeConfig orig_conv;
24916         orig_conv.inner = (void*)(orig & (~1));
24917         orig_conv.is_owned = false;
24918         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24919         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
24920         int64_t ret_ref = 0;
24921         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24922         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24924         ret_ref = (uintptr_t)ret_var.inner;
24925         if (ret_var.is_owned) {
24926                 ret_ref |= 1;
24927         }
24928         return ret_ref;
24929 }
24930
24931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
24932         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
24933         int64_t ret_ref = 0;
24934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24937         ret_ref = (uintptr_t)ret_var.inner;
24938         if (ret_var.is_owned) {
24939                 ret_ref |= 1;
24940         }
24941         return ret_ref;
24942 }
24943
24944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24945         LDKChannelHandshakeLimits this_obj_conv;
24946         this_obj_conv.inner = (void*)(this_obj & (~1));
24947         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24949         ChannelHandshakeLimits_free(this_obj_conv);
24950 }
24951
24952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24953         LDKChannelHandshakeLimits this_ptr_conv;
24954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24955         this_ptr_conv.is_owned = false;
24956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24957         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
24958         return ret_conv;
24959 }
24960
24961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24962         LDKChannelHandshakeLimits this_ptr_conv;
24963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24964         this_ptr_conv.is_owned = false;
24965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24966         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
24967 }
24968
24969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24970         LDKChannelHandshakeLimits this_ptr_conv;
24971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24972         this_ptr_conv.is_owned = false;
24973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24974         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
24975         return ret_conv;
24976 }
24977
24978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24979         LDKChannelHandshakeLimits this_ptr_conv;
24980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24981         this_ptr_conv.is_owned = false;
24982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24983         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
24984 }
24985
24986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24987         LDKChannelHandshakeLimits this_ptr_conv;
24988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24989         this_ptr_conv.is_owned = false;
24990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24991         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
24992         return ret_conv;
24993 }
24994
24995 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) {
24996         LDKChannelHandshakeLimits this_ptr_conv;
24997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24998         this_ptr_conv.is_owned = false;
24999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25000         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
25001 }
25002
25003 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) {
25004         LDKChannelHandshakeLimits this_ptr_conv;
25005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25006         this_ptr_conv.is_owned = false;
25007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25008         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
25009         return ret_conv;
25010 }
25011
25012 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) {
25013         LDKChannelHandshakeLimits this_ptr_conv;
25014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25015         this_ptr_conv.is_owned = false;
25016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25017         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
25018 }
25019
25020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25021         LDKChannelHandshakeLimits this_ptr_conv;
25022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25023         this_ptr_conv.is_owned = false;
25024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25025         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
25026         return ret_conv;
25027 }
25028
25029 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) {
25030         LDKChannelHandshakeLimits this_ptr_conv;
25031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25032         this_ptr_conv.is_owned = false;
25033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25034         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
25035 }
25036
25037 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
25038         LDKChannelHandshakeLimits this_ptr_conv;
25039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25040         this_ptr_conv.is_owned = false;
25041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25042         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
25043         return ret_conv;
25044 }
25045
25046 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) {
25047         LDKChannelHandshakeLimits this_ptr_conv;
25048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25049         this_ptr_conv.is_owned = false;
25050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25051         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
25052 }
25053
25054 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
25055         LDKChannelHandshakeLimits this_ptr_conv;
25056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25057         this_ptr_conv.is_owned = false;
25058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25059         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
25060         return ret_conv;
25061 }
25062
25063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25064         LDKChannelHandshakeLimits this_ptr_conv;
25065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25066         this_ptr_conv.is_owned = false;
25067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25068         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
25069 }
25070
25071 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
25072         LDKChannelHandshakeLimits this_ptr_conv;
25073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25074         this_ptr_conv.is_owned = false;
25075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25076         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
25077         return ret_conv;
25078 }
25079
25080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25081         LDKChannelHandshakeLimits this_ptr_conv;
25082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25083         this_ptr_conv.is_owned = false;
25084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25085         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
25086 }
25087
25088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
25089         LDKChannelHandshakeLimits this_ptr_conv;
25090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25091         this_ptr_conv.is_owned = false;
25092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25093         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
25094         return ret_conv;
25095 }
25096
25097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25098         LDKChannelHandshakeLimits this_ptr_conv;
25099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25100         this_ptr_conv.is_owned = false;
25101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25102         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
25103 }
25104
25105 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25106         LDKChannelHandshakeLimits this_ptr_conv;
25107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25108         this_ptr_conv.is_owned = false;
25109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25110         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
25111         return ret_conv;
25112 }
25113
25114 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) {
25115         LDKChannelHandshakeLimits this_ptr_conv;
25116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25117         this_ptr_conv.is_owned = false;
25118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25119         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
25120 }
25121
25122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_funding_satoshis_arg, int64_t max_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 trust_own_funding_0conf_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
25123         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_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, trust_own_funding_0conf_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
25124         int64_t ret_ref = 0;
25125         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25126         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25128         ret_ref = (uintptr_t)ret_var.inner;
25129         if (ret_var.is_owned) {
25130                 ret_ref |= 1;
25131         }
25132         return ret_ref;
25133 }
25134
25135 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
25136         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
25137 int64_t ret_ref = 0;
25138 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25139 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25140 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25141 ret_ref = (uintptr_t)ret_var.inner;
25142 if (ret_var.is_owned) {
25143         ret_ref |= 1;
25144 }
25145         return ret_ref;
25146 }
25147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25148         LDKChannelHandshakeLimits arg_conv;
25149         arg_conv.inner = (void*)(arg & (~1));
25150         arg_conv.is_owned = false;
25151         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25152         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
25153         return ret_conv;
25154 }
25155
25156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25157         LDKChannelHandshakeLimits orig_conv;
25158         orig_conv.inner = (void*)(orig & (~1));
25159         orig_conv.is_owned = false;
25160         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25161         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
25162         int64_t ret_ref = 0;
25163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25166         ret_ref = (uintptr_t)ret_var.inner;
25167         if (ret_var.is_owned) {
25168                 ret_ref |= 1;
25169         }
25170         return ret_ref;
25171 }
25172
25173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
25174         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
25175         int64_t ret_ref = 0;
25176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25179         ret_ref = (uintptr_t)ret_var.inner;
25180         if (ret_var.is_owned) {
25181                 ret_ref |= 1;
25182         }
25183         return ret_ref;
25184 }
25185
25186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25187         LDKChannelConfig this_obj_conv;
25188         this_obj_conv.inner = (void*)(this_obj & (~1));
25189         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25191         ChannelConfig_free(this_obj_conv);
25192 }
25193
25194 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
25195         LDKChannelConfig this_ptr_conv;
25196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25197         this_ptr_conv.is_owned = false;
25198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25199         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
25200         return ret_conv;
25201 }
25202
25203 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) {
25204         LDKChannelConfig this_ptr_conv;
25205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25206         this_ptr_conv.is_owned = false;
25207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25208         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
25209 }
25210
25211 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25212         LDKChannelConfig this_ptr_conv;
25213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25214         this_ptr_conv.is_owned = false;
25215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25216         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
25217         return ret_conv;
25218 }
25219
25220 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) {
25221         LDKChannelConfig this_ptr_conv;
25222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25223         this_ptr_conv.is_owned = false;
25224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25225         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
25226 }
25227
25228 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
25229         LDKChannelConfig this_ptr_conv;
25230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25231         this_ptr_conv.is_owned = false;
25232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25233         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
25234         return ret_conv;
25235 }
25236
25237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25238         LDKChannelConfig this_ptr_conv;
25239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25240         this_ptr_conv.is_owned = false;
25241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25242         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
25243 }
25244
25245 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
25246         LDKChannelConfig this_ptr_conv;
25247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25248         this_ptr_conv.is_owned = false;
25249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25250         jboolean ret_conv = ChannelConfig_get_announced_channel(&this_ptr_conv);
25251         return ret_conv;
25252 }
25253
25254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25255         LDKChannelConfig this_ptr_conv;
25256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25257         this_ptr_conv.is_owned = false;
25258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25259         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
25260 }
25261
25262 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25263         LDKChannelConfig this_ptr_conv;
25264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25265         this_ptr_conv.is_owned = false;
25266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25267         jboolean ret_conv = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
25268         return ret_conv;
25269 }
25270
25271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25272         LDKChannelConfig this_ptr_conv;
25273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25274         this_ptr_conv.is_owned = false;
25275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25276         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
25277 }
25278
25279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25280         LDKChannelConfig this_ptr_conv;
25281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25282         this_ptr_conv.is_owned = false;
25283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25284         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
25285         return ret_conv;
25286 }
25287
25288 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) {
25289         LDKChannelConfig this_ptr_conv;
25290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25291         this_ptr_conv.is_owned = false;
25292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25293         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
25294 }
25295
25296 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) {
25297         LDKChannelConfig this_ptr_conv;
25298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25299         this_ptr_conv.is_owned = false;
25300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25301         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
25302         return ret_conv;
25303 }
25304
25305 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) {
25306         LDKChannelConfig this_ptr_conv;
25307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25308         this_ptr_conv.is_owned = false;
25309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25310         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
25311 }
25312
25313 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) {
25314         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);
25315         int64_t ret_ref = 0;
25316         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25317         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25319         ret_ref = (uintptr_t)ret_var.inner;
25320         if (ret_var.is_owned) {
25321                 ret_ref |= 1;
25322         }
25323         return ret_ref;
25324 }
25325
25326 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
25327         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
25328 int64_t ret_ref = 0;
25329 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25330 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25331 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25332 ret_ref = (uintptr_t)ret_var.inner;
25333 if (ret_var.is_owned) {
25334         ret_ref |= 1;
25335 }
25336         return ret_ref;
25337 }
25338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25339         LDKChannelConfig arg_conv;
25340         arg_conv.inner = (void*)(arg & (~1));
25341         arg_conv.is_owned = false;
25342         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25343         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
25344         return ret_conv;
25345 }
25346
25347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25348         LDKChannelConfig orig_conv;
25349         orig_conv.inner = (void*)(orig & (~1));
25350         orig_conv.is_owned = false;
25351         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25352         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
25353         int64_t ret_ref = 0;
25354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25357         ret_ref = (uintptr_t)ret_var.inner;
25358         if (ret_var.is_owned) {
25359                 ret_ref |= 1;
25360         }
25361         return ret_ref;
25362 }
25363
25364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
25365         LDKChannelConfig ret_var = ChannelConfig_default();
25366         int64_t ret_ref = 0;
25367         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25368         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25370         ret_ref = (uintptr_t)ret_var.inner;
25371         if (ret_var.is_owned) {
25372                 ret_ref |= 1;
25373         }
25374         return ret_ref;
25375 }
25376
25377 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
25378         LDKChannelConfig obj_conv;
25379         obj_conv.inner = (void*)(obj & (~1));
25380         obj_conv.is_owned = false;
25381         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25382         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
25383         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25384         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25385         CVec_u8Z_free(ret_var);
25386         return ret_arr;
25387 }
25388
25389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25390         LDKu8slice ser_ref;
25391         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25392         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25393         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
25394         *ret_conv = ChannelConfig_read(ser_ref);
25395         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25396         return (int64_t)ret_conv;
25397 }
25398
25399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25400         LDKUserConfig this_obj_conv;
25401         this_obj_conv.inner = (void*)(this_obj & (~1));
25402         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25404         UserConfig_free(this_obj_conv);
25405 }
25406
25407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
25408         LDKUserConfig this_ptr_conv;
25409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25410         this_ptr_conv.is_owned = false;
25411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25412         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
25413         int64_t ret_ref = 0;
25414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25417         ret_ref = (uintptr_t)ret_var.inner;
25418         if (ret_var.is_owned) {
25419                 ret_ref |= 1;
25420         }
25421         return ret_ref;
25422 }
25423
25424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25425         LDKUserConfig this_ptr_conv;
25426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25427         this_ptr_conv.is_owned = false;
25428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25429         LDKChannelHandshakeConfig val_conv;
25430         val_conv.inner = (void*)(val & (~1));
25431         val_conv.is_owned = (val & 1) || (val == 0);
25432         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25433         val_conv = ChannelHandshakeConfig_clone(&val_conv);
25434         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
25435 }
25436
25437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
25438         LDKUserConfig this_ptr_conv;
25439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25440         this_ptr_conv.is_owned = false;
25441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25442         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
25443         int64_t ret_ref = 0;
25444         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25445         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25447         ret_ref = (uintptr_t)ret_var.inner;
25448         if (ret_var.is_owned) {
25449                 ret_ref |= 1;
25450         }
25451         return ret_ref;
25452 }
25453
25454 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) {
25455         LDKUserConfig this_ptr_conv;
25456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25457         this_ptr_conv.is_owned = false;
25458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25459         LDKChannelHandshakeLimits val_conv;
25460         val_conv.inner = (void*)(val & (~1));
25461         val_conv.is_owned = (val & 1) || (val == 0);
25462         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25463         val_conv = ChannelHandshakeLimits_clone(&val_conv);
25464         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
25465 }
25466
25467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
25468         LDKUserConfig this_ptr_conv;
25469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25470         this_ptr_conv.is_owned = false;
25471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25472         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
25473         int64_t ret_ref = 0;
25474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25477         ret_ref = (uintptr_t)ret_var.inner;
25478         if (ret_var.is_owned) {
25479                 ret_ref |= 1;
25480         }
25481         return ret_ref;
25482 }
25483
25484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25485         LDKUserConfig this_ptr_conv;
25486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25487         this_ptr_conv.is_owned = false;
25488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25489         LDKChannelConfig val_conv;
25490         val_conv.inner = (void*)(val & (~1));
25491         val_conv.is_owned = (val & 1) || (val == 0);
25492         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25493         val_conv = ChannelConfig_clone(&val_conv);
25494         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
25495 }
25496
25497 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
25498         LDKUserConfig this_ptr_conv;
25499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25500         this_ptr_conv.is_owned = false;
25501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25502         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
25503         return ret_conv;
25504 }
25505
25506 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) {
25507         LDKUserConfig this_ptr_conv;
25508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25509         this_ptr_conv.is_owned = false;
25510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25511         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
25512 }
25513
25514 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
25515         LDKUserConfig this_ptr_conv;
25516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25517         this_ptr_conv.is_owned = false;
25518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25519         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
25520         return ret_conv;
25521 }
25522
25523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25524         LDKUserConfig 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         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
25529 }
25530
25531 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
25532         LDKUserConfig this_ptr_conv;
25533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25534         this_ptr_conv.is_owned = false;
25535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25536         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
25537         return ret_conv;
25538 }
25539
25540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25541         LDKUserConfig this_ptr_conv;
25542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25543         this_ptr_conv.is_owned = false;
25544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25545         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
25546 }
25547
25548 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, jboolean manually_accept_inbound_channels_arg) {
25549         LDKChannelHandshakeConfig own_channel_config_arg_conv;
25550         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
25551         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
25552         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
25553         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
25554         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
25555         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
25556         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
25557         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
25558         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
25559         LDKChannelConfig channel_options_arg_conv;
25560         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
25561         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
25562         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
25563         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
25564         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, manually_accept_inbound_channels_arg);
25565         int64_t ret_ref = 0;
25566         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25567         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25569         ret_ref = (uintptr_t)ret_var.inner;
25570         if (ret_var.is_owned) {
25571                 ret_ref |= 1;
25572         }
25573         return ret_ref;
25574 }
25575
25576 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
25577         LDKUserConfig ret_var = UserConfig_clone(arg);
25578 int64_t ret_ref = 0;
25579 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25580 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25581 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25582 ret_ref = (uintptr_t)ret_var.inner;
25583 if (ret_var.is_owned) {
25584         ret_ref |= 1;
25585 }
25586         return ret_ref;
25587 }
25588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25589         LDKUserConfig arg_conv;
25590         arg_conv.inner = (void*)(arg & (~1));
25591         arg_conv.is_owned = false;
25592         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25593         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
25594         return ret_conv;
25595 }
25596
25597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25598         LDKUserConfig orig_conv;
25599         orig_conv.inner = (void*)(orig & (~1));
25600         orig_conv.is_owned = false;
25601         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25602         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
25603         int64_t ret_ref = 0;
25604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25607         ret_ref = (uintptr_t)ret_var.inner;
25608         if (ret_var.is_owned) {
25609                 ret_ref |= 1;
25610         }
25611         return ret_ref;
25612 }
25613
25614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
25615         LDKUserConfig ret_var = UserConfig_default();
25616         int64_t ret_ref = 0;
25617         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25618         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25620         ret_ref = (uintptr_t)ret_var.inner;
25621         if (ret_var.is_owned) {
25622                 ret_ref |= 1;
25623         }
25624         return ret_ref;
25625 }
25626
25627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25628         LDKBestBlock this_obj_conv;
25629         this_obj_conv.inner = (void*)(this_obj & (~1));
25630         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25632         BestBlock_free(this_obj_conv);
25633 }
25634
25635 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
25636         LDKBestBlock ret_var = BestBlock_clone(arg);
25637 int64_t ret_ref = 0;
25638 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25639 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25640 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25641 ret_ref = (uintptr_t)ret_var.inner;
25642 if (ret_var.is_owned) {
25643         ret_ref |= 1;
25644 }
25645         return ret_ref;
25646 }
25647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25648         LDKBestBlock arg_conv;
25649         arg_conv.inner = (void*)(arg & (~1));
25650         arg_conv.is_owned = false;
25651         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25652         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
25653         return ret_conv;
25654 }
25655
25656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25657         LDKBestBlock orig_conv;
25658         orig_conv.inner = (void*)(orig & (~1));
25659         orig_conv.is_owned = false;
25660         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25661         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
25662         int64_t ret_ref = 0;
25663         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25664         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25666         ret_ref = (uintptr_t)ret_var.inner;
25667         if (ret_var.is_owned) {
25668                 ret_ref |= 1;
25669         }
25670         return ret_ref;
25671 }
25672
25673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
25674         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
25675         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
25676         int64_t ret_ref = 0;
25677         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25678         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25680         ret_ref = (uintptr_t)ret_var.inner;
25681         if (ret_var.is_owned) {
25682                 ret_ref |= 1;
25683         }
25684         return ret_ref;
25685 }
25686
25687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
25688         LDKThirtyTwoBytes block_hash_ref;
25689         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
25690         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
25691         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
25692         int64_t ret_ref = 0;
25693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25696         ret_ref = (uintptr_t)ret_var.inner;
25697         if (ret_var.is_owned) {
25698                 ret_ref |= 1;
25699         }
25700         return ret_ref;
25701 }
25702
25703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25704         LDKBestBlock 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25709         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
25710         return ret_arr;
25711 }
25712
25713 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
25714         LDKBestBlock this_arg_conv;
25715         this_arg_conv.inner = (void*)(this_arg & (~1));
25716         this_arg_conv.is_owned = false;
25717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25718         int32_t ret_conv = BestBlock_height(&this_arg_conv);
25719         return ret_conv;
25720 }
25721
25722 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25723         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
25724         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
25725         return ret_conv;
25726 }
25727
25728 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
25729         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
25730         return ret_conv;
25731 }
25732
25733 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
25734         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
25735         return ret_conv;
25736 }
25737
25738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25739         if ((this_ptr & 1) != 0) return;
25740         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25741         CHECK_ACCESS(this_ptr_ptr);
25742         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
25743         FREE((void*)this_ptr);
25744         Access_free(this_ptr_conv);
25745 }
25746
25747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25748         if ((this_ptr & 1) != 0) return;
25749         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25750         CHECK_ACCESS(this_ptr_ptr);
25751         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
25752         FREE((void*)this_ptr);
25753         Listen_free(this_ptr_conv);
25754 }
25755
25756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25757         if ((this_ptr & 1) != 0) return;
25758         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25759         CHECK_ACCESS(this_ptr_ptr);
25760         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
25761         FREE((void*)this_ptr);
25762         Confirm_free(this_ptr_conv);
25763 }
25764
25765 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25766         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
25767         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
25768         return ret_conv;
25769 }
25770
25771 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
25772         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
25773         return ret_conv;
25774 }
25775
25776 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
25777         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
25778         return ret_conv;
25779 }
25780
25781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25782         if ((this_ptr & 1) != 0) return;
25783         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25784         CHECK_ACCESS(this_ptr_ptr);
25785         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
25786         FREE((void*)this_ptr);
25787         Watch_free(this_ptr_conv);
25788 }
25789
25790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25791         if ((this_ptr & 1) != 0) return;
25792         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25793         CHECK_ACCESS(this_ptr_ptr);
25794         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
25795         FREE((void*)this_ptr);
25796         Filter_free(this_ptr_conv);
25797 }
25798
25799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25800         LDKWatchedOutput this_obj_conv;
25801         this_obj_conv.inner = (void*)(this_obj & (~1));
25802         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25804         WatchedOutput_free(this_obj_conv);
25805 }
25806
25807 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
25808         LDKWatchedOutput this_ptr_conv;
25809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25810         this_ptr_conv.is_owned = false;
25811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25812         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25813         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
25814         return ret_arr;
25815 }
25816
25817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25818         LDKWatchedOutput this_ptr_conv;
25819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25820         this_ptr_conv.is_owned = false;
25821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25822         LDKThirtyTwoBytes val_ref;
25823         CHECK((*env)->GetArrayLength(env, val) == 32);
25824         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25825         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
25826 }
25827
25828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25829         LDKWatchedOutput this_ptr_conv;
25830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25831         this_ptr_conv.is_owned = false;
25832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25833         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
25834         int64_t ret_ref = 0;
25835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25838         ret_ref = (uintptr_t)ret_var.inner;
25839         if (ret_var.is_owned) {
25840                 ret_ref |= 1;
25841         }
25842         return ret_ref;
25843 }
25844
25845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25846         LDKWatchedOutput this_ptr_conv;
25847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25848         this_ptr_conv.is_owned = false;
25849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25850         LDKOutPoint val_conv;
25851         val_conv.inner = (void*)(val & (~1));
25852         val_conv.is_owned = (val & 1) || (val == 0);
25853         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25854         val_conv = OutPoint_clone(&val_conv);
25855         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
25856 }
25857
25858 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25859         LDKWatchedOutput this_ptr_conv;
25860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25861         this_ptr_conv.is_owned = false;
25862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25863         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
25864         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25865         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25866         return ret_arr;
25867 }
25868
25869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25870         LDKWatchedOutput this_ptr_conv;
25871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25872         this_ptr_conv.is_owned = false;
25873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25874         LDKCVec_u8Z val_ref;
25875         val_ref.datalen = (*env)->GetArrayLength(env, val);
25876         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
25877         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
25878         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
25879 }
25880
25881 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) {
25882         LDKThirtyTwoBytes block_hash_arg_ref;
25883         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
25884         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
25885         LDKOutPoint outpoint_arg_conv;
25886         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
25887         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
25888         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
25889         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
25890         LDKCVec_u8Z script_pubkey_arg_ref;
25891         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
25892         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
25893         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
25894         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
25895         int64_t ret_ref = 0;
25896         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25897         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25899         ret_ref = (uintptr_t)ret_var.inner;
25900         if (ret_var.is_owned) {
25901                 ret_ref |= 1;
25902         }
25903         return ret_ref;
25904 }
25905
25906 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
25907         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
25908 int64_t ret_ref = 0;
25909 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25910 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25911 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25912 ret_ref = (uintptr_t)ret_var.inner;
25913 if (ret_var.is_owned) {
25914         ret_ref |= 1;
25915 }
25916         return ret_ref;
25917 }
25918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25919         LDKWatchedOutput arg_conv;
25920         arg_conv.inner = (void*)(arg & (~1));
25921         arg_conv.is_owned = false;
25922         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25923         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
25924         return ret_conv;
25925 }
25926
25927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25928         LDKWatchedOutput orig_conv;
25929         orig_conv.inner = (void*)(orig & (~1));
25930         orig_conv.is_owned = false;
25931         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25932         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
25933         int64_t ret_ref = 0;
25934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25937         ret_ref = (uintptr_t)ret_var.inner;
25938         if (ret_var.is_owned) {
25939                 ret_ref |= 1;
25940         }
25941         return ret_ref;
25942 }
25943
25944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
25945         LDKWatchedOutput o_conv;
25946         o_conv.inner = (void*)(o & (~1));
25947         o_conv.is_owned = false;
25948         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25949         int64_t ret_conv = WatchedOutput_hash(&o_conv);
25950         return ret_conv;
25951 }
25952
25953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25954         if ((this_ptr & 1) != 0) return;
25955         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25956         CHECK_ACCESS(this_ptr_ptr);
25957         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
25958         FREE((void*)this_ptr);
25959         BroadcasterInterface_free(this_ptr_conv);
25960 }
25961
25962 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25963         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
25964         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
25965         return ret_conv;
25966 }
25967
25968 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
25969         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
25970         return ret_conv;
25971 }
25972
25973 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
25974         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
25975         return ret_conv;
25976 }
25977
25978 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
25979         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
25980         return ret_conv;
25981 }
25982
25983 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25984         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
25985         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
25986         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
25987         return ret_conv;
25988 }
25989
25990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25991         if ((this_ptr & 1) != 0) return;
25992         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25993         CHECK_ACCESS(this_ptr_ptr);
25994         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
25995         FREE((void*)this_ptr);
25996         FeeEstimator_free(this_ptr_conv);
25997 }
25998
25999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26000         LDKMonitorUpdateId this_obj_conv;
26001         this_obj_conv.inner = (void*)(this_obj & (~1));
26002         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26004         MonitorUpdateId_free(this_obj_conv);
26005 }
26006
26007 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
26008         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
26009 int64_t ret_ref = 0;
26010 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26011 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26012 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26013 ret_ref = (uintptr_t)ret_var.inner;
26014 if (ret_var.is_owned) {
26015         ret_ref |= 1;
26016 }
26017         return ret_ref;
26018 }
26019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26020         LDKMonitorUpdateId arg_conv;
26021         arg_conv.inner = (void*)(arg & (~1));
26022         arg_conv.is_owned = false;
26023         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26024         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
26025         return ret_conv;
26026 }
26027
26028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26029         LDKMonitorUpdateId orig_conv;
26030         orig_conv.inner = (void*)(orig & (~1));
26031         orig_conv.is_owned = false;
26032         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26033         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
26034         int64_t ret_ref = 0;
26035         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26036         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26038         ret_ref = (uintptr_t)ret_var.inner;
26039         if (ret_var.is_owned) {
26040                 ret_ref |= 1;
26041         }
26042         return ret_ref;
26043 }
26044
26045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
26046         LDKMonitorUpdateId o_conv;
26047         o_conv.inner = (void*)(o & (~1));
26048         o_conv.is_owned = false;
26049         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26050         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
26051         return ret_conv;
26052 }
26053
26054 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26055         LDKMonitorUpdateId a_conv;
26056         a_conv.inner = (void*)(a & (~1));
26057         a_conv.is_owned = false;
26058         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26059         LDKMonitorUpdateId b_conv;
26060         b_conv.inner = (void*)(b & (~1));
26061         b_conv.is_owned = false;
26062         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26063         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
26064         return ret_conv;
26065 }
26066
26067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26068         if ((this_ptr & 1) != 0) return;
26069         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26070         CHECK_ACCESS(this_ptr_ptr);
26071         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
26072         FREE((void*)this_ptr);
26073         Persist_free(this_ptr_conv);
26074 }
26075
26076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26077         LDKLockedChannelMonitor this_obj_conv;
26078         this_obj_conv.inner = (void*)(this_obj & (~1));
26079         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26081         LockedChannelMonitor_free(this_obj_conv);
26082 }
26083
26084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26085         LDKChainMonitor this_obj_conv;
26086         this_obj_conv.inner = (void*)(this_obj & (~1));
26087         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26089         ChainMonitor_free(this_obj_conv);
26090 }
26091
26092 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) {
26093         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
26094         CHECK_ACCESS(chain_source_ptr);
26095         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
26096         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
26097         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
26098                 // Manually implement clone for Java trait instances
26099                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
26100                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26101                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
26102                 }
26103         }
26104         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26105         CHECK_ACCESS(broadcaster_ptr);
26106         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26107         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26108                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26109                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26110         }
26111         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26112         CHECK_ACCESS(logger_ptr);
26113         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26114         if (logger_conv.free == LDKLogger_JCalls_free) {
26115                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26116                 LDKLogger_JCalls_cloned(&logger_conv);
26117         }
26118         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
26119         CHECK_ACCESS(feeest_ptr);
26120         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
26121         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
26122                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26123                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
26124         }
26125         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
26126         CHECK_ACCESS(persister_ptr);
26127         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
26128         if (persister_conv.free == LDKPersist_JCalls_free) {
26129                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26130                 LDKPersist_JCalls_cloned(&persister_conv);
26131         }
26132         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
26133         int64_t ret_ref = 0;
26134         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26135         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26137         ret_ref = (uintptr_t)ret_var.inner;
26138         if (ret_var.is_owned) {
26139                 ret_ref |= 1;
26140         }
26141         return ret_ref;
26142 }
26143
26144 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) {
26145         LDKChainMonitor this_arg_conv;
26146         this_arg_conv.inner = (void*)(this_arg & (~1));
26147         this_arg_conv.is_owned = false;
26148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26149         LDKCVec_ChannelDetailsZ ignored_channels_constr;
26150         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
26151         if (ignored_channels_constr.datalen > 0)
26152                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
26153         else
26154                 ignored_channels_constr.data = NULL;
26155         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
26156         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
26157                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
26158                 LDKChannelDetails ignored_channels_conv_16_conv;
26159                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
26160                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
26161                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
26162                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
26163                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
26164         }
26165         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
26166         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
26167         int64_tArray ret_arr = NULL;
26168         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26169         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26170         for (size_t j = 0; j < ret_var.datalen; j++) {
26171                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26172                 *ret_conv_9_copy = ret_var.data[j];
26173                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
26174                 ret_arr_ptr[j] = ret_conv_9_ref;
26175         }
26176         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26177         FREE(ret_var.data);
26178         return ret_arr;
26179 }
26180
26181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
26182         LDKChainMonitor this_arg_conv;
26183         this_arg_conv.inner = (void*)(this_arg & (~1));
26184         this_arg_conv.is_owned = false;
26185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26186         LDKOutPoint funding_txo_conv;
26187         funding_txo_conv.inner = (void*)(funding_txo & (~1));
26188         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
26189         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
26190         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
26191         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
26192         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
26193         return (int64_t)ret_conv;
26194 }
26195
26196 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
26197         LDKChainMonitor this_arg_conv;
26198         this_arg_conv.inner = (void*)(this_arg & (~1));
26199         this_arg_conv.is_owned = false;
26200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26201         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
26202         int64_tArray ret_arr = NULL;
26203         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26204         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26205         for (size_t k = 0; k < ret_var.datalen; k++) {
26206                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
26207                 int64_t ret_conv_10_ref = 0;
26208                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26209                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26210                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
26211                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
26212                 if (ret_conv_10_var.is_owned) {
26213                         ret_conv_10_ref |= 1;
26214                 }
26215                 ret_arr_ptr[k] = ret_conv_10_ref;
26216         }
26217         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26218         FREE(ret_var.data);
26219         return ret_arr;
26220 }
26221
26222 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) {
26223         LDKChainMonitor this_arg_conv;
26224         this_arg_conv.inner = (void*)(this_arg & (~1));
26225         this_arg_conv.is_owned = false;
26226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26227         LDKOutPoint funding_txo_conv;
26228         funding_txo_conv.inner = (void*)(funding_txo & (~1));
26229         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
26230         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
26231         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
26232         LDKMonitorUpdateId completed_update_id_conv;
26233         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
26234         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
26235         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
26236         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
26237         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26238         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
26239         return (int64_t)ret_conv;
26240 }
26241
26242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
26243         LDKChainMonitor this_arg_conv;
26244         this_arg_conv.inner = (void*)(this_arg & (~1));
26245         this_arg_conv.is_owned = false;
26246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26247         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
26248         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
26249         return (int64_t)ret_ret;
26250 }
26251
26252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
26253         LDKChainMonitor this_arg_conv;
26254         this_arg_conv.inner = (void*)(this_arg & (~1));
26255         this_arg_conv.is_owned = false;
26256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26257         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
26258         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
26259         return (int64_t)ret_ret;
26260 }
26261
26262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
26263         LDKChainMonitor this_arg_conv;
26264         this_arg_conv.inner = (void*)(this_arg & (~1));
26265         this_arg_conv.is_owned = false;
26266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26267         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
26268         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
26269         return (int64_t)ret_ret;
26270 }
26271
26272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
26273         LDKChainMonitor this_arg_conv;
26274         this_arg_conv.inner = (void*)(this_arg & (~1));
26275         this_arg_conv.is_owned = false;
26276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26277         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
26278         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
26279         return (int64_t)ret_ret;
26280 }
26281
26282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26283         LDKChannelMonitorUpdate this_obj_conv;
26284         this_obj_conv.inner = (void*)(this_obj & (~1));
26285         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26287         ChannelMonitorUpdate_free(this_obj_conv);
26288 }
26289
26290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26291         LDKChannelMonitorUpdate this_ptr_conv;
26292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26293         this_ptr_conv.is_owned = false;
26294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26295         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
26296         return ret_conv;
26297 }
26298
26299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26300         LDKChannelMonitorUpdate this_ptr_conv;
26301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26302         this_ptr_conv.is_owned = false;
26303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26304         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
26305 }
26306
26307 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
26308         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
26309 int64_t ret_ref = 0;
26310 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26311 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26312 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26313 ret_ref = (uintptr_t)ret_var.inner;
26314 if (ret_var.is_owned) {
26315         ret_ref |= 1;
26316 }
26317         return ret_ref;
26318 }
26319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26320         LDKChannelMonitorUpdate arg_conv;
26321         arg_conv.inner = (void*)(arg & (~1));
26322         arg_conv.is_owned = false;
26323         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26324         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
26325         return ret_conv;
26326 }
26327
26328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26329         LDKChannelMonitorUpdate orig_conv;
26330         orig_conv.inner = (void*)(orig & (~1));
26331         orig_conv.is_owned = false;
26332         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26333         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
26334         int64_t ret_ref = 0;
26335         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26336         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26338         ret_ref = (uintptr_t)ret_var.inner;
26339         if (ret_var.is_owned) {
26340                 ret_ref |= 1;
26341         }
26342         return ret_ref;
26343 }
26344
26345 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
26346         LDKChannelMonitorUpdate obj_conv;
26347         obj_conv.inner = (void*)(obj & (~1));
26348         obj_conv.is_owned = false;
26349         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26350         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
26351         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26352         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26353         CVec_u8Z_free(ret_var);
26354         return ret_arr;
26355 }
26356
26357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26358         LDKu8slice ser_ref;
26359         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26360         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26361         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
26362         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
26363         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26364         return (int64_t)ret_conv;
26365 }
26366
26367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26368         if ((this_ptr & 1) != 0) return;
26369         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26370         CHECK_ACCESS(this_ptr_ptr);
26371         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
26372         FREE((void*)this_ptr);
26373         MonitorEvent_free(this_ptr_conv);
26374 }
26375
26376 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
26377         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26378         *ret_copy = MonitorEvent_clone(arg);
26379 int64_t ret_ref = (uintptr_t)ret_copy;
26380         return ret_ref;
26381 }
26382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26383         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
26384         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
26385         return ret_conv;
26386 }
26387
26388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26389         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
26390         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26391         *ret_copy = MonitorEvent_clone(orig_conv);
26392         int64_t ret_ref = (uintptr_t)ret_copy;
26393         return ret_ref;
26394 }
26395
26396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
26397         LDKHTLCUpdate a_conv;
26398         a_conv.inner = (void*)(a & (~1));
26399         a_conv.is_owned = (a & 1) || (a == 0);
26400         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26401         a_conv = HTLCUpdate_clone(&a_conv);
26402         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26403         *ret_copy = MonitorEvent_htlcevent(a_conv);
26404         int64_t ret_ref = (uintptr_t)ret_copy;
26405         return ret_ref;
26406 }
26407
26408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
26409         LDKOutPoint a_conv;
26410         a_conv.inner = (void*)(a & (~1));
26411         a_conv.is_owned = (a & 1) || (a == 0);
26412         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26413         a_conv = OutPoint_clone(&a_conv);
26414         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26415         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
26416         int64_t ret_ref = (uintptr_t)ret_copy;
26417         return ret_ref;
26418 }
26419
26420 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) {
26421         LDKOutPoint funding_txo_conv;
26422         funding_txo_conv.inner = (void*)(funding_txo & (~1));
26423         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
26424         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
26425         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
26426         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26427         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
26428         int64_t ret_ref = (uintptr_t)ret_copy;
26429         return ret_ref;
26430 }
26431
26432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
26433         LDKOutPoint a_conv;
26434         a_conv.inner = (void*)(a & (~1));
26435         a_conv.is_owned = (a & 1) || (a == 0);
26436         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26437         a_conv = OutPoint_clone(&a_conv);
26438         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26439         *ret_copy = MonitorEvent_update_failed(a_conv);
26440         int64_t ret_ref = (uintptr_t)ret_copy;
26441         return ret_ref;
26442 }
26443
26444 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
26445         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
26446         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
26447         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26448         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26449         CVec_u8Z_free(ret_var);
26450         return ret_arr;
26451 }
26452
26453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26454         LDKu8slice ser_ref;
26455         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26456         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26457         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
26458         *ret_conv = MonitorEvent_read(ser_ref);
26459         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26460         return (int64_t)ret_conv;
26461 }
26462
26463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26464         LDKHTLCUpdate this_obj_conv;
26465         this_obj_conv.inner = (void*)(this_obj & (~1));
26466         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26468         HTLCUpdate_free(this_obj_conv);
26469 }
26470
26471 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
26472         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
26473 int64_t ret_ref = 0;
26474 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26475 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26476 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26477 ret_ref = (uintptr_t)ret_var.inner;
26478 if (ret_var.is_owned) {
26479         ret_ref |= 1;
26480 }
26481         return ret_ref;
26482 }
26483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26484         LDKHTLCUpdate arg_conv;
26485         arg_conv.inner = (void*)(arg & (~1));
26486         arg_conv.is_owned = false;
26487         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26488         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
26489         return ret_conv;
26490 }
26491
26492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26493         LDKHTLCUpdate orig_conv;
26494         orig_conv.inner = (void*)(orig & (~1));
26495         orig_conv.is_owned = false;
26496         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26497         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
26498         int64_t ret_ref = 0;
26499         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26500         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26502         ret_ref = (uintptr_t)ret_var.inner;
26503         if (ret_var.is_owned) {
26504                 ret_ref |= 1;
26505         }
26506         return ret_ref;
26507 }
26508
26509 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
26510         LDKHTLCUpdate obj_conv;
26511         obj_conv.inner = (void*)(obj & (~1));
26512         obj_conv.is_owned = false;
26513         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26514         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
26515         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26516         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26517         CVec_u8Z_free(ret_var);
26518         return ret_arr;
26519 }
26520
26521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26522         LDKu8slice ser_ref;
26523         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26524         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26525         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
26526         *ret_conv = HTLCUpdate_read(ser_ref);
26527         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26528         return (int64_t)ret_conv;
26529 }
26530
26531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26532         if ((this_ptr & 1) != 0) return;
26533         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26534         CHECK_ACCESS(this_ptr_ptr);
26535         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
26536         FREE((void*)this_ptr);
26537         Balance_free(this_ptr_conv);
26538 }
26539
26540 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
26541         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26542         *ret_copy = Balance_clone(arg);
26543 int64_t ret_ref = (uintptr_t)ret_copy;
26544         return ret_ref;
26545 }
26546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26547         LDKBalance* arg_conv = (LDKBalance*)arg;
26548         int64_t ret_conv = Balance_clone_ptr(arg_conv);
26549         return ret_conv;
26550 }
26551
26552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26553         LDKBalance* orig_conv = (LDKBalance*)orig;
26554         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26555         *ret_copy = Balance_clone(orig_conv);
26556         int64_t ret_ref = (uintptr_t)ret_copy;
26557         return ret_ref;
26558 }
26559
26560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
26561         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26562         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
26563         int64_t ret_ref = (uintptr_t)ret_copy;
26564         return ret_ref;
26565 }
26566
26567 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) {
26568         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26569         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
26570         int64_t ret_ref = (uintptr_t)ret_copy;
26571         return ret_ref;
26572 }
26573
26574 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) {
26575         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26576         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
26577         int64_t ret_ref = (uintptr_t)ret_copy;
26578         return ret_ref;
26579 }
26580
26581 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) {
26582         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26583         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
26584         int64_t ret_ref = (uintptr_t)ret_copy;
26585         return ret_ref;
26586 }
26587
26588 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26589         LDKBalance* a_conv = (LDKBalance*)a;
26590         LDKBalance* b_conv = (LDKBalance*)b;
26591         jboolean ret_conv = Balance_eq(a_conv, b_conv);
26592         return ret_conv;
26593 }
26594
26595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26596         LDKChannelMonitor this_obj_conv;
26597         this_obj_conv.inner = (void*)(this_obj & (~1));
26598         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26600         ChannelMonitor_free(this_obj_conv);
26601 }
26602
26603 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
26604         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
26605 int64_t ret_ref = 0;
26606 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26607 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26608 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26609 ret_ref = (uintptr_t)ret_var.inner;
26610 if (ret_var.is_owned) {
26611         ret_ref |= 1;
26612 }
26613         return ret_ref;
26614 }
26615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26616         LDKChannelMonitor arg_conv;
26617         arg_conv.inner = (void*)(arg & (~1));
26618         arg_conv.is_owned = false;
26619         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26620         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
26621         return ret_conv;
26622 }
26623
26624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26625         LDKChannelMonitor orig_conv;
26626         orig_conv.inner = (void*)(orig & (~1));
26627         orig_conv.is_owned = false;
26628         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26629         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
26630         int64_t ret_ref = 0;
26631         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26632         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26634         ret_ref = (uintptr_t)ret_var.inner;
26635         if (ret_var.is_owned) {
26636                 ret_ref |= 1;
26637         }
26638         return ret_ref;
26639 }
26640
26641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26642         LDKChannelMonitor obj_conv;
26643         obj_conv.inner = (void*)(obj & (~1));
26644         obj_conv.is_owned = false;
26645         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26646         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
26647         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26648         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26649         CVec_u8Z_free(ret_var);
26650         return ret_arr;
26651 }
26652
26653 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) {
26654         LDKChannelMonitor this_arg_conv;
26655         this_arg_conv.inner = (void*)(this_arg & (~1));
26656         this_arg_conv.is_owned = false;
26657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26658         LDKChannelMonitorUpdate updates_conv;
26659         updates_conv.inner = (void*)(updates & (~1));
26660         updates_conv.is_owned = false;
26661         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
26662         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26663         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
26664         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
26665         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26666         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
26667         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
26668         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26669         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
26670         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
26671         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
26672         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
26673         return (int64_t)ret_conv;
26674 }
26675
26676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26677         LDKChannelMonitor this_arg_conv;
26678         this_arg_conv.inner = (void*)(this_arg & (~1));
26679         this_arg_conv.is_owned = false;
26680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26681         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
26682         return ret_conv;
26683 }
26684
26685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
26686         LDKChannelMonitor this_arg_conv;
26687         this_arg_conv.inner = (void*)(this_arg & (~1));
26688         this_arg_conv.is_owned = false;
26689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26690         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
26691         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
26692         return ((int64_t)ret_conv);
26693 }
26694
26695 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
26696         LDKChannelMonitor this_arg_conv;
26697         this_arg_conv.inner = (void*)(this_arg & (~1));
26698         this_arg_conv.is_owned = false;
26699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26700         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
26701         int64_tArray ret_arr = NULL;
26702         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26703         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26704         for (size_t o = 0; o < ret_var.datalen; o++) {
26705                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
26706                 *ret_conv_40_conv = ret_var.data[o];
26707                 ret_arr_ptr[o] = ((int64_t)ret_conv_40_conv);
26708         }
26709         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26710         FREE(ret_var.data);
26711         return ret_arr;
26712 }
26713
26714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
26715         LDKChannelMonitor this_arg_conv;
26716         this_arg_conv.inner = (void*)(this_arg & (~1));
26717         this_arg_conv.is_owned = false;
26718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26719         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
26720         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
26721         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
26722         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
26723 }
26724
26725 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
26726         LDKChannelMonitor this_arg_conv;
26727         this_arg_conv.inner = (void*)(this_arg & (~1));
26728         this_arg_conv.is_owned = false;
26729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26730         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
26731         int64_tArray ret_arr = NULL;
26732         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26733         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26734         for (size_t o = 0; o < ret_var.datalen; o++) {
26735                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26736                 *ret_conv_14_copy = ret_var.data[o];
26737                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
26738                 ret_arr_ptr[o] = ret_conv_14_ref;
26739         }
26740         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26741         FREE(ret_var.data);
26742         return ret_arr;
26743 }
26744
26745 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
26746         LDKChannelMonitor this_arg_conv;
26747         this_arg_conv.inner = (void*)(this_arg & (~1));
26748         this_arg_conv.is_owned = false;
26749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26750         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
26751         int64_tArray ret_arr = NULL;
26752         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26753         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26754         for (size_t h = 0; h < ret_var.datalen; h++) {
26755                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26756                 *ret_conv_7_copy = ret_var.data[h];
26757                 int64_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
26758                 ret_arr_ptr[h] = ret_conv_7_ref;
26759         }
26760         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26761         FREE(ret_var.data);
26762         return ret_arr;
26763 }
26764
26765 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) {
26766         LDKChannelMonitor this_arg_conv;
26767         this_arg_conv.inner = (void*)(this_arg & (~1));
26768         this_arg_conv.is_owned = false;
26769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26770         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26771         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
26772         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
26773         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
26774         jobjectArray ret_arr = NULL;
26775         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
26776         ;
26777         for (size_t i = 0; i < ret_var.datalen; i++) {
26778                 LDKTransaction ret_conv_8_var = ret_var.data[i];
26779                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
26780                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
26781                 Transaction_free(ret_conv_8_var);
26782                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
26783         }
26784         
26785         FREE(ret_var.data);
26786         return ret_arr;
26787 }
26788
26789 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) {
26790         LDKChannelMonitor this_arg_conv;
26791         this_arg_conv.inner = (void*)(this_arg & (~1));
26792         this_arg_conv.is_owned = false;
26793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26794         unsigned char header_arr[80];
26795         CHECK((*env)->GetArrayLength(env, header) == 80);
26796         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26797         unsigned char (*header_ref)[80] = &header_arr;
26798         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
26799         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
26800         if (txdata_constr.datalen > 0)
26801                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
26802         else
26803                 txdata_constr.data = NULL;
26804         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
26805         for (size_t c = 0; c < txdata_constr.datalen; c++) {
26806                 int64_t txdata_conv_28 = txdata_vals[c];
26807                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
26808                 CHECK_ACCESS(txdata_conv_28_ptr);
26809                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
26810                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
26811                 txdata_constr.data[c] = txdata_conv_28_conv;
26812         }
26813         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
26814         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26815         CHECK_ACCESS(broadcaster_ptr);
26816         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26817         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26818                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26819                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26820         }
26821         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26822         CHECK_ACCESS(fee_estimator_ptr);
26823         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26824         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26825                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26826                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26827         }
26828         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26829         CHECK_ACCESS(logger_ptr);
26830         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26831         if (logger_conv.free == LDKLogger_JCalls_free) {
26832                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26833                 LDKLogger_JCalls_cloned(&logger_conv);
26834         }
26835         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);
26836         int64_tArray ret_arr = NULL;
26837         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26838         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26839         for (size_t n = 0; n < ret_var.datalen; n++) {
26840                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26841                 *ret_conv_39_conv = ret_var.data[n];
26842                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
26843         }
26844         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26845         FREE(ret_var.data);
26846         return ret_arr;
26847 }
26848
26849 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) {
26850         LDKChannelMonitor this_arg_conv;
26851         this_arg_conv.inner = (void*)(this_arg & (~1));
26852         this_arg_conv.is_owned = false;
26853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26854         unsigned char header_arr[80];
26855         CHECK((*env)->GetArrayLength(env, header) == 80);
26856         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26857         unsigned char (*header_ref)[80] = &header_arr;
26858         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26859         CHECK_ACCESS(broadcaster_ptr);
26860         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26861         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26862                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26863                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26864         }
26865         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26866         CHECK_ACCESS(fee_estimator_ptr);
26867         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26868         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26869                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26870                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26871         }
26872         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26873         CHECK_ACCESS(logger_ptr);
26874         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26875         if (logger_conv.free == LDKLogger_JCalls_free) {
26876                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26877                 LDKLogger_JCalls_cloned(&logger_conv);
26878         }
26879         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
26880 }
26881
26882 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) {
26883         LDKChannelMonitor this_arg_conv;
26884         this_arg_conv.inner = (void*)(this_arg & (~1));
26885         this_arg_conv.is_owned = false;
26886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26887         unsigned char header_arr[80];
26888         CHECK((*env)->GetArrayLength(env, header) == 80);
26889         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26890         unsigned char (*header_ref)[80] = &header_arr;
26891         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
26892         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
26893         if (txdata_constr.datalen > 0)
26894                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
26895         else
26896                 txdata_constr.data = NULL;
26897         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
26898         for (size_t c = 0; c < txdata_constr.datalen; c++) {
26899                 int64_t txdata_conv_28 = txdata_vals[c];
26900                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
26901                 CHECK_ACCESS(txdata_conv_28_ptr);
26902                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
26903                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
26904                 txdata_constr.data[c] = txdata_conv_28_conv;
26905         }
26906         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
26907         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26908         CHECK_ACCESS(broadcaster_ptr);
26909         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26910         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26911                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26912                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26913         }
26914         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26915         CHECK_ACCESS(fee_estimator_ptr);
26916         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26917         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26918                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26919                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26920         }
26921         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26922         CHECK_ACCESS(logger_ptr);
26923         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26924         if (logger_conv.free == LDKLogger_JCalls_free) {
26925                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26926                 LDKLogger_JCalls_cloned(&logger_conv);
26927         }
26928         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);
26929         int64_tArray ret_arr = NULL;
26930         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26931         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26932         for (size_t n = 0; n < ret_var.datalen; n++) {
26933                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26934                 *ret_conv_39_conv = ret_var.data[n];
26935                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
26936         }
26937         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26938         FREE(ret_var.data);
26939         return ret_arr;
26940 }
26941
26942 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) {
26943         LDKChannelMonitor this_arg_conv;
26944         this_arg_conv.inner = (void*)(this_arg & (~1));
26945         this_arg_conv.is_owned = false;
26946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26947         unsigned char txid_arr[32];
26948         CHECK((*env)->GetArrayLength(env, txid) == 32);
26949         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
26950         unsigned char (*txid_ref)[32] = &txid_arr;
26951         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26952         CHECK_ACCESS(broadcaster_ptr);
26953         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26954         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26955                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26956                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26957         }
26958         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26959         CHECK_ACCESS(fee_estimator_ptr);
26960         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26961         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26962                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26963                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26964         }
26965         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26966         CHECK_ACCESS(logger_ptr);
26967         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26968         if (logger_conv.free == LDKLogger_JCalls_free) {
26969                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26970                 LDKLogger_JCalls_cloned(&logger_conv);
26971         }
26972         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
26973 }
26974
26975 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) {
26976         LDKChannelMonitor this_arg_conv;
26977         this_arg_conv.inner = (void*)(this_arg & (~1));
26978         this_arg_conv.is_owned = false;
26979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26980         unsigned char header_arr[80];
26981         CHECK((*env)->GetArrayLength(env, header) == 80);
26982         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26983         unsigned char (*header_ref)[80] = &header_arr;
26984         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26985         CHECK_ACCESS(broadcaster_ptr);
26986         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26987         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26988                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26989                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26990         }
26991         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26992         CHECK_ACCESS(fee_estimator_ptr);
26993         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26994         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26995                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26996                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26997         }
26998         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26999         CHECK_ACCESS(logger_ptr);
27000         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27001         if (logger_conv.free == LDKLogger_JCalls_free) {
27002                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27003                 LDKLogger_JCalls_cloned(&logger_conv);
27004         }
27005         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
27006         int64_tArray ret_arr = NULL;
27007         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27008         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27009         for (size_t n = 0; n < ret_var.datalen; n++) {
27010                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27011                 *ret_conv_39_conv = ret_var.data[n];
27012                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27013         }
27014         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27015         FREE(ret_var.data);
27016         return ret_arr;
27017 }
27018
27019 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
27020         LDKChannelMonitor this_arg_conv;
27021         this_arg_conv.inner = (void*)(this_arg & (~1));
27022         this_arg_conv.is_owned = false;
27023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27024         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
27025         jobjectArray ret_arr = NULL;
27026         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
27027         ;
27028         for (size_t i = 0; i < ret_var.datalen; i++) {
27029                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
27030                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
27031                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
27032         }
27033         
27034         FREE(ret_var.data);
27035         return ret_arr;
27036 }
27037
27038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
27039         LDKChannelMonitor this_arg_conv;
27040         this_arg_conv.inner = (void*)(this_arg & (~1));
27041         this_arg_conv.is_owned = false;
27042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27043         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
27044         int64_t ret_ref = 0;
27045         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27046         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27048         ret_ref = (uintptr_t)ret_var.inner;
27049         if (ret_var.is_owned) {
27050                 ret_ref |= 1;
27051         }
27052         return ret_ref;
27053 }
27054
27055 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
27056         LDKChannelMonitor this_arg_conv;
27057         this_arg_conv.inner = (void*)(this_arg & (~1));
27058         this_arg_conv.is_owned = false;
27059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27060         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
27061         int64_tArray ret_arr = NULL;
27062         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27063         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27064         for (size_t j = 0; j < ret_var.datalen; j++) {
27065                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27066                 *ret_conv_9_copy = ret_var.data[j];
27067                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
27068                 ret_arr_ptr[j] = ret_conv_9_ref;
27069         }
27070         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27071         FREE(ret_var.data);
27072         return ret_arr;
27073 }
27074
27075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
27076         LDKu8slice ser_ref;
27077         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27078         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27079         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
27080         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
27081         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
27082         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
27083         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
27084         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27085         return (int64_t)ret_conv;
27086 }
27087
27088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27089         LDKOutPoint this_obj_conv;
27090         this_obj_conv.inner = (void*)(this_obj & (~1));
27091         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27093         OutPoint_free(this_obj_conv);
27094 }
27095
27096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
27097         LDKOutPoint this_ptr_conv;
27098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27099         this_ptr_conv.is_owned = false;
27100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27101         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27102         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
27103         return ret_arr;
27104 }
27105
27106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27107         LDKOutPoint this_ptr_conv;
27108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27109         this_ptr_conv.is_owned = false;
27110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27111         LDKThirtyTwoBytes val_ref;
27112         CHECK((*env)->GetArrayLength(env, val) == 32);
27113         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27114         OutPoint_set_txid(&this_ptr_conv, val_ref);
27115 }
27116
27117 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
27118         LDKOutPoint this_ptr_conv;
27119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27120         this_ptr_conv.is_owned = false;
27121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27122         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
27123         return ret_conv;
27124 }
27125
27126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27127         LDKOutPoint this_ptr_conv;
27128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27129         this_ptr_conv.is_owned = false;
27130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27131         OutPoint_set_index(&this_ptr_conv, val);
27132 }
27133
27134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
27135         LDKThirtyTwoBytes txid_arg_ref;
27136         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
27137         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
27138         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
27139         int64_t ret_ref = 0;
27140         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27141         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27143         ret_ref = (uintptr_t)ret_var.inner;
27144         if (ret_var.is_owned) {
27145                 ret_ref |= 1;
27146         }
27147         return ret_ref;
27148 }
27149
27150 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
27151         LDKOutPoint ret_var = OutPoint_clone(arg);
27152 int64_t ret_ref = 0;
27153 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27154 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27155 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27156 ret_ref = (uintptr_t)ret_var.inner;
27157 if (ret_var.is_owned) {
27158         ret_ref |= 1;
27159 }
27160         return ret_ref;
27161 }
27162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27163         LDKOutPoint arg_conv;
27164         arg_conv.inner = (void*)(arg & (~1));
27165         arg_conv.is_owned = false;
27166         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27167         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
27168         return ret_conv;
27169 }
27170
27171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27172         LDKOutPoint orig_conv;
27173         orig_conv.inner = (void*)(orig & (~1));
27174         orig_conv.is_owned = false;
27175         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27176         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
27177         int64_t ret_ref = 0;
27178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27181         ret_ref = (uintptr_t)ret_var.inner;
27182         if (ret_var.is_owned) {
27183                 ret_ref |= 1;
27184         }
27185         return ret_ref;
27186 }
27187
27188 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27189         LDKOutPoint a_conv;
27190         a_conv.inner = (void*)(a & (~1));
27191         a_conv.is_owned = false;
27192         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27193         LDKOutPoint b_conv;
27194         b_conv.inner = (void*)(b & (~1));
27195         b_conv.is_owned = false;
27196         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27197         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
27198         return ret_conv;
27199 }
27200
27201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
27202         LDKOutPoint o_conv;
27203         o_conv.inner = (void*)(o & (~1));
27204         o_conv.is_owned = false;
27205         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27206         int64_t ret_conv = OutPoint_hash(&o_conv);
27207         return ret_conv;
27208 }
27209
27210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
27211         LDKOutPoint this_arg_conv;
27212         this_arg_conv.inner = (void*)(this_arg & (~1));
27213         this_arg_conv.is_owned = false;
27214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27215         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27216         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
27217         return ret_arr;
27218 }
27219
27220 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
27221         LDKOutPoint obj_conv;
27222         obj_conv.inner = (void*)(obj & (~1));
27223         obj_conv.is_owned = false;
27224         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27225         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
27226         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27227         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27228         CVec_u8Z_free(ret_var);
27229         return ret_arr;
27230 }
27231
27232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27233         LDKu8slice ser_ref;
27234         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27235         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27236         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
27237         *ret_conv = OutPoint_read(ser_ref);
27238         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27239         return (int64_t)ret_conv;
27240 }
27241
27242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27243         LDKDelayedPaymentOutputDescriptor this_obj_conv;
27244         this_obj_conv.inner = (void*)(this_obj & (~1));
27245         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27247         DelayedPaymentOutputDescriptor_free(this_obj_conv);
27248 }
27249
27250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27251         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27253         this_ptr_conv.is_owned = false;
27254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27255         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
27256         int64_t ret_ref = 0;
27257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27260         ret_ref = (uintptr_t)ret_var.inner;
27261         if (ret_var.is_owned) {
27262                 ret_ref |= 1;
27263         }
27264         return ret_ref;
27265 }
27266
27267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27268         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27270         this_ptr_conv.is_owned = false;
27271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27272         LDKOutPoint val_conv;
27273         val_conv.inner = (void*)(val & (~1));
27274         val_conv.is_owned = (val & 1) || (val == 0);
27275         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27276         val_conv = OutPoint_clone(&val_conv);
27277         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
27278 }
27279
27280 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
27281         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27283         this_ptr_conv.is_owned = false;
27284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27285         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27286         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
27287         return ret_arr;
27288 }
27289
27290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27291         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27293         this_ptr_conv.is_owned = false;
27294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27295         LDKPublicKey val_ref;
27296         CHECK((*env)->GetArrayLength(env, val) == 33);
27297         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27298         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
27299 }
27300
27301 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27302         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27304         this_ptr_conv.is_owned = false;
27305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27306         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
27307         return ret_conv;
27308 }
27309
27310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27311         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27313         this_ptr_conv.is_owned = false;
27314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27315         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
27316 }
27317
27318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27319         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27321         this_ptr_conv.is_owned = false;
27322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27323         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27324         CHECK_ACCESS(val_ptr);
27325         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
27326         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
27327         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
27328 }
27329
27330 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27331         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27333         this_ptr_conv.is_owned = false;
27334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27335         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27336         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
27337         return ret_arr;
27338 }
27339
27340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27341         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27343         this_ptr_conv.is_owned = false;
27344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27345         LDKPublicKey val_ref;
27346         CHECK((*env)->GetArrayLength(env, val) == 33);
27347         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27348         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
27349 }
27350
27351 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27352         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27354         this_ptr_conv.is_owned = false;
27355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27356         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27357         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
27358         return ret_arr;
27359 }
27360
27361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27362         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27364         this_ptr_conv.is_owned = false;
27365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27366         LDKThirtyTwoBytes val_ref;
27367         CHECK((*env)->GetArrayLength(env, val) == 32);
27368         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27369         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
27370 }
27371
27372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27373         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27375         this_ptr_conv.is_owned = false;
27376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27377         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
27378         return ret_conv;
27379 }
27380
27381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27382         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27384         this_ptr_conv.is_owned = false;
27385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27386         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
27387 }
27388
27389 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) {
27390         LDKOutPoint outpoint_arg_conv;
27391         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
27392         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
27393         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
27394         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
27395         LDKPublicKey per_commitment_point_arg_ref;
27396         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
27397         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
27398         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
27399         CHECK_ACCESS(output_arg_ptr);
27400         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
27401         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
27402         LDKPublicKey revocation_pubkey_arg_ref;
27403         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
27404         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
27405         LDKThirtyTwoBytes channel_keys_id_arg_ref;
27406         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
27407         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
27408         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);
27409         int64_t ret_ref = 0;
27410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27413         ret_ref = (uintptr_t)ret_var.inner;
27414         if (ret_var.is_owned) {
27415                 ret_ref |= 1;
27416         }
27417         return ret_ref;
27418 }
27419
27420 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
27421         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
27422 int64_t ret_ref = 0;
27423 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27424 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27425 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27426 ret_ref = (uintptr_t)ret_var.inner;
27427 if (ret_var.is_owned) {
27428         ret_ref |= 1;
27429 }
27430         return ret_ref;
27431 }
27432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27433         LDKDelayedPaymentOutputDescriptor arg_conv;
27434         arg_conv.inner = (void*)(arg & (~1));
27435         arg_conv.is_owned = false;
27436         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27437         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
27438         return ret_conv;
27439 }
27440
27441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27442         LDKDelayedPaymentOutputDescriptor orig_conv;
27443         orig_conv.inner = (void*)(orig & (~1));
27444         orig_conv.is_owned = false;
27445         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27446         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
27447         int64_t ret_ref = 0;
27448         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27449         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27451         ret_ref = (uintptr_t)ret_var.inner;
27452         if (ret_var.is_owned) {
27453                 ret_ref |= 1;
27454         }
27455         return ret_ref;
27456 }
27457
27458 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27459         LDKDelayedPaymentOutputDescriptor obj_conv;
27460         obj_conv.inner = (void*)(obj & (~1));
27461         obj_conv.is_owned = false;
27462         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27463         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
27464         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27465         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27466         CVec_u8Z_free(ret_var);
27467         return ret_arr;
27468 }
27469
27470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27471         LDKu8slice ser_ref;
27472         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27473         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27474         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
27475         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
27476         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27477         return (int64_t)ret_conv;
27478 }
27479
27480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27481         LDKStaticPaymentOutputDescriptor this_obj_conv;
27482         this_obj_conv.inner = (void*)(this_obj & (~1));
27483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27485         StaticPaymentOutputDescriptor_free(this_obj_conv);
27486 }
27487
27488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27489         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27491         this_ptr_conv.is_owned = false;
27492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27493         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
27494         int64_t ret_ref = 0;
27495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27498         ret_ref = (uintptr_t)ret_var.inner;
27499         if (ret_var.is_owned) {
27500                 ret_ref |= 1;
27501         }
27502         return ret_ref;
27503 }
27504
27505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27506         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27508         this_ptr_conv.is_owned = false;
27509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27510         LDKOutPoint val_conv;
27511         val_conv.inner = (void*)(val & (~1));
27512         val_conv.is_owned = (val & 1) || (val == 0);
27513         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27514         val_conv = OutPoint_clone(&val_conv);
27515         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
27516 }
27517
27518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27519         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27521         this_ptr_conv.is_owned = false;
27522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27523         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27524         CHECK_ACCESS(val_ptr);
27525         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
27526         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
27527         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
27528 }
27529
27530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27531         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27533         this_ptr_conv.is_owned = false;
27534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27535         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27536         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
27537         return ret_arr;
27538 }
27539
27540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27541         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27543         this_ptr_conv.is_owned = false;
27544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27545         LDKThirtyTwoBytes val_ref;
27546         CHECK((*env)->GetArrayLength(env, val) == 32);
27547         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27548         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
27549 }
27550
27551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27552         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27554         this_ptr_conv.is_owned = false;
27555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27556         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
27557         return ret_conv;
27558 }
27559
27560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27561         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27563         this_ptr_conv.is_owned = false;
27564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27565         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
27566 }
27567
27568 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) {
27569         LDKOutPoint outpoint_arg_conv;
27570         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
27571         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
27572         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
27573         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
27574         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
27575         CHECK_ACCESS(output_arg_ptr);
27576         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
27577         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
27578         LDKThirtyTwoBytes channel_keys_id_arg_ref;
27579         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
27580         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
27581         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
27582         int64_t ret_ref = 0;
27583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27586         ret_ref = (uintptr_t)ret_var.inner;
27587         if (ret_var.is_owned) {
27588                 ret_ref |= 1;
27589         }
27590         return ret_ref;
27591 }
27592
27593 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
27594         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
27595 int64_t ret_ref = 0;
27596 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27597 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27598 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27599 ret_ref = (uintptr_t)ret_var.inner;
27600 if (ret_var.is_owned) {
27601         ret_ref |= 1;
27602 }
27603         return ret_ref;
27604 }
27605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27606         LDKStaticPaymentOutputDescriptor arg_conv;
27607         arg_conv.inner = (void*)(arg & (~1));
27608         arg_conv.is_owned = false;
27609         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27610         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
27611         return ret_conv;
27612 }
27613
27614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27615         LDKStaticPaymentOutputDescriptor orig_conv;
27616         orig_conv.inner = (void*)(orig & (~1));
27617         orig_conv.is_owned = false;
27618         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27619         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
27620         int64_t ret_ref = 0;
27621         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27622         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27624         ret_ref = (uintptr_t)ret_var.inner;
27625         if (ret_var.is_owned) {
27626                 ret_ref |= 1;
27627         }
27628         return ret_ref;
27629 }
27630
27631 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27632         LDKStaticPaymentOutputDescriptor obj_conv;
27633         obj_conv.inner = (void*)(obj & (~1));
27634         obj_conv.is_owned = false;
27635         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27636         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
27637         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27638         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27639         CVec_u8Z_free(ret_var);
27640         return ret_arr;
27641 }
27642
27643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27644         LDKu8slice ser_ref;
27645         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27646         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27647         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
27648         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
27649         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27650         return (int64_t)ret_conv;
27651 }
27652
27653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27654         if ((this_ptr & 1) != 0) return;
27655         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27656         CHECK_ACCESS(this_ptr_ptr);
27657         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
27658         FREE((void*)this_ptr);
27659         SpendableOutputDescriptor_free(this_ptr_conv);
27660 }
27661
27662 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
27663         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27664         *ret_copy = SpendableOutputDescriptor_clone(arg);
27665 int64_t ret_ref = (uintptr_t)ret_copy;
27666         return ret_ref;
27667 }
27668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27669         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
27670         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
27671         return ret_conv;
27672 }
27673
27674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27675         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
27676         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27677         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
27678         int64_t ret_ref = (uintptr_t)ret_copy;
27679         return ret_ref;
27680 }
27681
27682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
27683         LDKOutPoint outpoint_conv;
27684         outpoint_conv.inner = (void*)(outpoint & (~1));
27685         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
27686         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
27687         outpoint_conv = OutPoint_clone(&outpoint_conv);
27688         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
27689         CHECK_ACCESS(output_ptr);
27690         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
27691         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
27692         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27693         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
27694         int64_t ret_ref = (uintptr_t)ret_copy;
27695         return ret_ref;
27696 }
27697
27698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27699         LDKDelayedPaymentOutputDescriptor a_conv;
27700         a_conv.inner = (void*)(a & (~1));
27701         a_conv.is_owned = (a & 1) || (a == 0);
27702         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27703         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
27704         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27705         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
27706         int64_t ret_ref = (uintptr_t)ret_copy;
27707         return ret_ref;
27708 }
27709
27710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27711         LDKStaticPaymentOutputDescriptor a_conv;
27712         a_conv.inner = (void*)(a & (~1));
27713         a_conv.is_owned = (a & 1) || (a == 0);
27714         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27715         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
27716         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27717         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
27718         int64_t ret_ref = (uintptr_t)ret_copy;
27719         return ret_ref;
27720 }
27721
27722 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27723         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
27724         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
27725         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27726         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27727         CVec_u8Z_free(ret_var);
27728         return ret_arr;
27729 }
27730
27731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27732         LDKu8slice ser_ref;
27733         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27734         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27735         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
27736         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
27737         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27738         return (int64_t)ret_conv;
27739 }
27740
27741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27742         if ((this_ptr & 1) != 0) return;
27743         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27744         CHECK_ACCESS(this_ptr_ptr);
27745         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
27746         FREE((void*)this_ptr);
27747         BaseSign_free(this_ptr_conv);
27748 }
27749
27750 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
27751         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27752         *ret_ret = Sign_clone(arg);
27753         return (int64_t)ret_ret;
27754 }
27755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27756         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
27757         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
27758         LDKSign* arg_conv = (LDKSign*)arg_ptr;
27759         int64_t ret_conv = Sign_clone_ptr(arg_conv);
27760         return ret_conv;
27761 }
27762
27763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27764         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
27765         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
27766         LDKSign* orig_conv = (LDKSign*)orig_ptr;
27767         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27768         *ret_ret = Sign_clone(orig_conv);
27769         return (int64_t)ret_ret;
27770 }
27771
27772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27773         if ((this_ptr & 1) != 0) return;
27774         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27775         CHECK_ACCESS(this_ptr_ptr);
27776         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
27777         FREE((void*)this_ptr);
27778         Sign_free(this_ptr_conv);
27779 }
27780
27781 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27782         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
27783         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
27784         return ret_conv;
27785 }
27786
27787 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
27788         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
27789         return ret_conv;
27790 }
27791
27792 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
27793         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
27794         return ret_conv;
27795 }
27796
27797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27798         if ((this_ptr & 1) != 0) return;
27799         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27800         CHECK_ACCESS(this_ptr_ptr);
27801         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
27802         FREE((void*)this_ptr);
27803         KeysInterface_free(this_ptr_conv);
27804 }
27805
27806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27807         LDKInMemorySigner this_obj_conv;
27808         this_obj_conv.inner = (void*)(this_obj & (~1));
27809         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27811         InMemorySigner_free(this_obj_conv);
27812 }
27813
27814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27815         LDKInMemorySigner this_ptr_conv;
27816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27817         this_ptr_conv.is_owned = false;
27818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27819         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27820         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
27821         return ret_arr;
27822 }
27823
27824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27825         LDKInMemorySigner this_ptr_conv;
27826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27827         this_ptr_conv.is_owned = false;
27828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27829         LDKSecretKey val_ref;
27830         CHECK((*env)->GetArrayLength(env, val) == 32);
27831         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27832         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
27833 }
27834
27835 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27836         LDKInMemorySigner this_ptr_conv;
27837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27838         this_ptr_conv.is_owned = false;
27839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27840         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27841         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
27842         return ret_arr;
27843 }
27844
27845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27846         LDKInMemorySigner this_ptr_conv;
27847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27848         this_ptr_conv.is_owned = false;
27849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27850         LDKSecretKey val_ref;
27851         CHECK((*env)->GetArrayLength(env, val) == 32);
27852         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27853         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
27854 }
27855
27856 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27857         LDKInMemorySigner this_ptr_conv;
27858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27859         this_ptr_conv.is_owned = false;
27860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27861         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27862         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
27863         return ret_arr;
27864 }
27865
27866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27867         LDKInMemorySigner this_ptr_conv;
27868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27869         this_ptr_conv.is_owned = false;
27870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27871         LDKSecretKey val_ref;
27872         CHECK((*env)->GetArrayLength(env, val) == 32);
27873         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27874         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
27875 }
27876
27877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27878         LDKInMemorySigner 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27883         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
27884         return ret_arr;
27885 }
27886
27887 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) {
27888         LDKInMemorySigner this_ptr_conv;
27889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27890         this_ptr_conv.is_owned = false;
27891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27892         LDKSecretKey val_ref;
27893         CHECK((*env)->GetArrayLength(env, val) == 32);
27894         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27895         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
27896 }
27897
27898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27899         LDKInMemorySigner this_ptr_conv;
27900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27901         this_ptr_conv.is_owned = false;
27902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27903         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27904         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
27905         return ret_arr;
27906 }
27907
27908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27909         LDKInMemorySigner this_ptr_conv;
27910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27911         this_ptr_conv.is_owned = false;
27912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27913         LDKSecretKey val_ref;
27914         CHECK((*env)->GetArrayLength(env, val) == 32);
27915         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27916         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
27917 }
27918
27919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
27920         LDKInMemorySigner this_ptr_conv;
27921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27922         this_ptr_conv.is_owned = false;
27923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27924         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27925         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
27926         return ret_arr;
27927 }
27928
27929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27930         LDKInMemorySigner this_ptr_conv;
27931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27932         this_ptr_conv.is_owned = false;
27933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27934         LDKThirtyTwoBytes val_ref;
27935         CHECK((*env)->GetArrayLength(env, val) == 32);
27936         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27937         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
27938 }
27939
27940 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
27941         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
27942 int64_t ret_ref = 0;
27943 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27944 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27945 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27946 ret_ref = (uintptr_t)ret_var.inner;
27947 if (ret_var.is_owned) {
27948         ret_ref |= 1;
27949 }
27950         return ret_ref;
27951 }
27952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27953         LDKInMemorySigner arg_conv;
27954         arg_conv.inner = (void*)(arg & (~1));
27955         arg_conv.is_owned = false;
27956         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27957         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
27958         return ret_conv;
27959 }
27960
27961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27962         LDKInMemorySigner orig_conv;
27963         orig_conv.inner = (void*)(orig & (~1));
27964         orig_conv.is_owned = false;
27965         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27966         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
27967         int64_t ret_ref = 0;
27968         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27969         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27970         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27971         ret_ref = (uintptr_t)ret_var.inner;
27972         if (ret_var.is_owned) {
27973                 ret_ref |= 1;
27974         }
27975         return ret_ref;
27976 }
27977
27978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1new(JNIEnv *env, jclass clz, int8_tArray node_secret, 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) {
27979         LDKSecretKey node_secret_ref;
27980         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
27981         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
27982         LDKSecretKey funding_key_ref;
27983         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
27984         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
27985         LDKSecretKey revocation_base_key_ref;
27986         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
27987         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
27988         LDKSecretKey payment_key_ref;
27989         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
27990         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
27991         LDKSecretKey delayed_payment_base_key_ref;
27992         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
27993         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
27994         LDKSecretKey htlc_base_key_ref;
27995         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
27996         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
27997         LDKThirtyTwoBytes commitment_seed_ref;
27998         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
27999         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
28000         LDKThirtyTwoBytes channel_keys_id_ref;
28001         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
28002         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
28003         LDKInMemorySigner ret_var = InMemorySigner_new(node_secret_ref, 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);
28004         int64_t ret_ref = 0;
28005         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28006         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28008         ret_ref = (uintptr_t)ret_var.inner;
28009         if (ret_var.is_owned) {
28010                 ret_ref |= 1;
28011         }
28012         return ret_ref;
28013 }
28014
28015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
28016         LDKInMemorySigner this_arg_conv;
28017         this_arg_conv.inner = (void*)(this_arg & (~1));
28018         this_arg_conv.is_owned = false;
28019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28020         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
28021         int64_t ret_ref = 0;
28022         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28023         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28025         ret_ref = (uintptr_t)ret_var.inner;
28026         if (ret_var.is_owned) {
28027                 ret_ref |= 1;
28028         }
28029         return ret_ref;
28030 }
28031
28032 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28033         LDKInMemorySigner this_arg_conv;
28034         this_arg_conv.inner = (void*)(this_arg & (~1));
28035         this_arg_conv.is_owned = false;
28036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28037         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
28038         return ret_conv;
28039 }
28040
28041 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28042         LDKInMemorySigner this_arg_conv;
28043         this_arg_conv.inner = (void*)(this_arg & (~1));
28044         this_arg_conv.is_owned = false;
28045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28046         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
28047         return ret_conv;
28048 }
28049
28050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
28051         LDKInMemorySigner this_arg_conv;
28052         this_arg_conv.inner = (void*)(this_arg & (~1));
28053         this_arg_conv.is_owned = false;
28054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28055         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
28056         return ret_conv;
28057 }
28058
28059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
28060         LDKInMemorySigner this_arg_conv;
28061         this_arg_conv.inner = (void*)(this_arg & (~1));
28062         this_arg_conv.is_owned = false;
28063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28064         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
28065         int64_t ret_ref = 0;
28066         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28067         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28069         ret_ref = (uintptr_t)ret_var.inner;
28070         if (ret_var.is_owned) {
28071                 ret_ref |= 1;
28072         }
28073         return ret_ref;
28074 }
28075
28076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
28077         LDKInMemorySigner this_arg_conv;
28078         this_arg_conv.inner = (void*)(this_arg & (~1));
28079         this_arg_conv.is_owned = false;
28080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28081         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
28082         int64_t ret_ref = 0;
28083         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28084         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28086         ret_ref = (uintptr_t)ret_var.inner;
28087         if (ret_var.is_owned) {
28088                 ret_ref |= 1;
28089         }
28090         return ret_ref;
28091 }
28092
28093 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
28094         LDKInMemorySigner this_arg_conv;
28095         this_arg_conv.inner = (void*)(this_arg & (~1));
28096         this_arg_conv.is_owned = false;
28097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28098         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
28099         return ret_conv;
28100 }
28101
28102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1sign_1counterparty_1payment_1input(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
28103         LDKInMemorySigner this_arg_conv;
28104         this_arg_conv.inner = (void*)(this_arg & (~1));
28105         this_arg_conv.is_owned = false;
28106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28107         LDKTransaction spend_tx_ref;
28108         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
28109         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
28110         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
28111         spend_tx_ref.data_is_owned = true;
28112         LDKStaticPaymentOutputDescriptor descriptor_conv;
28113         descriptor_conv.inner = (void*)(descriptor & (~1));
28114         descriptor_conv.is_owned = false;
28115         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
28116         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
28117         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
28118         return (int64_t)ret_conv;
28119 }
28120
28121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1sign_1dynamic_1p2wsh_1input(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
28122         LDKInMemorySigner this_arg_conv;
28123         this_arg_conv.inner = (void*)(this_arg & (~1));
28124         this_arg_conv.is_owned = false;
28125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28126         LDKTransaction spend_tx_ref;
28127         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
28128         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
28129         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
28130         spend_tx_ref.data_is_owned = true;
28131         LDKDelayedPaymentOutputDescriptor descriptor_conv;
28132         descriptor_conv.inner = (void*)(descriptor & (~1));
28133         descriptor_conv.is_owned = false;
28134         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
28135         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
28136         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
28137         return (int64_t)ret_conv;
28138 }
28139
28140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
28141         LDKInMemorySigner this_arg_conv;
28142         this_arg_conv.inner = (void*)(this_arg & (~1));
28143         this_arg_conv.is_owned = false;
28144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28145         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
28146         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
28147         return (int64_t)ret_ret;
28148 }
28149
28150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
28151         LDKInMemorySigner this_arg_conv;
28152         this_arg_conv.inner = (void*)(this_arg & (~1));
28153         this_arg_conv.is_owned = false;
28154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28155         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28156         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
28157         return (int64_t)ret_ret;
28158 }
28159
28160 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
28161         LDKInMemorySigner obj_conv;
28162         obj_conv.inner = (void*)(obj & (~1));
28163         obj_conv.is_owned = false;
28164         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28165         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
28166         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28167         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28168         CVec_u8Z_free(ret_var);
28169         return ret_arr;
28170 }
28171
28172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
28173         LDKu8slice ser_ref;
28174         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28175         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28176         LDKSecretKey arg_ref;
28177         CHECK((*env)->GetArrayLength(env, arg) == 32);
28178         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
28179         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
28180         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
28181         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28182         return (int64_t)ret_conv;
28183 }
28184
28185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28186         LDKKeysManager this_obj_conv;
28187         this_obj_conv.inner = (void*)(this_obj & (~1));
28188         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28190         KeysManager_free(this_obj_conv);
28191 }
28192
28193 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) {
28194         unsigned char seed_arr[32];
28195         CHECK((*env)->GetArrayLength(env, seed) == 32);
28196         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
28197         unsigned char (*seed_ref)[32] = &seed_arr;
28198         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
28199         int64_t ret_ref = 0;
28200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28203         ret_ref = (uintptr_t)ret_var.inner;
28204         if (ret_var.is_owned) {
28205                 ret_ref |= 1;
28206         }
28207         return ret_ref;
28208 }
28209
28210 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) {
28211         LDKKeysManager this_arg_conv;
28212         this_arg_conv.inner = (void*)(this_arg & (~1));
28213         this_arg_conv.is_owned = false;
28214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28215         unsigned char params_arr[32];
28216         CHECK((*env)->GetArrayLength(env, params) == 32);
28217         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
28218         unsigned char (*params_ref)[32] = &params_arr;
28219         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
28220         int64_t ret_ref = 0;
28221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28224         ret_ref = (uintptr_t)ret_var.inner;
28225         if (ret_var.is_owned) {
28226                 ret_ref |= 1;
28227         }
28228         return ret_ref;
28229 }
28230
28231 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) {
28232         LDKKeysManager this_arg_conv;
28233         this_arg_conv.inner = (void*)(this_arg & (~1));
28234         this_arg_conv.is_owned = false;
28235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28236         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
28237         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
28238         if (descriptors_constr.datalen > 0)
28239                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
28240         else
28241                 descriptors_constr.data = NULL;
28242         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
28243         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
28244                 int64_t descriptors_conv_27 = descriptors_vals[b];
28245                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
28246                 CHECK_ACCESS(descriptors_conv_27_ptr);
28247                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
28248                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
28249                 descriptors_constr.data[b] = descriptors_conv_27_conv;
28250         }
28251         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
28252         LDKCVec_TxOutZ outputs_constr;
28253         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
28254         if (outputs_constr.datalen > 0)
28255                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
28256         else
28257                 outputs_constr.data = NULL;
28258         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
28259         for (size_t h = 0; h < outputs_constr.datalen; h++) {
28260                 int64_t outputs_conv_7 = outputs_vals[h];
28261                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
28262                 CHECK_ACCESS(outputs_conv_7_ptr);
28263                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
28264                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
28265                 outputs_constr.data[h] = outputs_conv_7_conv;
28266         }
28267         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
28268         LDKCVec_u8Z change_destination_script_ref;
28269         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
28270         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
28271         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
28272         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
28273         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
28274         return (int64_t)ret_conv;
28275 }
28276
28277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
28278         LDKKeysManager this_arg_conv;
28279         this_arg_conv.inner = (void*)(this_arg & (~1));
28280         this_arg_conv.is_owned = false;
28281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28282         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
28283         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
28284         return (int64_t)ret_ret;
28285 }
28286
28287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28288         LDKPhantomKeysManager this_obj_conv;
28289         this_obj_conv.inner = (void*)(this_obj & (~1));
28290         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28292         PhantomKeysManager_free(this_obj_conv);
28293 }
28294
28295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
28296         LDKPhantomKeysManager this_arg_conv;
28297         this_arg_conv.inner = (void*)(this_arg & (~1));
28298         this_arg_conv.is_owned = false;
28299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28300         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
28301         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
28302         return (int64_t)ret_ret;
28303 }
28304
28305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1new(JNIEnv *env, jclass clz, int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos, int8_tArray cross_node_seed) {
28306         unsigned char seed_arr[32];
28307         CHECK((*env)->GetArrayLength(env, seed) == 32);
28308         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
28309         unsigned char (*seed_ref)[32] = &seed_arr;
28310         unsigned char cross_node_seed_arr[32];
28311         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
28312         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
28313         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
28314         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
28315         int64_t ret_ref = 0;
28316         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28317         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28319         ret_ref = (uintptr_t)ret_var.inner;
28320         if (ret_var.is_owned) {
28321                 ret_ref |= 1;
28322         }
28323         return ret_ref;
28324 }
28325
28326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_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) {
28327         LDKPhantomKeysManager this_arg_conv;
28328         this_arg_conv.inner = (void*)(this_arg & (~1));
28329         this_arg_conv.is_owned = false;
28330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28331         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
28332         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
28333         if (descriptors_constr.datalen > 0)
28334                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
28335         else
28336                 descriptors_constr.data = NULL;
28337         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
28338         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
28339                 int64_t descriptors_conv_27 = descriptors_vals[b];
28340                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
28341                 CHECK_ACCESS(descriptors_conv_27_ptr);
28342                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
28343                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
28344                 descriptors_constr.data[b] = descriptors_conv_27_conv;
28345         }
28346         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
28347         LDKCVec_TxOutZ outputs_constr;
28348         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
28349         if (outputs_constr.datalen > 0)
28350                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
28351         else
28352                 outputs_constr.data = NULL;
28353         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
28354         for (size_t h = 0; h < outputs_constr.datalen; h++) {
28355                 int64_t outputs_conv_7 = outputs_vals[h];
28356                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
28357                 CHECK_ACCESS(outputs_conv_7_ptr);
28358                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
28359                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
28360                 outputs_constr.data[h] = outputs_conv_7_conv;
28361         }
28362         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
28363         LDKCVec_u8Z change_destination_script_ref;
28364         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
28365         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
28366         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
28367         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
28368         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
28369         return (int64_t)ret_conv;
28370 }
28371
28372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1derive_1channel_1keys(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
28373         LDKPhantomKeysManager this_arg_conv;
28374         this_arg_conv.inner = (void*)(this_arg & (~1));
28375         this_arg_conv.is_owned = false;
28376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28377         unsigned char params_arr[32];
28378         CHECK((*env)->GetArrayLength(env, params) == 32);
28379         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
28380         unsigned char (*params_ref)[32] = &params_arr;
28381         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
28382         int64_t ret_ref = 0;
28383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28386         ret_ref = (uintptr_t)ret_var.inner;
28387         if (ret_var.is_owned) {
28388                 ret_ref |= 1;
28389         }
28390         return ret_ref;
28391 }
28392
28393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28394         LDKChannelManager this_obj_conv;
28395         this_obj_conv.inner = (void*)(this_obj & (~1));
28396         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28398         ChannelManager_free(this_obj_conv);
28399 }
28400
28401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28402         LDKChainParameters this_obj_conv;
28403         this_obj_conv.inner = (void*)(this_obj & (~1));
28404         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28406         ChainParameters_free(this_obj_conv);
28407 }
28408
28409 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
28410         LDKChainParameters this_ptr_conv;
28411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28412         this_ptr_conv.is_owned = false;
28413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28414         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
28415         return ret_conv;
28416 }
28417
28418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
28419         LDKChainParameters this_ptr_conv;
28420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28421         this_ptr_conv.is_owned = false;
28422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28423         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
28424         ChainParameters_set_network(&this_ptr_conv, val_conv);
28425 }
28426
28427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
28428         LDKChainParameters this_ptr_conv;
28429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28430         this_ptr_conv.is_owned = false;
28431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28432         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
28433         int64_t ret_ref = 0;
28434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28437         ret_ref = (uintptr_t)ret_var.inner;
28438         if (ret_var.is_owned) {
28439                 ret_ref |= 1;
28440         }
28441         return ret_ref;
28442 }
28443
28444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28445         LDKChainParameters this_ptr_conv;
28446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28447         this_ptr_conv.is_owned = false;
28448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28449         LDKBestBlock val_conv;
28450         val_conv.inner = (void*)(val & (~1));
28451         val_conv.is_owned = (val & 1) || (val == 0);
28452         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28453         val_conv = BestBlock_clone(&val_conv);
28454         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
28455 }
28456
28457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
28458         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
28459         LDKBestBlock best_block_arg_conv;
28460         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
28461         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
28462         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
28463         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
28464         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
28465         int64_t ret_ref = 0;
28466         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28467         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28469         ret_ref = (uintptr_t)ret_var.inner;
28470         if (ret_var.is_owned) {
28471                 ret_ref |= 1;
28472         }
28473         return ret_ref;
28474 }
28475
28476 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
28477         LDKChainParameters ret_var = ChainParameters_clone(arg);
28478 int64_t ret_ref = 0;
28479 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28480 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28481 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28482 ret_ref = (uintptr_t)ret_var.inner;
28483 if (ret_var.is_owned) {
28484         ret_ref |= 1;
28485 }
28486         return ret_ref;
28487 }
28488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28489         LDKChainParameters arg_conv;
28490         arg_conv.inner = (void*)(arg & (~1));
28491         arg_conv.is_owned = false;
28492         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28493         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
28494         return ret_conv;
28495 }
28496
28497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28498         LDKChainParameters orig_conv;
28499         orig_conv.inner = (void*)(orig & (~1));
28500         orig_conv.is_owned = false;
28501         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28502         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
28503         int64_t ret_ref = 0;
28504         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28505         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28507         ret_ref = (uintptr_t)ret_var.inner;
28508         if (ret_var.is_owned) {
28509                 ret_ref |= 1;
28510         }
28511         return ret_ref;
28512 }
28513
28514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28515         LDKCounterpartyForwardingInfo this_obj_conv;
28516         this_obj_conv.inner = (void*)(this_obj & (~1));
28517         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28519         CounterpartyForwardingInfo_free(this_obj_conv);
28520 }
28521
28522 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28523         LDKCounterpartyForwardingInfo this_ptr_conv;
28524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28525         this_ptr_conv.is_owned = false;
28526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28527         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
28528         return ret_conv;
28529 }
28530
28531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28532         LDKCounterpartyForwardingInfo this_ptr_conv;
28533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28534         this_ptr_conv.is_owned = false;
28535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28536         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
28537 }
28538
28539 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28540         LDKCounterpartyForwardingInfo this_ptr_conv;
28541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28542         this_ptr_conv.is_owned = false;
28543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28544         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
28545         return ret_conv;
28546 }
28547
28548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28549         LDKCounterpartyForwardingInfo this_ptr_conv;
28550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28551         this_ptr_conv.is_owned = false;
28552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28553         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
28554 }
28555
28556 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28557         LDKCounterpartyForwardingInfo this_ptr_conv;
28558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28559         this_ptr_conv.is_owned = false;
28560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28561         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
28562         return ret_conv;
28563 }
28564
28565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28566         LDKCounterpartyForwardingInfo this_ptr_conv;
28567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28568         this_ptr_conv.is_owned = false;
28569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28570         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
28571 }
28572
28573 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) {
28574         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
28575         int64_t ret_ref = 0;
28576         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28577         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28579         ret_ref = (uintptr_t)ret_var.inner;
28580         if (ret_var.is_owned) {
28581                 ret_ref |= 1;
28582         }
28583         return ret_ref;
28584 }
28585
28586 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
28587         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
28588 int64_t ret_ref = 0;
28589 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28590 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28591 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28592 ret_ref = (uintptr_t)ret_var.inner;
28593 if (ret_var.is_owned) {
28594         ret_ref |= 1;
28595 }
28596         return ret_ref;
28597 }
28598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28599         LDKCounterpartyForwardingInfo arg_conv;
28600         arg_conv.inner = (void*)(arg & (~1));
28601         arg_conv.is_owned = false;
28602         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28603         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
28604         return ret_conv;
28605 }
28606
28607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28608         LDKCounterpartyForwardingInfo orig_conv;
28609         orig_conv.inner = (void*)(orig & (~1));
28610         orig_conv.is_owned = false;
28611         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28612         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
28613         int64_t ret_ref = 0;
28614         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28615         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28617         ret_ref = (uintptr_t)ret_var.inner;
28618         if (ret_var.is_owned) {
28619                 ret_ref |= 1;
28620         }
28621         return ret_ref;
28622 }
28623
28624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28625         LDKChannelCounterparty this_obj_conv;
28626         this_obj_conv.inner = (void*)(this_obj & (~1));
28627         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28629         ChannelCounterparty_free(this_obj_conv);
28630 }
28631
28632 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28633         LDKChannelCounterparty this_ptr_conv;
28634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28635         this_ptr_conv.is_owned = false;
28636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28637         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28638         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
28639         return ret_arr;
28640 }
28641
28642 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28643         LDKChannelCounterparty this_ptr_conv;
28644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28645         this_ptr_conv.is_owned = false;
28646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28647         LDKPublicKey val_ref;
28648         CHECK((*env)->GetArrayLength(env, val) == 33);
28649         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28650         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
28651 }
28652
28653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28654         LDKChannelCounterparty this_ptr_conv;
28655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28656         this_ptr_conv.is_owned = false;
28657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28658         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
28659         int64_t ret_ref = 0;
28660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28663         ret_ref = (uintptr_t)ret_var.inner;
28664         if (ret_var.is_owned) {
28665                 ret_ref |= 1;
28666         }
28667         return ret_ref;
28668 }
28669
28670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28671         LDKChannelCounterparty 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         LDKInitFeatures val_conv;
28676         val_conv.inner = (void*)(val & (~1));
28677         val_conv.is_owned = (val & 1) || (val == 0);
28678         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28679         val_conv = InitFeatures_clone(&val_conv);
28680         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
28681 }
28682
28683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
28684         LDKChannelCounterparty this_ptr_conv;
28685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28686         this_ptr_conv.is_owned = false;
28687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28688         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
28689         return ret_conv;
28690 }
28691
28692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28693         LDKChannelCounterparty this_ptr_conv;
28694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28695         this_ptr_conv.is_owned = false;
28696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28697         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
28698 }
28699
28700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
28701         LDKChannelCounterparty this_ptr_conv;
28702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28703         this_ptr_conv.is_owned = false;
28704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28705         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
28706         int64_t ret_ref = 0;
28707         if ((uintptr_t)ret_var.inner > 4096) {
28708                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28709                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28711                 ret_ref = (uintptr_t)ret_var.inner;
28712                 if (ret_var.is_owned) {
28713                         ret_ref |= 1;
28714                 }
28715         }
28716         return ret_ref;
28717 }
28718
28719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28720         LDKChannelCounterparty this_ptr_conv;
28721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28722         this_ptr_conv.is_owned = false;
28723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28724         LDKCounterpartyForwardingInfo val_conv;
28725         val_conv.inner = (void*)(val & (~1));
28726         val_conv.is_owned = (val & 1) || (val == 0);
28727         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28728         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
28729         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
28730 }
28731
28732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28733         LDKChannelCounterparty this_ptr_conv;
28734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28735         this_ptr_conv.is_owned = false;
28736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28737         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28738         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
28739         int64_t ret_ref = (uintptr_t)ret_copy;
28740         return ret_ref;
28741 }
28742
28743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28744         LDKChannelCounterparty this_ptr_conv;
28745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28746         this_ptr_conv.is_owned = false;
28747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28748         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28749         CHECK_ACCESS(val_ptr);
28750         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28751         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
28752         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
28753 }
28754
28755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28756         LDKChannelCounterparty this_ptr_conv;
28757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28758         this_ptr_conv.is_owned = false;
28759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28760         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28761         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
28762         int64_t ret_ref = (uintptr_t)ret_copy;
28763         return ret_ref;
28764 }
28765
28766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28767         LDKChannelCounterparty this_ptr_conv;
28768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28769         this_ptr_conv.is_owned = false;
28770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28771         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28772         CHECK_ACCESS(val_ptr);
28773         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28774         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
28775         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
28776 }
28777
28778 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, int64_t outbound_htlc_minimum_msat_arg, int64_t outbound_htlc_maximum_msat_arg) {
28779         LDKPublicKey node_id_arg_ref;
28780         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
28781         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
28782         LDKInitFeatures features_arg_conv;
28783         features_arg_conv.inner = (void*)(features_arg & (~1));
28784         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
28785         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
28786         features_arg_conv = InitFeatures_clone(&features_arg_conv);
28787         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
28788         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
28789         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
28790         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
28791         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
28792         void* outbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1);
28793         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
28794         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
28795         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1));
28796         void* outbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1);
28797         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
28798         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
28799         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1));
28800         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv, outbound_htlc_minimum_msat_arg_conv, outbound_htlc_maximum_msat_arg_conv);
28801         int64_t ret_ref = 0;
28802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28805         ret_ref = (uintptr_t)ret_var.inner;
28806         if (ret_var.is_owned) {
28807                 ret_ref |= 1;
28808         }
28809         return ret_ref;
28810 }
28811
28812 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
28813         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
28814 int64_t ret_ref = 0;
28815 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28816 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28817 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28818 ret_ref = (uintptr_t)ret_var.inner;
28819 if (ret_var.is_owned) {
28820         ret_ref |= 1;
28821 }
28822         return ret_ref;
28823 }
28824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28825         LDKChannelCounterparty arg_conv;
28826         arg_conv.inner = (void*)(arg & (~1));
28827         arg_conv.is_owned = false;
28828         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28829         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
28830         return ret_conv;
28831 }
28832
28833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28834         LDKChannelCounterparty orig_conv;
28835         orig_conv.inner = (void*)(orig & (~1));
28836         orig_conv.is_owned = false;
28837         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28838         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
28839         int64_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 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28851         LDKChannelDetails this_obj_conv;
28852         this_obj_conv.inner = (void*)(this_obj & (~1));
28853         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28855         ChannelDetails_free(this_obj_conv);
28856 }
28857
28858 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28859         LDKChannelDetails this_ptr_conv;
28860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28861         this_ptr_conv.is_owned = false;
28862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28863         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28864         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
28865         return ret_arr;
28866 }
28867
28868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28869         LDKChannelDetails this_ptr_conv;
28870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28871         this_ptr_conv.is_owned = false;
28872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28873         LDKThirtyTwoBytes val_ref;
28874         CHECK((*env)->GetArrayLength(env, val) == 32);
28875         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28876         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
28877 }
28878
28879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
28880         LDKChannelDetails this_ptr_conv;
28881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28882         this_ptr_conv.is_owned = false;
28883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28884         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
28885         int64_t ret_ref = 0;
28886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28889         ret_ref = (uintptr_t)ret_var.inner;
28890         if (ret_var.is_owned) {
28891                 ret_ref |= 1;
28892         }
28893         return ret_ref;
28894 }
28895
28896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28897         LDKChannelDetails 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         LDKChannelCounterparty val_conv;
28902         val_conv.inner = (void*)(val & (~1));
28903         val_conv.is_owned = (val & 1) || (val == 0);
28904         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28905         val_conv = ChannelCounterparty_clone(&val_conv);
28906         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
28907 }
28908
28909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
28910         LDKChannelDetails this_ptr_conv;
28911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28912         this_ptr_conv.is_owned = false;
28913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28914         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
28915         int64_t ret_ref = 0;
28916         if ((uintptr_t)ret_var.inner > 4096) {
28917                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28918                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28920                 ret_ref = (uintptr_t)ret_var.inner;
28921                 if (ret_var.is_owned) {
28922                         ret_ref |= 1;
28923                 }
28924         }
28925         return ret_ref;
28926 }
28927
28928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28929         LDKChannelDetails this_ptr_conv;
28930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28931         this_ptr_conv.is_owned = false;
28932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28933         LDKOutPoint val_conv;
28934         val_conv.inner = (void*)(val & (~1));
28935         val_conv.is_owned = (val & 1) || (val == 0);
28936         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28937         val_conv = OutPoint_clone(&val_conv);
28938         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
28939 }
28940
28941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
28942         LDKChannelDetails this_ptr_conv;
28943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28944         this_ptr_conv.is_owned = false;
28945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28946         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
28947         int64_t ret_ref = 0;
28948         if ((uintptr_t)ret_var.inner > 4096) {
28949                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28950                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28952                 ret_ref = (uintptr_t)ret_var.inner;
28953                 if (ret_var.is_owned) {
28954                         ret_ref |= 1;
28955                 }
28956         }
28957         return ret_ref;
28958 }
28959
28960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28961         LDKChannelDetails this_ptr_conv;
28962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28963         this_ptr_conv.is_owned = false;
28964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28965         LDKChannelTypeFeatures val_conv;
28966         val_conv.inner = (void*)(val & (~1));
28967         val_conv.is_owned = (val & 1) || (val == 0);
28968         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28969         val_conv = ChannelTypeFeatures_clone(&val_conv);
28970         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
28971 }
28972
28973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28974         LDKChannelDetails this_ptr_conv;
28975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28976         this_ptr_conv.is_owned = false;
28977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28978         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28979         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
28980         int64_t ret_ref = (uintptr_t)ret_copy;
28981         return ret_ref;
28982 }
28983
28984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28985         LDKChannelDetails this_ptr_conv;
28986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28987         this_ptr_conv.is_owned = false;
28988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28989         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28990         CHECK_ACCESS(val_ptr);
28991         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28992         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
28993         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
28994 }
28995
28996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
28997         LDKChannelDetails this_ptr_conv;
28998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28999         this_ptr_conv.is_owned = false;
29000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29001         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29002         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
29003         int64_t ret_ref = (uintptr_t)ret_copy;
29004         return ret_ref;
29005 }
29006
29007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29008         LDKChannelDetails this_ptr_conv;
29009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29010         this_ptr_conv.is_owned = false;
29011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29012         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29013         CHECK_ACCESS(val_ptr);
29014         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29015         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29016         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
29017 }
29018
29019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29020         LDKChannelDetails this_ptr_conv;
29021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29022         this_ptr_conv.is_owned = false;
29023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29024         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29025         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
29026         int64_t ret_ref = (uintptr_t)ret_copy;
29027         return ret_ref;
29028 }
29029
29030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29031         LDKChannelDetails this_ptr_conv;
29032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29033         this_ptr_conv.is_owned = false;
29034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29035         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29036         CHECK_ACCESS(val_ptr);
29037         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29038         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29039         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
29040 }
29041
29042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29043         LDKChannelDetails this_ptr_conv;
29044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29045         this_ptr_conv.is_owned = false;
29046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29047         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
29048         return ret_conv;
29049 }
29050
29051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29052         LDKChannelDetails this_ptr_conv;
29053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29054         this_ptr_conv.is_owned = false;
29055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29056         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
29057 }
29058
29059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
29060         LDKChannelDetails this_ptr_conv;
29061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29062         this_ptr_conv.is_owned = false;
29063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29064         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29065         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
29066         int64_t ret_ref = (uintptr_t)ret_copy;
29067         return ret_ref;
29068 }
29069
29070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29071         LDKChannelDetails this_ptr_conv;
29072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29073         this_ptr_conv.is_owned = false;
29074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29075         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29076         CHECK_ACCESS(val_ptr);
29077         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29078         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29079         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
29080 }
29081
29082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29083         LDKChannelDetails this_ptr_conv;
29084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29085         this_ptr_conv.is_owned = false;
29086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29087         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
29088         return ret_conv;
29089 }
29090
29091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29092         LDKChannelDetails this_ptr_conv;
29093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29094         this_ptr_conv.is_owned = false;
29095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29096         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
29097 }
29098
29099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29100         LDKChannelDetails this_ptr_conv;
29101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29102         this_ptr_conv.is_owned = false;
29103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29104         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
29105         return ret_conv;
29106 }
29107
29108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29109         LDKChannelDetails this_ptr_conv;
29110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29111         this_ptr_conv.is_owned = false;
29112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29113         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
29114 }
29115
29116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29117         LDKChannelDetails this_ptr_conv;
29118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29119         this_ptr_conv.is_owned = false;
29120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29121         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
29122         return ret_conv;
29123 }
29124
29125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29126         LDKChannelDetails this_ptr_conv;
29127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29128         this_ptr_conv.is_owned = false;
29129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29130         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
29131 }
29132
29133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29134         LDKChannelDetails this_ptr_conv;
29135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29136         this_ptr_conv.is_owned = false;
29137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29138         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
29139         return ret_conv;
29140 }
29141
29142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29143         LDKChannelDetails 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         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
29148 }
29149
29150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29151         LDKChannelDetails this_ptr_conv;
29152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29153         this_ptr_conv.is_owned = false;
29154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29155         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
29156         return ret_conv;
29157 }
29158
29159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29160         LDKChannelDetails this_ptr_conv;
29161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29162         this_ptr_conv.is_owned = false;
29163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29164         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
29165 }
29166
29167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
29168         LDKChannelDetails this_ptr_conv;
29169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29170         this_ptr_conv.is_owned = false;
29171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29172         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
29173         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
29174         int64_t ret_ref = (uintptr_t)ret_copy;
29175         return ret_ref;
29176 }
29177
29178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29179         LDKChannelDetails this_ptr_conv;
29180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29181         this_ptr_conv.is_owned = false;
29182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29183         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29184         CHECK_ACCESS(val_ptr);
29185         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
29186         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
29187         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
29188 }
29189
29190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
29191         LDKChannelDetails this_ptr_conv;
29192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29193         this_ptr_conv.is_owned = false;
29194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29195         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
29196         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
29197         int64_t ret_ref = (uintptr_t)ret_copy;
29198         return ret_ref;
29199 }
29200
29201 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) {
29202         LDKChannelDetails this_ptr_conv;
29203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29204         this_ptr_conv.is_owned = false;
29205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29206         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29207         CHECK_ACCESS(val_ptr);
29208         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
29209         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
29210         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
29211 }
29212
29213 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
29214         LDKChannelDetails this_ptr_conv;
29215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29216         this_ptr_conv.is_owned = false;
29217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29218         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
29219         return ret_conv;
29220 }
29221
29222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29223         LDKChannelDetails this_ptr_conv;
29224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29225         this_ptr_conv.is_owned = false;
29226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29227         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
29228 }
29229
29230 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
29231         LDKChannelDetails this_ptr_conv;
29232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29233         this_ptr_conv.is_owned = false;
29234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29235         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
29236         return ret_conv;
29237 }
29238
29239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29240         LDKChannelDetails this_ptr_conv;
29241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29242         this_ptr_conv.is_owned = false;
29243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29244         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
29245 }
29246
29247 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
29248         LDKChannelDetails this_ptr_conv;
29249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29250         this_ptr_conv.is_owned = false;
29251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29252         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
29253         return ret_conv;
29254 }
29255
29256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29257         LDKChannelDetails this_ptr_conv;
29258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29259         this_ptr_conv.is_owned = false;
29260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29261         ChannelDetails_set_is_usable(&this_ptr_conv, val);
29262 }
29263
29264 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
29265         LDKChannelDetails this_ptr_conv;
29266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29267         this_ptr_conv.is_owned = false;
29268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29269         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
29270         return ret_conv;
29271 }
29272
29273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29274         LDKChannelDetails this_ptr_conv;
29275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29276         this_ptr_conv.is_owned = false;
29277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29278         ChannelDetails_set_is_public(&this_ptr_conv, val);
29279 }
29280
29281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29282         LDKChannelDetails this_ptr_conv;
29283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29284         this_ptr_conv.is_owned = false;
29285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29286         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29287         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
29288         int64_t ret_ref = (uintptr_t)ret_copy;
29289         return ret_ref;
29290 }
29291
29292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29293         LDKChannelDetails this_ptr_conv;
29294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29295         this_ptr_conv.is_owned = false;
29296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29297         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29298         CHECK_ACCESS(val_ptr);
29299         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29300         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29301         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
29302 }
29303
29304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29305         LDKChannelDetails this_ptr_conv;
29306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29307         this_ptr_conv.is_owned = false;
29308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29309         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29310         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
29311         int64_t ret_ref = (uintptr_t)ret_copy;
29312         return ret_ref;
29313 }
29314
29315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29316         LDKChannelDetails this_ptr_conv;
29317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29318         this_ptr_conv.is_owned = false;
29319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29320         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29321         CHECK_ACCESS(val_ptr);
29322         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29323         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29324         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
29325 }
29326
29327 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 channel_type_arg, int64_t short_channel_id_arg, int64_t outbound_scid_alias_arg, int64_t inbound_scid_alias_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 next_outbound_htlc_limit_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_channel_ready_arg, jboolean is_usable_arg, jboolean is_public_arg, int64_t inbound_htlc_minimum_msat_arg, int64_t inbound_htlc_maximum_msat_arg) {
29328         LDKThirtyTwoBytes channel_id_arg_ref;
29329         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
29330         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
29331         LDKChannelCounterparty counterparty_arg_conv;
29332         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
29333         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
29334         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
29335         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
29336         LDKOutPoint funding_txo_arg_conv;
29337         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
29338         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
29339         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
29340         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
29341         LDKChannelTypeFeatures channel_type_arg_conv;
29342         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
29343         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
29344         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
29345         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
29346         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
29347         CHECK_ACCESS(short_channel_id_arg_ptr);
29348         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
29349         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
29350         void* outbound_scid_alias_arg_ptr = (void*)(((uintptr_t)outbound_scid_alias_arg) & ~1);
29351         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
29352         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
29353         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_scid_alias_arg) & ~1));
29354         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
29355         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
29356         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
29357         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
29358         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
29359         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
29360         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
29361         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
29362         CHECK_ACCESS(confirmations_required_arg_ptr);
29363         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
29364         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
29365         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
29366         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
29367         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
29368         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
29369         void* inbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1);
29370         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
29371         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
29372         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1));
29373         void* inbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1);
29374         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
29375         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
29376         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1));
29377         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, outbound_scid_alias_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, next_outbound_htlc_limit_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_channel_ready_arg, is_usable_arg, is_public_arg, inbound_htlc_minimum_msat_arg_conv, inbound_htlc_maximum_msat_arg_conv);
29378         int64_t ret_ref = 0;
29379         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29380         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29381         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29382         ret_ref = (uintptr_t)ret_var.inner;
29383         if (ret_var.is_owned) {
29384                 ret_ref |= 1;
29385         }
29386         return ret_ref;
29387 }
29388
29389 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
29390         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
29391 int64_t ret_ref = 0;
29392 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29393 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29394 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29395 ret_ref = (uintptr_t)ret_var.inner;
29396 if (ret_var.is_owned) {
29397         ret_ref |= 1;
29398 }
29399         return ret_ref;
29400 }
29401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29402         LDKChannelDetails arg_conv;
29403         arg_conv.inner = (void*)(arg & (~1));
29404         arg_conv.is_owned = false;
29405         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29406         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
29407         return ret_conv;
29408 }
29409
29410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29411         LDKChannelDetails orig_conv;
29412         orig_conv.inner = (void*)(orig & (~1));
29413         orig_conv.is_owned = false;
29414         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29415         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
29416         int64_t ret_ref = 0;
29417         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29418         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29420         ret_ref = (uintptr_t)ret_var.inner;
29421         if (ret_var.is_owned) {
29422                 ret_ref |= 1;
29423         }
29424         return ret_ref;
29425 }
29426
29427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
29428         LDKChannelDetails this_arg_conv;
29429         this_arg_conv.inner = (void*)(this_arg & (~1));
29430         this_arg_conv.is_owned = false;
29431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29432         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29433         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
29434         int64_t ret_ref = (uintptr_t)ret_copy;
29435         return ret_ref;
29436 }
29437
29438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
29439         LDKChannelDetails this_arg_conv;
29440         this_arg_conv.inner = (void*)(this_arg & (~1));
29441         this_arg_conv.is_owned = false;
29442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29443         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29444         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
29445         int64_t ret_ref = (uintptr_t)ret_copy;
29446         return ret_ref;
29447 }
29448
29449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29450         if ((this_ptr & 1) != 0) return;
29451         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
29452         CHECK_ACCESS(this_ptr_ptr);
29453         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
29454         FREE((void*)this_ptr);
29455         PaymentSendFailure_free(this_ptr_conv);
29456 }
29457
29458 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
29459         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29460         *ret_copy = PaymentSendFailure_clone(arg);
29461 int64_t ret_ref = (uintptr_t)ret_copy;
29462         return ret_ref;
29463 }
29464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29465         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
29466         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
29467         return ret_conv;
29468 }
29469
29470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29471         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
29472         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29473         *ret_copy = PaymentSendFailure_clone(orig_conv);
29474         int64_t ret_ref = (uintptr_t)ret_copy;
29475         return ret_ref;
29476 }
29477
29478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
29479         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
29480         CHECK_ACCESS(a_ptr);
29481         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
29482         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
29483         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29484         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
29485         int64_t ret_ref = (uintptr_t)ret_copy;
29486         return ret_ref;
29487 }
29488
29489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
29490         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
29491         a_constr.datalen = (*env)->GetArrayLength(env, a);
29492         if (a_constr.datalen > 0)
29493                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
29494         else
29495                 a_constr.data = NULL;
29496         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
29497         for (size_t w = 0; w < a_constr.datalen; w++) {
29498                 int64_t a_conv_22 = a_vals[w];
29499                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
29500                 CHECK_ACCESS(a_conv_22_ptr);
29501                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
29502                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
29503                 a_constr.data[w] = a_conv_22_conv;
29504         }
29505         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
29506         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29507         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
29508         int64_t ret_ref = (uintptr_t)ret_copy;
29509         return ret_ref;
29510 }
29511
29512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
29513         LDKCVec_APIErrorZ a_constr;
29514         a_constr.datalen = (*env)->GetArrayLength(env, a);
29515         if (a_constr.datalen > 0)
29516                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
29517         else
29518                 a_constr.data = NULL;
29519         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
29520         for (size_t k = 0; k < a_constr.datalen; k++) {
29521                 int64_t a_conv_10 = a_vals[k];
29522                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
29523                 CHECK_ACCESS(a_conv_10_ptr);
29524                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
29525                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
29526                 a_constr.data[k] = a_conv_10_conv;
29527         }
29528         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
29529         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29530         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
29531         int64_t ret_ref = (uintptr_t)ret_copy;
29532         return ret_ref;
29533 }
29534
29535 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) {
29536         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
29537         results_constr.datalen = (*env)->GetArrayLength(env, results);
29538         if (results_constr.datalen > 0)
29539                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
29540         else
29541                 results_constr.data = NULL;
29542         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
29543         for (size_t w = 0; w < results_constr.datalen; w++) {
29544                 int64_t results_conv_22 = results_vals[w];
29545                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
29546                 CHECK_ACCESS(results_conv_22_ptr);
29547                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
29548                 results_constr.data[w] = results_conv_22_conv;
29549         }
29550         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
29551         LDKRouteParameters failed_paths_retry_conv;
29552         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
29553         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
29554         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
29555         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
29556         LDKThirtyTwoBytes payment_id_ref;
29557         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29558         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29559         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29560         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
29561         int64_t ret_ref = (uintptr_t)ret_copy;
29562         return ret_ref;
29563 }
29564
29565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29566         LDKPhantomRouteHints this_obj_conv;
29567         this_obj_conv.inner = (void*)(this_obj & (~1));
29568         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29570         PhantomRouteHints_free(this_obj_conv);
29571 }
29572
29573 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
29574         LDKPhantomRouteHints this_ptr_conv;
29575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29576         this_ptr_conv.is_owned = false;
29577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29578         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
29579         int64_tArray ret_arr = NULL;
29580         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29581         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29582         for (size_t q = 0; q < ret_var.datalen; q++) {
29583                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29584                 int64_t ret_conv_16_ref = 0;
29585                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29586                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29587                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29588                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
29589                 if (ret_conv_16_var.is_owned) {
29590                         ret_conv_16_ref |= 1;
29591                 }
29592                 ret_arr_ptr[q] = ret_conv_16_ref;
29593         }
29594         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29595         FREE(ret_var.data);
29596         return ret_arr;
29597 }
29598
29599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
29600         LDKPhantomRouteHints this_ptr_conv;
29601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29602         this_ptr_conv.is_owned = false;
29603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29604         LDKCVec_ChannelDetailsZ val_constr;
29605         val_constr.datalen = (*env)->GetArrayLength(env, val);
29606         if (val_constr.datalen > 0)
29607                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29608         else
29609                 val_constr.data = NULL;
29610         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
29611         for (size_t q = 0; q < val_constr.datalen; q++) {
29612                 int64_t val_conv_16 = val_vals[q];
29613                 LDKChannelDetails val_conv_16_conv;
29614                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
29615                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
29616                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
29617                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
29618                 val_constr.data[q] = val_conv_16_conv;
29619         }
29620         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
29621         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
29622 }
29623
29624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
29625         LDKPhantomRouteHints this_ptr_conv;
29626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29627         this_ptr_conv.is_owned = false;
29628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29629         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
29630         return ret_conv;
29631 }
29632
29633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29634         LDKPhantomRouteHints this_ptr_conv;
29635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29636         this_ptr_conv.is_owned = false;
29637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29638         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
29639 }
29640
29641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
29642         LDKPhantomRouteHints this_ptr_conv;
29643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29644         this_ptr_conv.is_owned = false;
29645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29646         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29647         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
29648         return ret_arr;
29649 }
29650
29651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29652         LDKPhantomRouteHints 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         LDKPublicKey val_ref;
29657         CHECK((*env)->GetArrayLength(env, val) == 33);
29658         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29659         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
29660 }
29661
29662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1new(JNIEnv *env, jclass clz, int64_tArray channels_arg, int64_t phantom_scid_arg, int8_tArray real_node_pubkey_arg) {
29663         LDKCVec_ChannelDetailsZ channels_arg_constr;
29664         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
29665         if (channels_arg_constr.datalen > 0)
29666                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29667         else
29668                 channels_arg_constr.data = NULL;
29669         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
29670         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
29671                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
29672                 LDKChannelDetails channels_arg_conv_16_conv;
29673                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
29674                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
29675                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
29676                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
29677                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
29678         }
29679         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
29680         LDKPublicKey real_node_pubkey_arg_ref;
29681         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
29682         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
29683         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
29684         int64_t ret_ref = 0;
29685         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29686         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29688         ret_ref = (uintptr_t)ret_var.inner;
29689         if (ret_var.is_owned) {
29690                 ret_ref |= 1;
29691         }
29692         return ret_ref;
29693 }
29694
29695 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
29696         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
29697 int64_t ret_ref = 0;
29698 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29699 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29700 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29701 ret_ref = (uintptr_t)ret_var.inner;
29702 if (ret_var.is_owned) {
29703         ret_ref |= 1;
29704 }
29705         return ret_ref;
29706 }
29707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29708         LDKPhantomRouteHints arg_conv;
29709         arg_conv.inner = (void*)(arg & (~1));
29710         arg_conv.is_owned = false;
29711         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29712         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
29713         return ret_conv;
29714 }
29715
29716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29717         LDKPhantomRouteHints orig_conv;
29718         orig_conv.inner = (void*)(orig & (~1));
29719         orig_conv.is_owned = false;
29720         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29721         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
29722         int64_t ret_ref = 0;
29723         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29724         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29726         ret_ref = (uintptr_t)ret_var.inner;
29727         if (ret_var.is_owned) {
29728                 ret_ref |= 1;
29729         }
29730         return ret_ref;
29731 }
29732
29733 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) {
29734         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
29735         CHECK_ACCESS(fee_est_ptr);
29736         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
29737         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
29738                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29739                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
29740         }
29741         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
29742         CHECK_ACCESS(chain_monitor_ptr);
29743         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
29744         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
29745                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29746                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
29747         }
29748         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
29749         CHECK_ACCESS(tx_broadcaster_ptr);
29750         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
29751         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29752                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29753                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
29754         }
29755         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
29756         CHECK_ACCESS(logger_ptr);
29757         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29758         if (logger_conv.free == LDKLogger_JCalls_free) {
29759                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29760                 LDKLogger_JCalls_cloned(&logger_conv);
29761         }
29762         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
29763         CHECK_ACCESS(keys_manager_ptr);
29764         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
29765         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
29766                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29767                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
29768         }
29769         LDKUserConfig config_conv;
29770         config_conv.inner = (void*)(config & (~1));
29771         config_conv.is_owned = (config & 1) || (config == 0);
29772         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
29773         config_conv = UserConfig_clone(&config_conv);
29774         LDKChainParameters params_conv;
29775         params_conv.inner = (void*)(params & (~1));
29776         params_conv.is_owned = (params & 1) || (params == 0);
29777         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
29778         params_conv = ChainParameters_clone(&params_conv);
29779         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
29780         int64_t ret_ref = 0;
29781         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29782         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29784         ret_ref = (uintptr_t)ret_var.inner;
29785         if (ret_var.is_owned) {
29786                 ret_ref |= 1;
29787         }
29788         return ret_ref;
29789 }
29790
29791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
29792         LDKChannelManager this_arg_conv;
29793         this_arg_conv.inner = (void*)(this_arg & (~1));
29794         this_arg_conv.is_owned = false;
29795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29796         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
29797         int64_t ret_ref = 0;
29798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29801         ret_ref = (uintptr_t)ret_var.inner;
29802         if (ret_var.is_owned) {
29803                 ret_ref |= 1;
29804         }
29805         return ret_ref;
29806 }
29807
29808 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) {
29809         LDKChannelManager this_arg_conv;
29810         this_arg_conv.inner = (void*)(this_arg & (~1));
29811         this_arg_conv.is_owned = false;
29812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29813         LDKPublicKey their_network_key_ref;
29814         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
29815         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
29816         LDKUserConfig override_config_conv;
29817         override_config_conv.inner = (void*)(override_config & (~1));
29818         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
29819         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
29820         override_config_conv = UserConfig_clone(&override_config_conv);
29821         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
29822         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
29823         return (int64_t)ret_conv;
29824 }
29825
29826 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29827         LDKChannelManager this_arg_conv;
29828         this_arg_conv.inner = (void*)(this_arg & (~1));
29829         this_arg_conv.is_owned = false;
29830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29831         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
29832         int64_tArray ret_arr = NULL;
29833         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29834         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29835         for (size_t q = 0; q < ret_var.datalen; q++) {
29836                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29837                 int64_t ret_conv_16_ref = 0;
29838                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29839                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29840                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29841                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
29842                 if (ret_conv_16_var.is_owned) {
29843                         ret_conv_16_ref |= 1;
29844                 }
29845                 ret_arr_ptr[q] = ret_conv_16_ref;
29846         }
29847         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29848         FREE(ret_var.data);
29849         return ret_arr;
29850 }
29851
29852 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29853         LDKChannelManager this_arg_conv;
29854         this_arg_conv.inner = (void*)(this_arg & (~1));
29855         this_arg_conv.is_owned = false;
29856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29857         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
29858         int64_tArray ret_arr = NULL;
29859         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29860         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29861         for (size_t q = 0; q < ret_var.datalen; q++) {
29862                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29863                 int64_t ret_conv_16_ref = 0;
29864                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29865                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29866                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29867                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
29868                 if (ret_conv_16_var.is_owned) {
29869                         ret_conv_16_ref |= 1;
29870                 }
29871                 ret_arr_ptr[q] = ret_conv_16_ref;
29872         }
29873         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29874         FREE(ret_var.data);
29875         return ret_arr;
29876 }
29877
29878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
29879         LDKChannelManager this_arg_conv;
29880         this_arg_conv.inner = (void*)(this_arg & (~1));
29881         this_arg_conv.is_owned = false;
29882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29883         unsigned char channel_id_arr[32];
29884         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29885         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29886         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29887         LDKPublicKey counterparty_node_id_ref;
29888         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
29889         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
29890         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29891         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
29892         return (int64_t)ret_conv;
29893 }
29894
29895 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, int8_tArray counterparty_node_id, int32_t target_feerate_sats_per_1000_weight) {
29896         LDKChannelManager this_arg_conv;
29897         this_arg_conv.inner = (void*)(this_arg & (~1));
29898         this_arg_conv.is_owned = false;
29899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29900         unsigned char channel_id_arr[32];
29901         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29902         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29903         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29904         LDKPublicKey counterparty_node_id_ref;
29905         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
29906         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
29907         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29908         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
29909         return (int64_t)ret_conv;
29910 }
29911
29912 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, int8_tArray counterparty_node_id) {
29913         LDKChannelManager this_arg_conv;
29914         this_arg_conv.inner = (void*)(this_arg & (~1));
29915         this_arg_conv.is_owned = false;
29916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29917         unsigned char channel_id_arr[32];
29918         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29919         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29920         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29921         LDKPublicKey counterparty_node_id_ref;
29922         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
29923         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
29924         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29925         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
29926         return (int64_t)ret_conv;
29927 }
29928
29929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29930         LDKChannelManager this_arg_conv;
29931         this_arg_conv.inner = (void*)(this_arg & (~1));
29932         this_arg_conv.is_owned = false;
29933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29934         ChannelManager_force_close_all_channels(&this_arg_conv);
29935 }
29936
29937 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) {
29938         LDKChannelManager this_arg_conv;
29939         this_arg_conv.inner = (void*)(this_arg & (~1));
29940         this_arg_conv.is_owned = false;
29941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29942         LDKRoute route_conv;
29943         route_conv.inner = (void*)(route & (~1));
29944         route_conv.is_owned = false;
29945         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29946         LDKThirtyTwoBytes payment_hash_ref;
29947         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29948         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29949         LDKThirtyTwoBytes payment_secret_ref;
29950         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
29951         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
29952         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
29953         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
29954         return (int64_t)ret_conv;
29955 }
29956
29957 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) {
29958         LDKChannelManager this_arg_conv;
29959         this_arg_conv.inner = (void*)(this_arg & (~1));
29960         this_arg_conv.is_owned = false;
29961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29962         LDKRoute route_conv;
29963         route_conv.inner = (void*)(route & (~1));
29964         route_conv.is_owned = false;
29965         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29966         LDKThirtyTwoBytes payment_id_ref;
29967         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29968         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29969         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
29970         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
29971         return (int64_t)ret_conv;
29972 }
29973
29974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
29975         LDKChannelManager this_arg_conv;
29976         this_arg_conv.inner = (void*)(this_arg & (~1));
29977         this_arg_conv.is_owned = false;
29978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29979         LDKThirtyTwoBytes payment_id_ref;
29980         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29981         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29982         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
29983 }
29984
29985 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) {
29986         LDKChannelManager this_arg_conv;
29987         this_arg_conv.inner = (void*)(this_arg & (~1));
29988         this_arg_conv.is_owned = false;
29989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29990         LDKRoute route_conv;
29991         route_conv.inner = (void*)(route & (~1));
29992         route_conv.is_owned = false;
29993         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29994         LDKThirtyTwoBytes payment_preimage_ref;
29995         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
29996         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
29997         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
29998         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
29999         return (int64_t)ret_conv;
30000 }
30001
30002 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 counterparty_node_id, int8_tArray funding_transaction) {
30003         LDKChannelManager this_arg_conv;
30004         this_arg_conv.inner = (void*)(this_arg & (~1));
30005         this_arg_conv.is_owned = false;
30006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30007         unsigned char temporary_channel_id_arr[32];
30008         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
30009         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
30010         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
30011         LDKPublicKey counterparty_node_id_ref;
30012         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30013         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30014         LDKTransaction funding_transaction_ref;
30015         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
30016         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
30017         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
30018         funding_transaction_ref.data_is_owned = true;
30019         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30020         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
30021         return (int64_t)ret_conv;
30022 }
30023
30024 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) {
30025         LDKChannelManager this_arg_conv;
30026         this_arg_conv.inner = (void*)(this_arg & (~1));
30027         this_arg_conv.is_owned = false;
30028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30029         LDKThreeBytes rgb_ref;
30030         CHECK((*env)->GetArrayLength(env, rgb) == 3);
30031         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
30032         LDKThirtyTwoBytes alias_ref;
30033         CHECK((*env)->GetArrayLength(env, alias) == 32);
30034         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
30035         LDKCVec_NetAddressZ addresses_constr;
30036         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
30037         if (addresses_constr.datalen > 0)
30038                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
30039         else
30040                 addresses_constr.data = NULL;
30041         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
30042         for (size_t m = 0; m < addresses_constr.datalen; m++) {
30043                 int64_t addresses_conv_12 = addresses_vals[m];
30044                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
30045                 CHECK_ACCESS(addresses_conv_12_ptr);
30046                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
30047                 addresses_constr.data[m] = addresses_conv_12_conv;
30048         }
30049         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
30050         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
30051 }
30052
30053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
30054         LDKChannelManager this_arg_conv;
30055         this_arg_conv.inner = (void*)(this_arg & (~1));
30056         this_arg_conv.is_owned = false;
30057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30058         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
30059 }
30060
30061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
30062         LDKChannelManager this_arg_conv;
30063         this_arg_conv.inner = (void*)(this_arg & (~1));
30064         this_arg_conv.is_owned = false;
30065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30066         ChannelManager_timer_tick_occurred(&this_arg_conv);
30067 }
30068
30069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
30070         LDKChannelManager this_arg_conv;
30071         this_arg_conv.inner = (void*)(this_arg & (~1));
30072         this_arg_conv.is_owned = false;
30073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30074         unsigned char payment_hash_arr[32];
30075         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30076         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
30077         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
30078         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
30079 }
30080
30081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
30082         LDKChannelManager this_arg_conv;
30083         this_arg_conv.inner = (void*)(this_arg & (~1));
30084         this_arg_conv.is_owned = false;
30085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30086         LDKThirtyTwoBytes payment_preimage_ref;
30087         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
30088         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
30089         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
30090 }
30091
30092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
30093         LDKChannelManager this_arg_conv;
30094         this_arg_conv.inner = (void*)(this_arg & (~1));
30095         this_arg_conv.is_owned = false;
30096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30097         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30098         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
30099         return ret_arr;
30100 }
30101
30102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
30103         LDKChannelManager this_arg_conv;
30104         this_arg_conv.inner = (void*)(this_arg & (~1));
30105         this_arg_conv.is_owned = false;
30106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30107         unsigned char temporary_channel_id_arr[32];
30108         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
30109         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
30110         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
30111         LDKPublicKey counterparty_node_id_ref;
30112         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30113         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30114         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30115         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
30116         return (int64_t)ret_conv;
30117 }
30118
30119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel_1from_1trusted_1peer_10conf(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
30120         LDKChannelManager this_arg_conv;
30121         this_arg_conv.inner = (void*)(this_arg & (~1));
30122         this_arg_conv.is_owned = false;
30123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30124         unsigned char temporary_channel_id_arr[32];
30125         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
30126         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
30127         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
30128         LDKPublicKey counterparty_node_id_ref;
30129         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30130         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30131         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30132         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
30133         return (int64_t)ret_conv;
30134 }
30135
30136 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) {
30137         LDKChannelManager this_arg_conv;
30138         this_arg_conv.inner = (void*)(this_arg & (~1));
30139         this_arg_conv.is_owned = false;
30140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30141         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30142         CHECK_ACCESS(min_value_msat_ptr);
30143         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30144         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30145         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
30146         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
30147         return (int64_t)ret_conv;
30148 }
30149
30150 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) {
30151         LDKChannelManager this_arg_conv;
30152         this_arg_conv.inner = (void*)(this_arg & (~1));
30153         this_arg_conv.is_owned = false;
30154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30155         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30156         CHECK_ACCESS(min_value_msat_ptr);
30157         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30158         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30159         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
30160         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
30161         return (int64_t)ret_conv;
30162 }
30163
30164 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) {
30165         LDKChannelManager this_arg_conv;
30166         this_arg_conv.inner = (void*)(this_arg & (~1));
30167         this_arg_conv.is_owned = false;
30168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30169         LDKThirtyTwoBytes payment_hash_ref;
30170         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30171         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30172         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30173         CHECK_ACCESS(min_value_msat_ptr);
30174         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30175         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30176         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
30177         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
30178         return (int64_t)ret_conv;
30179 }
30180
30181 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) {
30182         LDKChannelManager this_arg_conv;
30183         this_arg_conv.inner = (void*)(this_arg & (~1));
30184         this_arg_conv.is_owned = false;
30185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30186         LDKThirtyTwoBytes payment_hash_ref;
30187         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30188         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30189         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30190         CHECK_ACCESS(min_value_msat_ptr);
30191         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30192         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30193         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
30194         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
30195         return (int64_t)ret_conv;
30196 }
30197
30198 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) {
30199         LDKChannelManager this_arg_conv;
30200         this_arg_conv.inner = (void*)(this_arg & (~1));
30201         this_arg_conv.is_owned = false;
30202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30203         LDKThirtyTwoBytes payment_hash_ref;
30204         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30205         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30206         LDKThirtyTwoBytes payment_secret_ref;
30207         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
30208         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
30209         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
30210         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
30211         return (int64_t)ret_conv;
30212 }
30213
30214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
30215         LDKChannelManager this_arg_conv;
30216         this_arg_conv.inner = (void*)(this_arg & (~1));
30217         this_arg_conv.is_owned = false;
30218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30219         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
30220         return ret_conv;
30221 }
30222
30223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
30224         LDKChannelManager this_arg_conv;
30225         this_arg_conv.inner = (void*)(this_arg & (~1));
30226         this_arg_conv.is_owned = false;
30227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30228         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
30229         int64_t ret_ref = 0;
30230         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30231         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30233         ret_ref = (uintptr_t)ret_var.inner;
30234         if (ret_var.is_owned) {
30235                 ret_ref |= 1;
30236         }
30237         return ret_ref;
30238 }
30239
30240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
30241         LDKChannelManager this_arg_conv;
30242         this_arg_conv.inner = (void*)(this_arg & (~1));
30243         this_arg_conv.is_owned = false;
30244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30245         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
30246         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
30247         return (int64_t)ret_ret;
30248 }
30249
30250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
30251         LDKChannelManager this_arg_conv;
30252         this_arg_conv.inner = (void*)(this_arg & (~1));
30253         this_arg_conv.is_owned = false;
30254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30255         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
30256         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
30257         return (int64_t)ret_ret;
30258 }
30259
30260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
30261         LDKChannelManager this_arg_conv;
30262         this_arg_conv.inner = (void*)(this_arg & (~1));
30263         this_arg_conv.is_owned = false;
30264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30265         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
30266         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
30267         return (int64_t)ret_ret;
30268 }
30269
30270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
30271         LDKChannelManager this_arg_conv;
30272         this_arg_conv.inner = (void*)(this_arg & (~1));
30273         this_arg_conv.is_owned = false;
30274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30275         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
30276         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
30277         return (int64_t)ret_ret;
30278 }
30279
30280 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) {
30281         LDKChannelManager this_arg_conv;
30282         this_arg_conv.inner = (void*)(this_arg & (~1));
30283         this_arg_conv.is_owned = false;
30284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30285         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
30286         return ret_conv;
30287 }
30288
30289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
30290         LDKChannelManager this_arg_conv;
30291         this_arg_conv.inner = (void*)(this_arg & (~1));
30292         this_arg_conv.is_owned = false;
30293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30294         ChannelManager_await_persistable_update(&this_arg_conv);
30295 }
30296
30297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
30298         LDKChannelManager this_arg_conv;
30299         this_arg_conv.inner = (void*)(this_arg & (~1));
30300         this_arg_conv.is_owned = false;
30301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30302         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
30303         int64_t ret_ref = 0;
30304         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30305         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30307         ret_ref = (uintptr_t)ret_var.inner;
30308         if (ret_var.is_owned) {
30309                 ret_ref |= 1;
30310         }
30311         return ret_ref;
30312 }
30313
30314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
30315         LDKChannelManager this_arg_conv;
30316         this_arg_conv.inner = (void*)(this_arg & (~1));
30317         this_arg_conv.is_owned = false;
30318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30319         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
30320         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
30321         return (int64_t)ret_ret;
30322 }
30323
30324 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
30325         LDKCounterpartyForwardingInfo obj_conv;
30326         obj_conv.inner = (void*)(obj & (~1));
30327         obj_conv.is_owned = false;
30328         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30329         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
30330         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30331         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30332         CVec_u8Z_free(ret_var);
30333         return ret_arr;
30334 }
30335
30336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30337         LDKu8slice ser_ref;
30338         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30339         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30340         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
30341         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
30342         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30343         return (int64_t)ret_conv;
30344 }
30345
30346 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
30347         LDKChannelCounterparty obj_conv;
30348         obj_conv.inner = (void*)(obj & (~1));
30349         obj_conv.is_owned = false;
30350         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30351         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
30352         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30353         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30354         CVec_u8Z_free(ret_var);
30355         return ret_arr;
30356 }
30357
30358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30359         LDKu8slice ser_ref;
30360         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30361         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30362         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
30363         *ret_conv = ChannelCounterparty_read(ser_ref);
30364         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30365         return (int64_t)ret_conv;
30366 }
30367
30368 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
30369         LDKChannelDetails obj_conv;
30370         obj_conv.inner = (void*)(obj & (~1));
30371         obj_conv.is_owned = false;
30372         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30373         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
30374         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30375         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30376         CVec_u8Z_free(ret_var);
30377         return ret_arr;
30378 }
30379
30380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30381         LDKu8slice ser_ref;
30382         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30383         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30384         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
30385         *ret_conv = ChannelDetails_read(ser_ref);
30386         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30387         return (int64_t)ret_conv;
30388 }
30389
30390 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
30391         LDKPhantomRouteHints obj_conv;
30392         obj_conv.inner = (void*)(obj & (~1));
30393         obj_conv.is_owned = false;
30394         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30395         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
30396         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30397         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30398         CVec_u8Z_free(ret_var);
30399         return ret_arr;
30400 }
30401
30402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30403         LDKu8slice ser_ref;
30404         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30405         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30406         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
30407         *ret_conv = PhantomRouteHints_read(ser_ref);
30408         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30409         return (int64_t)ret_conv;
30410 }
30411
30412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
30413         LDKChannelManager obj_conv;
30414         obj_conv.inner = (void*)(obj & (~1));
30415         obj_conv.is_owned = false;
30416         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30417         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
30418         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30419         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30420         CVec_u8Z_free(ret_var);
30421         return ret_arr;
30422 }
30423
30424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30425         LDKChannelManagerReadArgs this_obj_conv;
30426         this_obj_conv.inner = (void*)(this_obj & (~1));
30427         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30429         ChannelManagerReadArgs_free(this_obj_conv);
30430 }
30431
30432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
30433         LDKChannelManagerReadArgs this_ptr_conv;
30434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30435         this_ptr_conv.is_owned = false;
30436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30437         // WARNING: This object doesn't live past this scope, needs clone!
30438         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
30439         return ret_ret;
30440 }
30441
30442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30443         LDKChannelManagerReadArgs this_ptr_conv;
30444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30445         this_ptr_conv.is_owned = false;
30446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30447         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30448         CHECK_ACCESS(val_ptr);
30449         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
30450         if (val_conv.free == LDKKeysInterface_JCalls_free) {
30451                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30452                 LDKKeysInterface_JCalls_cloned(&val_conv);
30453         }
30454         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
30455 }
30456
30457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
30458         LDKChannelManagerReadArgs this_ptr_conv;
30459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30460         this_ptr_conv.is_owned = false;
30461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30462         // WARNING: This object doesn't live past this scope, needs clone!
30463         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
30464         return ret_ret;
30465 }
30466
30467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30468         LDKChannelManagerReadArgs this_ptr_conv;
30469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30470         this_ptr_conv.is_owned = false;
30471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30472         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30473         CHECK_ACCESS(val_ptr);
30474         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
30475         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
30476                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30477                 LDKFeeEstimator_JCalls_cloned(&val_conv);
30478         }
30479         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
30480 }
30481
30482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
30483         LDKChannelManagerReadArgs this_ptr_conv;
30484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30485         this_ptr_conv.is_owned = false;
30486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30487         // WARNING: This object doesn't live past this scope, needs clone!
30488         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
30489         return ret_ret;
30490 }
30491
30492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30493         LDKChannelManagerReadArgs this_ptr_conv;
30494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30495         this_ptr_conv.is_owned = false;
30496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30497         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30498         CHECK_ACCESS(val_ptr);
30499         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
30500         if (val_conv.free == LDKWatch_JCalls_free) {
30501                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30502                 LDKWatch_JCalls_cloned(&val_conv);
30503         }
30504         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
30505 }
30506
30507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
30508         LDKChannelManagerReadArgs this_ptr_conv;
30509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30510         this_ptr_conv.is_owned = false;
30511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30512         // WARNING: This object doesn't live past this scope, needs clone!
30513         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
30514         return ret_ret;
30515 }
30516
30517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30518         LDKChannelManagerReadArgs this_ptr_conv;
30519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30520         this_ptr_conv.is_owned = false;
30521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30522         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30523         CHECK_ACCESS(val_ptr);
30524         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
30525         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
30526                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30527                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
30528         }
30529         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
30530 }
30531
30532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
30533         LDKChannelManagerReadArgs 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         // WARNING: This object doesn't live past this scope, needs clone!
30538         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
30539         return ret_ret;
30540 }
30541
30542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30543         LDKChannelManagerReadArgs this_ptr_conv;
30544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30545         this_ptr_conv.is_owned = false;
30546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30547         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30548         CHECK_ACCESS(val_ptr);
30549         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
30550         if (val_conv.free == LDKLogger_JCalls_free) {
30551                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30552                 LDKLogger_JCalls_cloned(&val_conv);
30553         }
30554         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
30555 }
30556
30557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
30558         LDKChannelManagerReadArgs this_ptr_conv;
30559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30560         this_ptr_conv.is_owned = false;
30561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30562         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
30563         int64_t ret_ref = 0;
30564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30567         ret_ref = (uintptr_t)ret_var.inner;
30568         if (ret_var.is_owned) {
30569                 ret_ref |= 1;
30570         }
30571         return ret_ref;
30572 }
30573
30574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30575         LDKChannelManagerReadArgs this_ptr_conv;
30576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30577         this_ptr_conv.is_owned = false;
30578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30579         LDKUserConfig val_conv;
30580         val_conv.inner = (void*)(val & (~1));
30581         val_conv.is_owned = (val & 1) || (val == 0);
30582         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30583         val_conv = UserConfig_clone(&val_conv);
30584         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
30585 }
30586
30587 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) {
30588         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
30589         CHECK_ACCESS(keys_manager_ptr);
30590         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
30591         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
30592                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30593                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
30594         }
30595         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
30596         CHECK_ACCESS(fee_estimator_ptr);
30597         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30598         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30599                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30600                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30601         }
30602         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
30603         CHECK_ACCESS(chain_monitor_ptr);
30604         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
30605         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
30606                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30607                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
30608         }
30609         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
30610         CHECK_ACCESS(tx_broadcaster_ptr);
30611         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
30612         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30613                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30614                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
30615         }
30616         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
30617         CHECK_ACCESS(logger_ptr);
30618         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30619         if (logger_conv.free == LDKLogger_JCalls_free) {
30620                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30621                 LDKLogger_JCalls_cloned(&logger_conv);
30622         }
30623         LDKUserConfig default_config_conv;
30624         default_config_conv.inner = (void*)(default_config & (~1));
30625         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
30626         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
30627         default_config_conv = UserConfig_clone(&default_config_conv);
30628         LDKCVec_ChannelMonitorZ channel_monitors_constr;
30629         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
30630         if (channel_monitors_constr.datalen > 0)
30631                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
30632         else
30633                 channel_monitors_constr.data = NULL;
30634         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
30635         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
30636                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
30637                 LDKChannelMonitor channel_monitors_conv_16_conv;
30638                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
30639                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
30640                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
30641                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
30642         }
30643         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
30644         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);
30645         int64_t ret_ref = 0;
30646         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30647         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30649         ret_ref = (uintptr_t)ret_var.inner;
30650         if (ret_var.is_owned) {
30651                 ret_ref |= 1;
30652         }
30653         return ret_ref;
30654 }
30655
30656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
30657         LDKu8slice ser_ref;
30658         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30659         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30660         LDKChannelManagerReadArgs arg_conv;
30661         arg_conv.inner = (void*)(arg & (~1));
30662         arg_conv.is_owned = (arg & 1) || (arg == 0);
30663         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30664         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
30665         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
30666         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
30667         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30668         return (int64_t)ret_conv;
30669 }
30670
30671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30672         LDKExpandedKey this_obj_conv;
30673         this_obj_conv.inner = (void*)(this_obj & (~1));
30674         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30676         ExpandedKey_free(this_obj_conv);
30677 }
30678
30679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
30680         unsigned char key_material_arr[32];
30681         CHECK((*env)->GetArrayLength(env, key_material) == 32);
30682         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
30683         unsigned char (*key_material_ref)[32] = &key_material_arr;
30684         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
30685         int64_t ret_ref = 0;
30686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30689         ret_ref = (uintptr_t)ret_var.inner;
30690         if (ret_var.is_owned) {
30691                 ret_ref |= 1;
30692         }
30693         return ret_ref;
30694 }
30695
30696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create(JNIEnv *env, jclass clz, int64_t keys, int64_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t keys_manager, int64_t current_time) {
30697         LDKExpandedKey keys_conv;
30698         keys_conv.inner = (void*)(keys & (~1));
30699         keys_conv.is_owned = false;
30700         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
30701         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30702         CHECK_ACCESS(min_value_msat_ptr);
30703         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30704         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30705         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
30706         if (!(keys_manager & 1)) { CHECK_ACCESS(keys_manager_ptr); }
30707         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
30708         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
30709         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
30710         return (int64_t)ret_conv;
30711 }
30712
30713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1from_1hash(JNIEnv *env, jclass clz, int64_t keys, int64_t min_value_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t current_time) {
30714         LDKExpandedKey keys_conv;
30715         keys_conv.inner = (void*)(keys & (~1));
30716         keys_conv.is_owned = false;
30717         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
30718         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30719         CHECK_ACCESS(min_value_msat_ptr);
30720         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30721         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30722         LDKThirtyTwoBytes payment_hash_ref;
30723         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30724         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30725         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
30726         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
30727         return (int64_t)ret_conv;
30728 }
30729
30730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30731         LDKDecodeError 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         DecodeError_free(this_obj_conv);
30736 }
30737
30738 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
30739         LDKDecodeError ret_var = DecodeError_clone(arg);
30740 int64_t ret_ref = 0;
30741 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30742 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30743 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30744 ret_ref = (uintptr_t)ret_var.inner;
30745 if (ret_var.is_owned) {
30746         ret_ref |= 1;
30747 }
30748         return ret_ref;
30749 }
30750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30751         LDKDecodeError arg_conv;
30752         arg_conv.inner = (void*)(arg & (~1));
30753         arg_conv.is_owned = false;
30754         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30755         int64_t ret_conv = DecodeError_clone_ptr(&arg_conv);
30756         return ret_conv;
30757 }
30758
30759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30760         LDKDecodeError orig_conv;
30761         orig_conv.inner = (void*)(orig & (~1));
30762         orig_conv.is_owned = false;
30763         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30764         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
30765         int64_t ret_ref = 0;
30766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30769         ret_ref = (uintptr_t)ret_var.inner;
30770         if (ret_var.is_owned) {
30771                 ret_ref |= 1;
30772         }
30773         return ret_ref;
30774 }
30775
30776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30777         LDKInit this_obj_conv;
30778         this_obj_conv.inner = (void*)(this_obj & (~1));
30779         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30781         Init_free(this_obj_conv);
30782 }
30783
30784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
30785         LDKInit this_ptr_conv;
30786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30787         this_ptr_conv.is_owned = false;
30788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30789         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
30790         int64_t ret_ref = 0;
30791         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30792         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30794         ret_ref = (uintptr_t)ret_var.inner;
30795         if (ret_var.is_owned) {
30796                 ret_ref |= 1;
30797         }
30798         return ret_ref;
30799 }
30800
30801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30802         LDKInit this_ptr_conv;
30803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30804         this_ptr_conv.is_owned = false;
30805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30806         LDKInitFeatures val_conv;
30807         val_conv.inner = (void*)(val & (~1));
30808         val_conv.is_owned = (val & 1) || (val == 0);
30809         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30810         val_conv = InitFeatures_clone(&val_conv);
30811         Init_set_features(&this_ptr_conv, val_conv);
30812 }
30813
30814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
30815         LDKInit this_ptr_conv;
30816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30817         this_ptr_conv.is_owned = false;
30818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30819         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
30820         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
30821         int64_t ret_ref = (uintptr_t)ret_copy;
30822         return ret_ref;
30823 }
30824
30825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30826         LDKInit this_ptr_conv;
30827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30828         this_ptr_conv.is_owned = false;
30829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30830         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30831         CHECK_ACCESS(val_ptr);
30832         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
30833         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
30834         Init_set_remote_network_address(&this_ptr_conv, val_conv);
30835 }
30836
30837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg, int64_t remote_network_address_arg) {
30838         LDKInitFeatures features_arg_conv;
30839         features_arg_conv.inner = (void*)(features_arg & (~1));
30840         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
30841         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
30842         features_arg_conv = InitFeatures_clone(&features_arg_conv);
30843         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
30844         CHECK_ACCESS(remote_network_address_arg_ptr);
30845         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
30846         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
30847         int64_t ret_ref = 0;
30848         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30849         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30851         ret_ref = (uintptr_t)ret_var.inner;
30852         if (ret_var.is_owned) {
30853                 ret_ref |= 1;
30854         }
30855         return ret_ref;
30856 }
30857
30858 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
30859         LDKInit ret_var = Init_clone(arg);
30860 int64_t ret_ref = 0;
30861 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30862 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30863 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30864 ret_ref = (uintptr_t)ret_var.inner;
30865 if (ret_var.is_owned) {
30866         ret_ref |= 1;
30867 }
30868         return ret_ref;
30869 }
30870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30871         LDKInit arg_conv;
30872         arg_conv.inner = (void*)(arg & (~1));
30873         arg_conv.is_owned = false;
30874         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30875         int64_t ret_conv = Init_clone_ptr(&arg_conv);
30876         return ret_conv;
30877 }
30878
30879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30880         LDKInit orig_conv;
30881         orig_conv.inner = (void*)(orig & (~1));
30882         orig_conv.is_owned = false;
30883         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30884         LDKInit ret_var = Init_clone(&orig_conv);
30885         int64_t ret_ref = 0;
30886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30889         ret_ref = (uintptr_t)ret_var.inner;
30890         if (ret_var.is_owned) {
30891                 ret_ref |= 1;
30892         }
30893         return ret_ref;
30894 }
30895
30896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30897         LDKErrorMessage this_obj_conv;
30898         this_obj_conv.inner = (void*)(this_obj & (~1));
30899         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30901         ErrorMessage_free(this_obj_conv);
30902 }
30903
30904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30905         LDKErrorMessage this_ptr_conv;
30906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30907         this_ptr_conv.is_owned = false;
30908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30909         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30910         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
30911         return ret_arr;
30912 }
30913
30914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30915         LDKErrorMessage this_ptr_conv;
30916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30917         this_ptr_conv.is_owned = false;
30918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30919         LDKThirtyTwoBytes val_ref;
30920         CHECK((*env)->GetArrayLength(env, val) == 32);
30921         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30922         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
30923 }
30924
30925 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
30926         LDKErrorMessage this_ptr_conv;
30927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30928         this_ptr_conv.is_owned = false;
30929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30930         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
30931         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30932         Str_free(ret_str);
30933         return ret_conv;
30934 }
30935
30936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
30937         LDKErrorMessage this_ptr_conv;
30938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30939         this_ptr_conv.is_owned = false;
30940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30941         LDKStr val_conv = java_to_owned_str(env, val);
30942         ErrorMessage_set_data(&this_ptr_conv, val_conv);
30943 }
30944
30945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
30946         LDKThirtyTwoBytes channel_id_arg_ref;
30947         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30948         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30949         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
30950         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
30951         int64_t ret_ref = 0;
30952         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30953         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30955         ret_ref = (uintptr_t)ret_var.inner;
30956         if (ret_var.is_owned) {
30957                 ret_ref |= 1;
30958         }
30959         return ret_ref;
30960 }
30961
30962 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
30963         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
30964 int64_t ret_ref = 0;
30965 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30966 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30967 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30968 ret_ref = (uintptr_t)ret_var.inner;
30969 if (ret_var.is_owned) {
30970         ret_ref |= 1;
30971 }
30972         return ret_ref;
30973 }
30974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30975         LDKErrorMessage arg_conv;
30976         arg_conv.inner = (void*)(arg & (~1));
30977         arg_conv.is_owned = false;
30978         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30979         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
30980         return ret_conv;
30981 }
30982
30983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30984         LDKErrorMessage orig_conv;
30985         orig_conv.inner = (void*)(orig & (~1));
30986         orig_conv.is_owned = false;
30987         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30988         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
30989         int64_t ret_ref = 0;
30990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30993         ret_ref = (uintptr_t)ret_var.inner;
30994         if (ret_var.is_owned) {
30995                 ret_ref |= 1;
30996         }
30997         return ret_ref;
30998 }
30999
31000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31001         LDKWarningMessage this_obj_conv;
31002         this_obj_conv.inner = (void*)(this_obj & (~1));
31003         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31005         WarningMessage_free(this_obj_conv);
31006 }
31007
31008 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31009         LDKWarningMessage this_ptr_conv;
31010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31011         this_ptr_conv.is_owned = false;
31012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31013         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31014         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
31015         return ret_arr;
31016 }
31017
31018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31019         LDKWarningMessage this_ptr_conv;
31020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31021         this_ptr_conv.is_owned = false;
31022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31023         LDKThirtyTwoBytes val_ref;
31024         CHECK((*env)->GetArrayLength(env, val) == 32);
31025         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31026         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
31027 }
31028
31029 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
31030         LDKWarningMessage this_ptr_conv;
31031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31032         this_ptr_conv.is_owned = false;
31033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31034         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
31035         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31036         Str_free(ret_str);
31037         return ret_conv;
31038 }
31039
31040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
31041         LDKWarningMessage this_ptr_conv;
31042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31043         this_ptr_conv.is_owned = false;
31044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31045         LDKStr val_conv = java_to_owned_str(env, val);
31046         WarningMessage_set_data(&this_ptr_conv, val_conv);
31047 }
31048
31049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
31050         LDKThirtyTwoBytes channel_id_arg_ref;
31051         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31052         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31053         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
31054         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
31055         int64_t ret_ref = 0;
31056         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31057         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31059         ret_ref = (uintptr_t)ret_var.inner;
31060         if (ret_var.is_owned) {
31061                 ret_ref |= 1;
31062         }
31063         return ret_ref;
31064 }
31065
31066 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
31067         LDKWarningMessage ret_var = WarningMessage_clone(arg);
31068 int64_t ret_ref = 0;
31069 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31070 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31071 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31072 ret_ref = (uintptr_t)ret_var.inner;
31073 if (ret_var.is_owned) {
31074         ret_ref |= 1;
31075 }
31076         return ret_ref;
31077 }
31078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31079         LDKWarningMessage arg_conv;
31080         arg_conv.inner = (void*)(arg & (~1));
31081         arg_conv.is_owned = false;
31082         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31083         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
31084         return ret_conv;
31085 }
31086
31087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31088         LDKWarningMessage orig_conv;
31089         orig_conv.inner = (void*)(orig & (~1));
31090         orig_conv.is_owned = false;
31091         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31092         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
31093         int64_t ret_ref = 0;
31094         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31095         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31097         ret_ref = (uintptr_t)ret_var.inner;
31098         if (ret_var.is_owned) {
31099                 ret_ref |= 1;
31100         }
31101         return ret_ref;
31102 }
31103
31104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31105         LDKPing this_obj_conv;
31106         this_obj_conv.inner = (void*)(this_obj & (~1));
31107         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31109         Ping_free(this_obj_conv);
31110 }
31111
31112 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
31113         LDKPing this_ptr_conv;
31114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31115         this_ptr_conv.is_owned = false;
31116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31117         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
31118         return ret_conv;
31119 }
31120
31121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31122         LDKPing this_ptr_conv;
31123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31124         this_ptr_conv.is_owned = false;
31125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31126         Ping_set_ponglen(&this_ptr_conv, val);
31127 }
31128
31129 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
31130         LDKPing this_ptr_conv;
31131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31132         this_ptr_conv.is_owned = false;
31133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31134         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
31135         return ret_conv;
31136 }
31137
31138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31139         LDKPing this_ptr_conv;
31140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31141         this_ptr_conv.is_owned = false;
31142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31143         Ping_set_byteslen(&this_ptr_conv, val);
31144 }
31145
31146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
31147         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
31148         int64_t ret_ref = 0;
31149         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31150         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31152         ret_ref = (uintptr_t)ret_var.inner;
31153         if (ret_var.is_owned) {
31154                 ret_ref |= 1;
31155         }
31156         return ret_ref;
31157 }
31158
31159 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
31160         LDKPing ret_var = Ping_clone(arg);
31161 int64_t ret_ref = 0;
31162 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31163 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31164 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31165 ret_ref = (uintptr_t)ret_var.inner;
31166 if (ret_var.is_owned) {
31167         ret_ref |= 1;
31168 }
31169         return ret_ref;
31170 }
31171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31172         LDKPing arg_conv;
31173         arg_conv.inner = (void*)(arg & (~1));
31174         arg_conv.is_owned = false;
31175         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31176         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
31177         return ret_conv;
31178 }
31179
31180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31181         LDKPing orig_conv;
31182         orig_conv.inner = (void*)(orig & (~1));
31183         orig_conv.is_owned = false;
31184         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31185         LDKPing ret_var = Ping_clone(&orig_conv);
31186         int64_t ret_ref = 0;
31187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31190         ret_ref = (uintptr_t)ret_var.inner;
31191         if (ret_var.is_owned) {
31192                 ret_ref |= 1;
31193         }
31194         return ret_ref;
31195 }
31196
31197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31198         LDKPong this_obj_conv;
31199         this_obj_conv.inner = (void*)(this_obj & (~1));
31200         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31202         Pong_free(this_obj_conv);
31203 }
31204
31205 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
31206         LDKPong this_ptr_conv;
31207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31208         this_ptr_conv.is_owned = false;
31209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31210         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
31211         return ret_conv;
31212 }
31213
31214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31215         LDKPong this_ptr_conv;
31216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31217         this_ptr_conv.is_owned = false;
31218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31219         Pong_set_byteslen(&this_ptr_conv, val);
31220 }
31221
31222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
31223         LDKPong ret_var = Pong_new(byteslen_arg);
31224         int64_t ret_ref = 0;
31225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31228         ret_ref = (uintptr_t)ret_var.inner;
31229         if (ret_var.is_owned) {
31230                 ret_ref |= 1;
31231         }
31232         return ret_ref;
31233 }
31234
31235 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
31236         LDKPong ret_var = Pong_clone(arg);
31237 int64_t ret_ref = 0;
31238 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31239 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31240 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31241 ret_ref = (uintptr_t)ret_var.inner;
31242 if (ret_var.is_owned) {
31243         ret_ref |= 1;
31244 }
31245         return ret_ref;
31246 }
31247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31248         LDKPong arg_conv;
31249         arg_conv.inner = (void*)(arg & (~1));
31250         arg_conv.is_owned = false;
31251         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31252         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
31253         return ret_conv;
31254 }
31255
31256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31257         LDKPong orig_conv;
31258         orig_conv.inner = (void*)(orig & (~1));
31259         orig_conv.is_owned = false;
31260         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31261         LDKPong ret_var = Pong_clone(&orig_conv);
31262         int64_t ret_ref = 0;
31263         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31264         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31266         ret_ref = (uintptr_t)ret_var.inner;
31267         if (ret_var.is_owned) {
31268                 ret_ref |= 1;
31269         }
31270         return ret_ref;
31271 }
31272
31273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31274         LDKOpenChannel this_obj_conv;
31275         this_obj_conv.inner = (void*)(this_obj & (~1));
31276         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31278         OpenChannel_free(this_obj_conv);
31279 }
31280
31281 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
31282         LDKOpenChannel this_ptr_conv;
31283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31284         this_ptr_conv.is_owned = false;
31285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31286         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31287         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
31288         return ret_arr;
31289 }
31290
31291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31292         LDKOpenChannel this_ptr_conv;
31293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31294         this_ptr_conv.is_owned = false;
31295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31296         LDKThirtyTwoBytes val_ref;
31297         CHECK((*env)->GetArrayLength(env, val) == 32);
31298         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31299         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
31300 }
31301
31302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31303         LDKOpenChannel this_ptr_conv;
31304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31305         this_ptr_conv.is_owned = false;
31306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31307         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31308         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
31309         return ret_arr;
31310 }
31311
31312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31313         LDKOpenChannel this_ptr_conv;
31314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31315         this_ptr_conv.is_owned = false;
31316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31317         LDKThirtyTwoBytes val_ref;
31318         CHECK((*env)->GetArrayLength(env, val) == 32);
31319         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31320         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
31321 }
31322
31323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31324         LDKOpenChannel this_ptr_conv;
31325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31326         this_ptr_conv.is_owned = false;
31327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31328         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
31329         return ret_conv;
31330 }
31331
31332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31333         LDKOpenChannel this_ptr_conv;
31334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31335         this_ptr_conv.is_owned = false;
31336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31337         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
31338 }
31339
31340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31341         LDKOpenChannel this_ptr_conv;
31342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31343         this_ptr_conv.is_owned = false;
31344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31345         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
31346         return ret_conv;
31347 }
31348
31349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31350         LDKOpenChannel this_ptr_conv;
31351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31352         this_ptr_conv.is_owned = false;
31353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31354         OpenChannel_set_push_msat(&this_ptr_conv, val);
31355 }
31356
31357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31358         LDKOpenChannel this_ptr_conv;
31359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31360         this_ptr_conv.is_owned = false;
31361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31362         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
31363         return ret_conv;
31364 }
31365
31366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31367         LDKOpenChannel this_ptr_conv;
31368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31369         this_ptr_conv.is_owned = false;
31370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31371         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
31372 }
31373
31374 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) {
31375         LDKOpenChannel this_ptr_conv;
31376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31377         this_ptr_conv.is_owned = false;
31378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31379         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
31380         return ret_conv;
31381 }
31382
31383 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) {
31384         LDKOpenChannel this_ptr_conv;
31385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31386         this_ptr_conv.is_owned = false;
31387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31388         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
31389 }
31390
31391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31392         LDKOpenChannel this_ptr_conv;
31393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31394         this_ptr_conv.is_owned = false;
31395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31396         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
31397         return ret_conv;
31398 }
31399
31400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31401         LDKOpenChannel this_ptr_conv;
31402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31403         this_ptr_conv.is_owned = false;
31404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31405         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
31406 }
31407
31408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31409         LDKOpenChannel this_ptr_conv;
31410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31411         this_ptr_conv.is_owned = false;
31412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31413         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
31414         return ret_conv;
31415 }
31416
31417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31418         LDKOpenChannel this_ptr_conv;
31419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31420         this_ptr_conv.is_owned = false;
31421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31422         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
31423 }
31424
31425 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
31426         LDKOpenChannel this_ptr_conv;
31427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31428         this_ptr_conv.is_owned = false;
31429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31430         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
31431         return ret_conv;
31432 }
31433
31434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31435         LDKOpenChannel 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         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
31440 }
31441
31442 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
31443         LDKOpenChannel this_ptr_conv;
31444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31445         this_ptr_conv.is_owned = false;
31446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31447         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
31448         return ret_conv;
31449 }
31450
31451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31452         LDKOpenChannel this_ptr_conv;
31453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31454         this_ptr_conv.is_owned = false;
31455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31456         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
31457 }
31458
31459 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
31460         LDKOpenChannel this_ptr_conv;
31461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31462         this_ptr_conv.is_owned = false;
31463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31464         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
31465         return ret_conv;
31466 }
31467
31468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31469         LDKOpenChannel this_ptr_conv;
31470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31471         this_ptr_conv.is_owned = false;
31472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31473         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
31474 }
31475
31476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31477         LDKOpenChannel this_ptr_conv;
31478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31479         this_ptr_conv.is_owned = false;
31480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31481         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31482         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
31483         return ret_arr;
31484 }
31485
31486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31487         LDKOpenChannel this_ptr_conv;
31488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31489         this_ptr_conv.is_owned = false;
31490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31491         LDKPublicKey val_ref;
31492         CHECK((*env)->GetArrayLength(env, val) == 33);
31493         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31494         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
31495 }
31496
31497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31498         LDKOpenChannel this_ptr_conv;
31499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31500         this_ptr_conv.is_owned = false;
31501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31502         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31503         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
31504         return ret_arr;
31505 }
31506
31507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31508         LDKOpenChannel this_ptr_conv;
31509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31510         this_ptr_conv.is_owned = false;
31511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31512         LDKPublicKey val_ref;
31513         CHECK((*env)->GetArrayLength(env, val) == 33);
31514         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31515         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
31516 }
31517
31518 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31519         LDKOpenChannel this_ptr_conv;
31520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31521         this_ptr_conv.is_owned = false;
31522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31523         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31524         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
31525         return ret_arr;
31526 }
31527
31528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31529         LDKOpenChannel this_ptr_conv;
31530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31531         this_ptr_conv.is_owned = false;
31532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31533         LDKPublicKey val_ref;
31534         CHECK((*env)->GetArrayLength(env, val) == 33);
31535         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31536         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
31537 }
31538
31539 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31540         LDKOpenChannel 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31545         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
31546         return ret_arr;
31547 }
31548
31549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31550         LDKOpenChannel this_ptr_conv;
31551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31552         this_ptr_conv.is_owned = false;
31553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31554         LDKPublicKey val_ref;
31555         CHECK((*env)->GetArrayLength(env, val) == 33);
31556         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31557         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
31558 }
31559
31560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31561         LDKOpenChannel this_ptr_conv;
31562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31563         this_ptr_conv.is_owned = false;
31564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31565         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31566         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
31567         return ret_arr;
31568 }
31569
31570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31571         LDKOpenChannel this_ptr_conv;
31572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31573         this_ptr_conv.is_owned = false;
31574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31575         LDKPublicKey val_ref;
31576         CHECK((*env)->GetArrayLength(env, val) == 33);
31577         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31578         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
31579 }
31580
31581 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31582         LDKOpenChannel this_ptr_conv;
31583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31584         this_ptr_conv.is_owned = false;
31585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31586         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31587         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
31588         return ret_arr;
31589 }
31590
31591 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) {
31592         LDKOpenChannel this_ptr_conv;
31593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31594         this_ptr_conv.is_owned = false;
31595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31596         LDKPublicKey val_ref;
31597         CHECK((*env)->GetArrayLength(env, val) == 33);
31598         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31599         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
31600 }
31601
31602 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
31603         LDKOpenChannel this_ptr_conv;
31604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31605         this_ptr_conv.is_owned = false;
31606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31607         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
31608         return ret_conv;
31609 }
31610
31611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
31612         LDKOpenChannel this_ptr_conv;
31613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31614         this_ptr_conv.is_owned = false;
31615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31616         OpenChannel_set_channel_flags(&this_ptr_conv, val);
31617 }
31618
31619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
31620         LDKOpenChannel this_ptr_conv;
31621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31622         this_ptr_conv.is_owned = false;
31623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31624         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
31625         int64_t ret_ref = 0;
31626         if ((uintptr_t)ret_var.inner > 4096) {
31627                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31628                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31630                 ret_ref = (uintptr_t)ret_var.inner;
31631                 if (ret_var.is_owned) {
31632                         ret_ref |= 1;
31633                 }
31634         }
31635         return ret_ref;
31636 }
31637
31638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31639         LDKOpenChannel this_ptr_conv;
31640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31641         this_ptr_conv.is_owned = false;
31642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31643         LDKChannelTypeFeatures val_conv;
31644         val_conv.inner = (void*)(val & (~1));
31645         val_conv.is_owned = (val & 1) || (val == 0);
31646         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31647         val_conv = ChannelTypeFeatures_clone(&val_conv);
31648         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
31649 }
31650
31651 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
31652         LDKOpenChannel ret_var = OpenChannel_clone(arg);
31653 int64_t ret_ref = 0;
31654 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31655 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31656 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31657 ret_ref = (uintptr_t)ret_var.inner;
31658 if (ret_var.is_owned) {
31659         ret_ref |= 1;
31660 }
31661         return ret_ref;
31662 }
31663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31664         LDKOpenChannel arg_conv;
31665         arg_conv.inner = (void*)(arg & (~1));
31666         arg_conv.is_owned = false;
31667         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31668         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
31669         return ret_conv;
31670 }
31671
31672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31673         LDKOpenChannel orig_conv;
31674         orig_conv.inner = (void*)(orig & (~1));
31675         orig_conv.is_owned = false;
31676         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31677         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
31678         int64_t ret_ref = 0;
31679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31680         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31682         ret_ref = (uintptr_t)ret_var.inner;
31683         if (ret_var.is_owned) {
31684                 ret_ref |= 1;
31685         }
31686         return ret_ref;
31687 }
31688
31689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31690         LDKAcceptChannel this_obj_conv;
31691         this_obj_conv.inner = (void*)(this_obj & (~1));
31692         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31694         AcceptChannel_free(this_obj_conv);
31695 }
31696
31697 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31698         LDKAcceptChannel this_ptr_conv;
31699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31700         this_ptr_conv.is_owned = false;
31701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31702         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31703         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
31704         return ret_arr;
31705 }
31706
31707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31708         LDKAcceptChannel this_ptr_conv;
31709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31710         this_ptr_conv.is_owned = false;
31711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31712         LDKThirtyTwoBytes val_ref;
31713         CHECK((*env)->GetArrayLength(env, val) == 32);
31714         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31715         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
31716 }
31717
31718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31719         LDKAcceptChannel this_ptr_conv;
31720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31721         this_ptr_conv.is_owned = false;
31722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31723         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
31724         return ret_conv;
31725 }
31726
31727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31728         LDKAcceptChannel this_ptr_conv;
31729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31730         this_ptr_conv.is_owned = false;
31731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31732         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
31733 }
31734
31735 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) {
31736         LDKAcceptChannel this_ptr_conv;
31737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31738         this_ptr_conv.is_owned = false;
31739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31740         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
31741         return ret_conv;
31742 }
31743
31744 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) {
31745         LDKAcceptChannel this_ptr_conv;
31746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31747         this_ptr_conv.is_owned = false;
31748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31749         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
31750 }
31751
31752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31753         LDKAcceptChannel this_ptr_conv;
31754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31755         this_ptr_conv.is_owned = false;
31756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31757         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
31758         return ret_conv;
31759 }
31760
31761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31762         LDKAcceptChannel this_ptr_conv;
31763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31764         this_ptr_conv.is_owned = false;
31765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31766         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
31767 }
31768
31769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31770         LDKAcceptChannel this_ptr_conv;
31771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31772         this_ptr_conv.is_owned = false;
31773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31774         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
31775         return ret_conv;
31776 }
31777
31778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31779         LDKAcceptChannel this_ptr_conv;
31780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31781         this_ptr_conv.is_owned = false;
31782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31783         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
31784 }
31785
31786 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
31787         LDKAcceptChannel this_ptr_conv;
31788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31789         this_ptr_conv.is_owned = false;
31790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31791         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
31792         return ret_conv;
31793 }
31794
31795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31796         LDKAcceptChannel this_ptr_conv;
31797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31798         this_ptr_conv.is_owned = false;
31799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31800         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
31801 }
31802
31803 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
31804         LDKAcceptChannel this_ptr_conv;
31805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31806         this_ptr_conv.is_owned = false;
31807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31808         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
31809         return ret_conv;
31810 }
31811
31812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31813         LDKAcceptChannel this_ptr_conv;
31814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31815         this_ptr_conv.is_owned = false;
31816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31817         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
31818 }
31819
31820 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
31821         LDKAcceptChannel this_ptr_conv;
31822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31823         this_ptr_conv.is_owned = false;
31824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31825         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
31826         return ret_conv;
31827 }
31828
31829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31830         LDKAcceptChannel this_ptr_conv;
31831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31832         this_ptr_conv.is_owned = false;
31833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31834         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
31835 }
31836
31837 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31838         LDKAcceptChannel this_ptr_conv;
31839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31840         this_ptr_conv.is_owned = false;
31841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31842         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31843         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
31844         return ret_arr;
31845 }
31846
31847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31848         LDKAcceptChannel this_ptr_conv;
31849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31850         this_ptr_conv.is_owned = false;
31851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31852         LDKPublicKey val_ref;
31853         CHECK((*env)->GetArrayLength(env, val) == 33);
31854         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31855         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
31856 }
31857
31858 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31859         LDKAcceptChannel this_ptr_conv;
31860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31861         this_ptr_conv.is_owned = false;
31862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31863         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31864         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
31865         return ret_arr;
31866 }
31867
31868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31869         LDKAcceptChannel this_ptr_conv;
31870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31871         this_ptr_conv.is_owned = false;
31872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31873         LDKPublicKey val_ref;
31874         CHECK((*env)->GetArrayLength(env, val) == 33);
31875         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31876         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
31877 }
31878
31879 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31880         LDKAcceptChannel this_ptr_conv;
31881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31882         this_ptr_conv.is_owned = false;
31883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31884         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31885         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
31886         return ret_arr;
31887 }
31888
31889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31890         LDKAcceptChannel this_ptr_conv;
31891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31892         this_ptr_conv.is_owned = false;
31893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31894         LDKPublicKey val_ref;
31895         CHECK((*env)->GetArrayLength(env, val) == 33);
31896         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31897         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
31898 }
31899
31900 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31901         LDKAcceptChannel 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31906         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
31907         return ret_arr;
31908 }
31909
31910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31911         LDKAcceptChannel this_ptr_conv;
31912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31913         this_ptr_conv.is_owned = false;
31914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31915         LDKPublicKey val_ref;
31916         CHECK((*env)->GetArrayLength(env, val) == 33);
31917         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31918         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
31919 }
31920
31921 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31922         LDKAcceptChannel this_ptr_conv;
31923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31924         this_ptr_conv.is_owned = false;
31925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31926         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31927         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
31928         return ret_arr;
31929 }
31930
31931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31932         LDKAcceptChannel this_ptr_conv;
31933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31934         this_ptr_conv.is_owned = false;
31935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31936         LDKPublicKey val_ref;
31937         CHECK((*env)->GetArrayLength(env, val) == 33);
31938         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31939         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
31940 }
31941
31942 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31943         LDKAcceptChannel this_ptr_conv;
31944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31945         this_ptr_conv.is_owned = false;
31946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31947         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31948         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
31949         return ret_arr;
31950 }
31951
31952 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) {
31953         LDKAcceptChannel this_ptr_conv;
31954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31955         this_ptr_conv.is_owned = false;
31956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31957         LDKPublicKey val_ref;
31958         CHECK((*env)->GetArrayLength(env, val) == 33);
31959         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31960         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
31961 }
31962
31963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
31964         LDKAcceptChannel this_ptr_conv;
31965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31966         this_ptr_conv.is_owned = false;
31967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31968         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
31969         int64_t ret_ref = 0;
31970         if ((uintptr_t)ret_var.inner > 4096) {
31971                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31972                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31974                 ret_ref = (uintptr_t)ret_var.inner;
31975                 if (ret_var.is_owned) {
31976                         ret_ref |= 1;
31977                 }
31978         }
31979         return ret_ref;
31980 }
31981
31982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31983         LDKAcceptChannel this_ptr_conv;
31984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31985         this_ptr_conv.is_owned = false;
31986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31987         LDKChannelTypeFeatures val_conv;
31988         val_conv.inner = (void*)(val & (~1));
31989         val_conv.is_owned = (val & 1) || (val == 0);
31990         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31991         val_conv = ChannelTypeFeatures_clone(&val_conv);
31992         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
31993 }
31994
31995 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
31996         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
31997 int64_t ret_ref = 0;
31998 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31999 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32000 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32001 ret_ref = (uintptr_t)ret_var.inner;
32002 if (ret_var.is_owned) {
32003         ret_ref |= 1;
32004 }
32005         return ret_ref;
32006 }
32007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32008         LDKAcceptChannel arg_conv;
32009         arg_conv.inner = (void*)(arg & (~1));
32010         arg_conv.is_owned = false;
32011         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32012         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
32013         return ret_conv;
32014 }
32015
32016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32017         LDKAcceptChannel orig_conv;
32018         orig_conv.inner = (void*)(orig & (~1));
32019         orig_conv.is_owned = false;
32020         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32021         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
32022         int64_t ret_ref = 0;
32023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32026         ret_ref = (uintptr_t)ret_var.inner;
32027         if (ret_var.is_owned) {
32028                 ret_ref |= 1;
32029         }
32030         return ret_ref;
32031 }
32032
32033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32034         LDKFundingCreated this_obj_conv;
32035         this_obj_conv.inner = (void*)(this_obj & (~1));
32036         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32038         FundingCreated_free(this_obj_conv);
32039 }
32040
32041 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32042         LDKFundingCreated this_ptr_conv;
32043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32044         this_ptr_conv.is_owned = false;
32045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32046         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32047         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
32048         return ret_arr;
32049 }
32050
32051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32052         LDKFundingCreated this_ptr_conv;
32053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32054         this_ptr_conv.is_owned = false;
32055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32056         LDKThirtyTwoBytes val_ref;
32057         CHECK((*env)->GetArrayLength(env, val) == 32);
32058         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32059         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
32060 }
32061
32062 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
32063         LDKFundingCreated this_ptr_conv;
32064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32065         this_ptr_conv.is_owned = false;
32066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32067         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32068         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
32069         return ret_arr;
32070 }
32071
32072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32073         LDKFundingCreated this_ptr_conv;
32074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32075         this_ptr_conv.is_owned = false;
32076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32077         LDKThirtyTwoBytes val_ref;
32078         CHECK((*env)->GetArrayLength(env, val) == 32);
32079         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32080         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
32081 }
32082
32083 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
32084         LDKFundingCreated this_ptr_conv;
32085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32086         this_ptr_conv.is_owned = false;
32087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32088         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
32089         return ret_conv;
32090 }
32091
32092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32093         LDKFundingCreated this_ptr_conv;
32094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32095         this_ptr_conv.is_owned = false;
32096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32097         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
32098 }
32099
32100 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32101         LDKFundingCreated this_ptr_conv;
32102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32103         this_ptr_conv.is_owned = false;
32104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32105         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32106         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
32107         return ret_arr;
32108 }
32109
32110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32111         LDKFundingCreated this_ptr_conv;
32112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32113         this_ptr_conv.is_owned = false;
32114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32115         LDKSignature val_ref;
32116         CHECK((*env)->GetArrayLength(env, val) == 64);
32117         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32118         FundingCreated_set_signature(&this_ptr_conv, val_ref);
32119 }
32120
32121 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) {
32122         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
32123         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
32124         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
32125         LDKThirtyTwoBytes funding_txid_arg_ref;
32126         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
32127         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
32128         LDKSignature signature_arg_ref;
32129         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32130         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32131         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
32132         int64_t ret_ref = 0;
32133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32136         ret_ref = (uintptr_t)ret_var.inner;
32137         if (ret_var.is_owned) {
32138                 ret_ref |= 1;
32139         }
32140         return ret_ref;
32141 }
32142
32143 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
32144         LDKFundingCreated ret_var = FundingCreated_clone(arg);
32145 int64_t ret_ref = 0;
32146 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32147 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32148 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32149 ret_ref = (uintptr_t)ret_var.inner;
32150 if (ret_var.is_owned) {
32151         ret_ref |= 1;
32152 }
32153         return ret_ref;
32154 }
32155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32156         LDKFundingCreated arg_conv;
32157         arg_conv.inner = (void*)(arg & (~1));
32158         arg_conv.is_owned = false;
32159         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32160         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
32161         return ret_conv;
32162 }
32163
32164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32165         LDKFundingCreated orig_conv;
32166         orig_conv.inner = (void*)(orig & (~1));
32167         orig_conv.is_owned = false;
32168         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32169         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
32170         int64_t ret_ref = 0;
32171         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32172         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32174         ret_ref = (uintptr_t)ret_var.inner;
32175         if (ret_var.is_owned) {
32176                 ret_ref |= 1;
32177         }
32178         return ret_ref;
32179 }
32180
32181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32182         LDKFundingSigned this_obj_conv;
32183         this_obj_conv.inner = (void*)(this_obj & (~1));
32184         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32186         FundingSigned_free(this_obj_conv);
32187 }
32188
32189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32190         LDKFundingSigned this_ptr_conv;
32191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32192         this_ptr_conv.is_owned = false;
32193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32194         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32195         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
32196         return ret_arr;
32197 }
32198
32199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32200         LDKFundingSigned this_ptr_conv;
32201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32202         this_ptr_conv.is_owned = false;
32203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32204         LDKThirtyTwoBytes val_ref;
32205         CHECK((*env)->GetArrayLength(env, val) == 32);
32206         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32207         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
32208 }
32209
32210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32211         LDKFundingSigned this_ptr_conv;
32212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32213         this_ptr_conv.is_owned = false;
32214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32215         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32216         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
32217         return ret_arr;
32218 }
32219
32220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32221         LDKFundingSigned this_ptr_conv;
32222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32223         this_ptr_conv.is_owned = false;
32224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32225         LDKSignature val_ref;
32226         CHECK((*env)->GetArrayLength(env, val) == 64);
32227         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32228         FundingSigned_set_signature(&this_ptr_conv, val_ref);
32229 }
32230
32231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
32232         LDKThirtyTwoBytes channel_id_arg_ref;
32233         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32234         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32235         LDKSignature signature_arg_ref;
32236         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32237         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32238         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
32239         int64_t ret_ref = 0;
32240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32243         ret_ref = (uintptr_t)ret_var.inner;
32244         if (ret_var.is_owned) {
32245                 ret_ref |= 1;
32246         }
32247         return ret_ref;
32248 }
32249
32250 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
32251         LDKFundingSigned ret_var = FundingSigned_clone(arg);
32252 int64_t ret_ref = 0;
32253 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32254 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32255 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32256 ret_ref = (uintptr_t)ret_var.inner;
32257 if (ret_var.is_owned) {
32258         ret_ref |= 1;
32259 }
32260         return ret_ref;
32261 }
32262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32263         LDKFundingSigned arg_conv;
32264         arg_conv.inner = (void*)(arg & (~1));
32265         arg_conv.is_owned = false;
32266         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32267         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
32268         return ret_conv;
32269 }
32270
32271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32272         LDKFundingSigned orig_conv;
32273         orig_conv.inner = (void*)(orig & (~1));
32274         orig_conv.is_owned = false;
32275         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32276         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
32277         int64_t ret_ref = 0;
32278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32281         ret_ref = (uintptr_t)ret_var.inner;
32282         if (ret_var.is_owned) {
32283                 ret_ref |= 1;
32284         }
32285         return ret_ref;
32286 }
32287
32288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32289         LDKChannelReady this_obj_conv;
32290         this_obj_conv.inner = (void*)(this_obj & (~1));
32291         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32293         ChannelReady_free(this_obj_conv);
32294 }
32295
32296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32297         LDKChannelReady this_ptr_conv;
32298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32299         this_ptr_conv.is_owned = false;
32300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32301         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32302         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
32303         return ret_arr;
32304 }
32305
32306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32307         LDKChannelReady this_ptr_conv;
32308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32309         this_ptr_conv.is_owned = false;
32310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32311         LDKThirtyTwoBytes val_ref;
32312         CHECK((*env)->GetArrayLength(env, val) == 32);
32313         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32314         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
32315 }
32316
32317 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32318         LDKChannelReady this_ptr_conv;
32319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32320         this_ptr_conv.is_owned = false;
32321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32322         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32323         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
32324         return ret_arr;
32325 }
32326
32327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32328         LDKChannelReady this_ptr_conv;
32329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32330         this_ptr_conv.is_owned = false;
32331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32332         LDKPublicKey val_ref;
32333         CHECK((*env)->GetArrayLength(env, val) == 33);
32334         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32335         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
32336 }
32337
32338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32339         LDKChannelReady this_ptr_conv;
32340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32341         this_ptr_conv.is_owned = false;
32342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32343         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32344         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
32345         int64_t ret_ref = (uintptr_t)ret_copy;
32346         return ret_ref;
32347 }
32348
32349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32350         LDKChannelReady this_ptr_conv;
32351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32352         this_ptr_conv.is_owned = false;
32353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32354         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32355         CHECK_ACCESS(val_ptr);
32356         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32357         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
32358         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
32359 }
32360
32361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, int64_t short_channel_id_alias_arg) {
32362         LDKThirtyTwoBytes channel_id_arg_ref;
32363         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32364         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32365         LDKPublicKey next_per_commitment_point_arg_ref;
32366         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
32367         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
32368         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
32369         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
32370         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
32371         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
32372         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
32373         int64_t ret_ref = 0;
32374         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32375         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32377         ret_ref = (uintptr_t)ret_var.inner;
32378         if (ret_var.is_owned) {
32379                 ret_ref |= 1;
32380         }
32381         return ret_ref;
32382 }
32383
32384 static inline uintptr_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
32385         LDKChannelReady ret_var = ChannelReady_clone(arg);
32386 int64_t ret_ref = 0;
32387 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32388 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32389 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32390 ret_ref = (uintptr_t)ret_var.inner;
32391 if (ret_var.is_owned) {
32392         ret_ref |= 1;
32393 }
32394         return ret_ref;
32395 }
32396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32397         LDKChannelReady arg_conv;
32398         arg_conv.inner = (void*)(arg & (~1));
32399         arg_conv.is_owned = false;
32400         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32401         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
32402         return ret_conv;
32403 }
32404
32405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32406         LDKChannelReady orig_conv;
32407         orig_conv.inner = (void*)(orig & (~1));
32408         orig_conv.is_owned = false;
32409         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32410         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
32411         int64_t ret_ref = 0;
32412         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32413         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32415         ret_ref = (uintptr_t)ret_var.inner;
32416         if (ret_var.is_owned) {
32417                 ret_ref |= 1;
32418         }
32419         return ret_ref;
32420 }
32421
32422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32423         LDKShutdown this_obj_conv;
32424         this_obj_conv.inner = (void*)(this_obj & (~1));
32425         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32427         Shutdown_free(this_obj_conv);
32428 }
32429
32430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32431         LDKShutdown this_ptr_conv;
32432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32433         this_ptr_conv.is_owned = false;
32434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32435         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32436         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
32437         return ret_arr;
32438 }
32439
32440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32441         LDKShutdown this_ptr_conv;
32442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32443         this_ptr_conv.is_owned = false;
32444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32445         LDKThirtyTwoBytes val_ref;
32446         CHECK((*env)->GetArrayLength(env, val) == 32);
32447         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32448         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
32449 }
32450
32451 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32452         LDKShutdown this_ptr_conv;
32453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32454         this_ptr_conv.is_owned = false;
32455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32456         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
32457         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32458         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32459         return ret_arr;
32460 }
32461
32462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32463         LDKShutdown this_ptr_conv;
32464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32465         this_ptr_conv.is_owned = false;
32466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32467         LDKCVec_u8Z val_ref;
32468         val_ref.datalen = (*env)->GetArrayLength(env, val);
32469         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
32470         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
32471         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
32472 }
32473
32474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
32475         LDKThirtyTwoBytes channel_id_arg_ref;
32476         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32477         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32478         LDKCVec_u8Z scriptpubkey_arg_ref;
32479         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
32480         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
32481         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
32482         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
32483         int64_t ret_ref = 0;
32484         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32485         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32487         ret_ref = (uintptr_t)ret_var.inner;
32488         if (ret_var.is_owned) {
32489                 ret_ref |= 1;
32490         }
32491         return ret_ref;
32492 }
32493
32494 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
32495         LDKShutdown ret_var = Shutdown_clone(arg);
32496 int64_t ret_ref = 0;
32497 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32498 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32499 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32500 ret_ref = (uintptr_t)ret_var.inner;
32501 if (ret_var.is_owned) {
32502         ret_ref |= 1;
32503 }
32504         return ret_ref;
32505 }
32506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32507         LDKShutdown arg_conv;
32508         arg_conv.inner = (void*)(arg & (~1));
32509         arg_conv.is_owned = false;
32510         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32511         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
32512         return ret_conv;
32513 }
32514
32515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32516         LDKShutdown orig_conv;
32517         orig_conv.inner = (void*)(orig & (~1));
32518         orig_conv.is_owned = false;
32519         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32520         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
32521         int64_t ret_ref = 0;
32522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32525         ret_ref = (uintptr_t)ret_var.inner;
32526         if (ret_var.is_owned) {
32527                 ret_ref |= 1;
32528         }
32529         return ret_ref;
32530 }
32531
32532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32533         LDKClosingSignedFeeRange this_obj_conv;
32534         this_obj_conv.inner = (void*)(this_obj & (~1));
32535         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32537         ClosingSignedFeeRange_free(this_obj_conv);
32538 }
32539
32540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32541         LDKClosingSignedFeeRange this_ptr_conv;
32542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32543         this_ptr_conv.is_owned = false;
32544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32545         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
32546         return ret_conv;
32547 }
32548
32549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32550         LDKClosingSignedFeeRange this_ptr_conv;
32551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32552         this_ptr_conv.is_owned = false;
32553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32554         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
32555 }
32556
32557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32558         LDKClosingSignedFeeRange this_ptr_conv;
32559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32560         this_ptr_conv.is_owned = false;
32561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32562         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
32563         return ret_conv;
32564 }
32565
32566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32567         LDKClosingSignedFeeRange this_ptr_conv;
32568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32569         this_ptr_conv.is_owned = false;
32570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32571         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
32572 }
32573
32574 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) {
32575         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
32576         int64_t ret_ref = 0;
32577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32580         ret_ref = (uintptr_t)ret_var.inner;
32581         if (ret_var.is_owned) {
32582                 ret_ref |= 1;
32583         }
32584         return ret_ref;
32585 }
32586
32587 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
32588         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
32589 int64_t ret_ref = 0;
32590 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32591 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32592 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32593 ret_ref = (uintptr_t)ret_var.inner;
32594 if (ret_var.is_owned) {
32595         ret_ref |= 1;
32596 }
32597         return ret_ref;
32598 }
32599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32600         LDKClosingSignedFeeRange arg_conv;
32601         arg_conv.inner = (void*)(arg & (~1));
32602         arg_conv.is_owned = false;
32603         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32604         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
32605         return ret_conv;
32606 }
32607
32608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32609         LDKClosingSignedFeeRange orig_conv;
32610         orig_conv.inner = (void*)(orig & (~1));
32611         orig_conv.is_owned = false;
32612         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32613         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
32614         int64_t ret_ref = 0;
32615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32618         ret_ref = (uintptr_t)ret_var.inner;
32619         if (ret_var.is_owned) {
32620                 ret_ref |= 1;
32621         }
32622         return ret_ref;
32623 }
32624
32625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32626         LDKClosingSigned this_obj_conv;
32627         this_obj_conv.inner = (void*)(this_obj & (~1));
32628         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32630         ClosingSigned_free(this_obj_conv);
32631 }
32632
32633 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32634         LDKClosingSigned this_ptr_conv;
32635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32636         this_ptr_conv.is_owned = false;
32637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32638         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32639         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
32640         return ret_arr;
32641 }
32642
32643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32644         LDKClosingSigned this_ptr_conv;
32645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32646         this_ptr_conv.is_owned = false;
32647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32648         LDKThirtyTwoBytes val_ref;
32649         CHECK((*env)->GetArrayLength(env, val) == 32);
32650         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32651         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
32652 }
32653
32654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32655         LDKClosingSigned this_ptr_conv;
32656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32657         this_ptr_conv.is_owned = false;
32658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32659         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
32660         return ret_conv;
32661 }
32662
32663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32664         LDKClosingSigned this_ptr_conv;
32665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32666         this_ptr_conv.is_owned = false;
32667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32668         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
32669 }
32670
32671 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32672         LDKClosingSigned this_ptr_conv;
32673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32674         this_ptr_conv.is_owned = false;
32675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32676         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32677         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
32678         return ret_arr;
32679 }
32680
32681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32682         LDKClosingSigned this_ptr_conv;
32683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32684         this_ptr_conv.is_owned = false;
32685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32686         LDKSignature val_ref;
32687         CHECK((*env)->GetArrayLength(env, val) == 64);
32688         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32689         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
32690 }
32691
32692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
32693         LDKClosingSigned this_ptr_conv;
32694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32695         this_ptr_conv.is_owned = false;
32696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32697         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
32698         int64_t ret_ref = 0;
32699         if ((uintptr_t)ret_var.inner > 4096) {
32700                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32701                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32703                 ret_ref = (uintptr_t)ret_var.inner;
32704                 if (ret_var.is_owned) {
32705                         ret_ref |= 1;
32706                 }
32707         }
32708         return ret_ref;
32709 }
32710
32711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32712         LDKClosingSigned this_ptr_conv;
32713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32714         this_ptr_conv.is_owned = false;
32715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32716         LDKClosingSignedFeeRange val_conv;
32717         val_conv.inner = (void*)(val & (~1));
32718         val_conv.is_owned = (val & 1) || (val == 0);
32719         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32720         val_conv = ClosingSignedFeeRange_clone(&val_conv);
32721         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
32722 }
32723
32724 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) {
32725         LDKThirtyTwoBytes channel_id_arg_ref;
32726         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32727         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32728         LDKSignature signature_arg_ref;
32729         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32730         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32731         LDKClosingSignedFeeRange fee_range_arg_conv;
32732         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
32733         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
32734         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
32735         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
32736         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
32737         int64_t ret_ref = 0;
32738         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32739         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32741         ret_ref = (uintptr_t)ret_var.inner;
32742         if (ret_var.is_owned) {
32743                 ret_ref |= 1;
32744         }
32745         return ret_ref;
32746 }
32747
32748 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
32749         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
32750 int64_t ret_ref = 0;
32751 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32752 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32753 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32754 ret_ref = (uintptr_t)ret_var.inner;
32755 if (ret_var.is_owned) {
32756         ret_ref |= 1;
32757 }
32758         return ret_ref;
32759 }
32760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32761         LDKClosingSigned arg_conv;
32762         arg_conv.inner = (void*)(arg & (~1));
32763         arg_conv.is_owned = false;
32764         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32765         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
32766         return ret_conv;
32767 }
32768
32769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32770         LDKClosingSigned orig_conv;
32771         orig_conv.inner = (void*)(orig & (~1));
32772         orig_conv.is_owned = false;
32773         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32774         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
32775         int64_t ret_ref = 0;
32776         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32777         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32779         ret_ref = (uintptr_t)ret_var.inner;
32780         if (ret_var.is_owned) {
32781                 ret_ref |= 1;
32782         }
32783         return ret_ref;
32784 }
32785
32786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32787         LDKUpdateAddHTLC this_obj_conv;
32788         this_obj_conv.inner = (void*)(this_obj & (~1));
32789         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32791         UpdateAddHTLC_free(this_obj_conv);
32792 }
32793
32794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32795         LDKUpdateAddHTLC this_ptr_conv;
32796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32797         this_ptr_conv.is_owned = false;
32798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32799         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32800         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
32801         return ret_arr;
32802 }
32803
32804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32805         LDKUpdateAddHTLC this_ptr_conv;
32806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32807         this_ptr_conv.is_owned = false;
32808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32809         LDKThirtyTwoBytes val_ref;
32810         CHECK((*env)->GetArrayLength(env, val) == 32);
32811         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32812         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
32813 }
32814
32815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32816         LDKUpdateAddHTLC this_ptr_conv;
32817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32818         this_ptr_conv.is_owned = false;
32819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32820         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
32821         return ret_conv;
32822 }
32823
32824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32825         LDKUpdateAddHTLC this_ptr_conv;
32826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32827         this_ptr_conv.is_owned = false;
32828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32829         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
32830 }
32831
32832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32833         LDKUpdateAddHTLC this_ptr_conv;
32834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32835         this_ptr_conv.is_owned = false;
32836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32837         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
32838         return ret_conv;
32839 }
32840
32841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32842         LDKUpdateAddHTLC this_ptr_conv;
32843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32844         this_ptr_conv.is_owned = false;
32845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32846         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
32847 }
32848
32849 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32850         LDKUpdateAddHTLC this_ptr_conv;
32851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32852         this_ptr_conv.is_owned = false;
32853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32854         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32855         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
32856         return ret_arr;
32857 }
32858
32859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32860         LDKUpdateAddHTLC this_ptr_conv;
32861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32862         this_ptr_conv.is_owned = false;
32863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32864         LDKThirtyTwoBytes val_ref;
32865         CHECK((*env)->GetArrayLength(env, val) == 32);
32866         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32867         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
32868 }
32869
32870 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
32871         LDKUpdateAddHTLC this_ptr_conv;
32872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32873         this_ptr_conv.is_owned = false;
32874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32875         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
32876         return ret_conv;
32877 }
32878
32879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32880         LDKUpdateAddHTLC this_ptr_conv;
32881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32882         this_ptr_conv.is_owned = false;
32883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32884         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
32885 }
32886
32887 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
32888         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
32889 int64_t ret_ref = 0;
32890 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32891 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32892 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32893 ret_ref = (uintptr_t)ret_var.inner;
32894 if (ret_var.is_owned) {
32895         ret_ref |= 1;
32896 }
32897         return ret_ref;
32898 }
32899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32900         LDKUpdateAddHTLC arg_conv;
32901         arg_conv.inner = (void*)(arg & (~1));
32902         arg_conv.is_owned = false;
32903         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32904         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
32905         return ret_conv;
32906 }
32907
32908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32909         LDKUpdateAddHTLC orig_conv;
32910         orig_conv.inner = (void*)(orig & (~1));
32911         orig_conv.is_owned = false;
32912         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32913         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
32914         int64_t ret_ref = 0;
32915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32918         ret_ref = (uintptr_t)ret_var.inner;
32919         if (ret_var.is_owned) {
32920                 ret_ref |= 1;
32921         }
32922         return ret_ref;
32923 }
32924
32925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32926         LDKUpdateFulfillHTLC this_obj_conv;
32927         this_obj_conv.inner = (void*)(this_obj & (~1));
32928         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32930         UpdateFulfillHTLC_free(this_obj_conv);
32931 }
32932
32933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32934         LDKUpdateFulfillHTLC this_ptr_conv;
32935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32936         this_ptr_conv.is_owned = false;
32937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32938         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32939         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
32940         return ret_arr;
32941 }
32942
32943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32944         LDKUpdateFulfillHTLC this_ptr_conv;
32945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32946         this_ptr_conv.is_owned = false;
32947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32948         LDKThirtyTwoBytes val_ref;
32949         CHECK((*env)->GetArrayLength(env, val) == 32);
32950         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32951         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
32952 }
32953
32954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32955         LDKUpdateFulfillHTLC this_ptr_conv;
32956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32957         this_ptr_conv.is_owned = false;
32958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32959         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
32960         return ret_conv;
32961 }
32962
32963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32964         LDKUpdateFulfillHTLC this_ptr_conv;
32965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32966         this_ptr_conv.is_owned = false;
32967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32968         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
32969 }
32970
32971 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
32972         LDKUpdateFulfillHTLC this_ptr_conv;
32973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32974         this_ptr_conv.is_owned = false;
32975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32976         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32977         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
32978         return ret_arr;
32979 }
32980
32981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32982         LDKUpdateFulfillHTLC this_ptr_conv;
32983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32984         this_ptr_conv.is_owned = false;
32985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32986         LDKThirtyTwoBytes val_ref;
32987         CHECK((*env)->GetArrayLength(env, val) == 32);
32988         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32989         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
32990 }
32991
32992 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) {
32993         LDKThirtyTwoBytes channel_id_arg_ref;
32994         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32995         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32996         LDKThirtyTwoBytes payment_preimage_arg_ref;
32997         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
32998         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
32999         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
33000         int64_t ret_ref = 0;
33001         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33002         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33004         ret_ref = (uintptr_t)ret_var.inner;
33005         if (ret_var.is_owned) {
33006                 ret_ref |= 1;
33007         }
33008         return ret_ref;
33009 }
33010
33011 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
33012         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
33013 int64_t ret_ref = 0;
33014 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33015 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33016 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33017 ret_ref = (uintptr_t)ret_var.inner;
33018 if (ret_var.is_owned) {
33019         ret_ref |= 1;
33020 }
33021         return ret_ref;
33022 }
33023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33024         LDKUpdateFulfillHTLC arg_conv;
33025         arg_conv.inner = (void*)(arg & (~1));
33026         arg_conv.is_owned = false;
33027         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33028         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
33029         return ret_conv;
33030 }
33031
33032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33033         LDKUpdateFulfillHTLC orig_conv;
33034         orig_conv.inner = (void*)(orig & (~1));
33035         orig_conv.is_owned = false;
33036         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33037         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
33038         int64_t ret_ref = 0;
33039         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33040         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33042         ret_ref = (uintptr_t)ret_var.inner;
33043         if (ret_var.is_owned) {
33044                 ret_ref |= 1;
33045         }
33046         return ret_ref;
33047 }
33048
33049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33050         LDKUpdateFailHTLC this_obj_conv;
33051         this_obj_conv.inner = (void*)(this_obj & (~1));
33052         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33054         UpdateFailHTLC_free(this_obj_conv);
33055 }
33056
33057 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33058         LDKUpdateFailHTLC this_ptr_conv;
33059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33060         this_ptr_conv.is_owned = false;
33061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33062         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33063         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
33064         return ret_arr;
33065 }
33066
33067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33068         LDKUpdateFailHTLC this_ptr_conv;
33069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33070         this_ptr_conv.is_owned = false;
33071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33072         LDKThirtyTwoBytes val_ref;
33073         CHECK((*env)->GetArrayLength(env, val) == 32);
33074         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33075         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
33076 }
33077
33078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33079         LDKUpdateFailHTLC this_ptr_conv;
33080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33081         this_ptr_conv.is_owned = false;
33082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33083         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
33084         return ret_conv;
33085 }
33086
33087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33088         LDKUpdateFailHTLC this_ptr_conv;
33089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33090         this_ptr_conv.is_owned = false;
33091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33092         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
33093 }
33094
33095 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
33096         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
33097 int64_t ret_ref = 0;
33098 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33099 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33100 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33101 ret_ref = (uintptr_t)ret_var.inner;
33102 if (ret_var.is_owned) {
33103         ret_ref |= 1;
33104 }
33105         return ret_ref;
33106 }
33107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33108         LDKUpdateFailHTLC arg_conv;
33109         arg_conv.inner = (void*)(arg & (~1));
33110         arg_conv.is_owned = false;
33111         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33112         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
33113         return ret_conv;
33114 }
33115
33116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33117         LDKUpdateFailHTLC orig_conv;
33118         orig_conv.inner = (void*)(orig & (~1));
33119         orig_conv.is_owned = false;
33120         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33121         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
33122         int64_t ret_ref = 0;
33123         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33124         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33126         ret_ref = (uintptr_t)ret_var.inner;
33127         if (ret_var.is_owned) {
33128                 ret_ref |= 1;
33129         }
33130         return ret_ref;
33131 }
33132
33133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33134         LDKUpdateFailMalformedHTLC this_obj_conv;
33135         this_obj_conv.inner = (void*)(this_obj & (~1));
33136         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33138         UpdateFailMalformedHTLC_free(this_obj_conv);
33139 }
33140
33141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33142         LDKUpdateFailMalformedHTLC this_ptr_conv;
33143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33144         this_ptr_conv.is_owned = false;
33145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33146         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33147         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
33148         return ret_arr;
33149 }
33150
33151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33152         LDKUpdateFailMalformedHTLC this_ptr_conv;
33153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33154         this_ptr_conv.is_owned = false;
33155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33156         LDKThirtyTwoBytes val_ref;
33157         CHECK((*env)->GetArrayLength(env, val) == 32);
33158         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33159         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
33160 }
33161
33162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33163         LDKUpdateFailMalformedHTLC this_ptr_conv;
33164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33165         this_ptr_conv.is_owned = false;
33166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33167         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
33168         return ret_conv;
33169 }
33170
33171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33172         LDKUpdateFailMalformedHTLC this_ptr_conv;
33173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33174         this_ptr_conv.is_owned = false;
33175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33176         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
33177 }
33178
33179 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
33180         LDKUpdateFailMalformedHTLC this_ptr_conv;
33181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33182         this_ptr_conv.is_owned = false;
33183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33184         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
33185         return ret_conv;
33186 }
33187
33188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33189         LDKUpdateFailMalformedHTLC this_ptr_conv;
33190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33191         this_ptr_conv.is_owned = false;
33192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33193         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
33194 }
33195
33196 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
33197         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
33198 int64_t ret_ref = 0;
33199 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33200 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33201 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33202 ret_ref = (uintptr_t)ret_var.inner;
33203 if (ret_var.is_owned) {
33204         ret_ref |= 1;
33205 }
33206         return ret_ref;
33207 }
33208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33209         LDKUpdateFailMalformedHTLC arg_conv;
33210         arg_conv.inner = (void*)(arg & (~1));
33211         arg_conv.is_owned = false;
33212         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33213         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
33214         return ret_conv;
33215 }
33216
33217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33218         LDKUpdateFailMalformedHTLC orig_conv;
33219         orig_conv.inner = (void*)(orig & (~1));
33220         orig_conv.is_owned = false;
33221         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33222         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
33223         int64_t ret_ref = 0;
33224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33227         ret_ref = (uintptr_t)ret_var.inner;
33228         if (ret_var.is_owned) {
33229                 ret_ref |= 1;
33230         }
33231         return ret_ref;
33232 }
33233
33234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33235         LDKCommitmentSigned this_obj_conv;
33236         this_obj_conv.inner = (void*)(this_obj & (~1));
33237         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33239         CommitmentSigned_free(this_obj_conv);
33240 }
33241
33242 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33243         LDKCommitmentSigned this_ptr_conv;
33244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33245         this_ptr_conv.is_owned = false;
33246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33247         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33248         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
33249         return ret_arr;
33250 }
33251
33252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33253         LDKCommitmentSigned this_ptr_conv;
33254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33255         this_ptr_conv.is_owned = false;
33256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33257         LDKThirtyTwoBytes val_ref;
33258         CHECK((*env)->GetArrayLength(env, val) == 32);
33259         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33260         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
33261 }
33262
33263 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33264         LDKCommitmentSigned this_ptr_conv;
33265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33266         this_ptr_conv.is_owned = false;
33267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33268         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33269         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
33270         return ret_arr;
33271 }
33272
33273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33274         LDKCommitmentSigned this_ptr_conv;
33275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33276         this_ptr_conv.is_owned = false;
33277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33278         LDKSignature val_ref;
33279         CHECK((*env)->GetArrayLength(env, val) == 64);
33280         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33281         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
33282 }
33283
33284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
33285         LDKCommitmentSigned this_ptr_conv;
33286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33287         this_ptr_conv.is_owned = false;
33288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33289         LDKCVec_SignatureZ val_constr;
33290         val_constr.datalen = (*env)->GetArrayLength(env, val);
33291         if (val_constr.datalen > 0)
33292                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33293         else
33294                 val_constr.data = NULL;
33295         for (size_t i = 0; i < val_constr.datalen; i++) {
33296                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
33297                 LDKSignature val_conv_8_ref;
33298                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
33299                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
33300                 val_constr.data[i] = val_conv_8_ref;
33301         }
33302         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
33303 }
33304
33305 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) {
33306         LDKThirtyTwoBytes channel_id_arg_ref;
33307         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33308         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33309         LDKSignature signature_arg_ref;
33310         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33311         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33312         LDKCVec_SignatureZ htlc_signatures_arg_constr;
33313         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
33314         if (htlc_signatures_arg_constr.datalen > 0)
33315                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33316         else
33317                 htlc_signatures_arg_constr.data = NULL;
33318         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
33319                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
33320                 LDKSignature htlc_signatures_arg_conv_8_ref;
33321                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
33322                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
33323                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
33324         }
33325         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
33326         int64_t ret_ref = 0;
33327         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33328         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33330         ret_ref = (uintptr_t)ret_var.inner;
33331         if (ret_var.is_owned) {
33332                 ret_ref |= 1;
33333         }
33334         return ret_ref;
33335 }
33336
33337 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
33338         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
33339 int64_t ret_ref = 0;
33340 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33341 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33342 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33343 ret_ref = (uintptr_t)ret_var.inner;
33344 if (ret_var.is_owned) {
33345         ret_ref |= 1;
33346 }
33347         return ret_ref;
33348 }
33349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33350         LDKCommitmentSigned arg_conv;
33351         arg_conv.inner = (void*)(arg & (~1));
33352         arg_conv.is_owned = false;
33353         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33354         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
33355         return ret_conv;
33356 }
33357
33358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33359         LDKCommitmentSigned orig_conv;
33360         orig_conv.inner = (void*)(orig & (~1));
33361         orig_conv.is_owned = false;
33362         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33363         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
33364         int64_t ret_ref = 0;
33365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33368         ret_ref = (uintptr_t)ret_var.inner;
33369         if (ret_var.is_owned) {
33370                 ret_ref |= 1;
33371         }
33372         return ret_ref;
33373 }
33374
33375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33376         LDKRevokeAndACK this_obj_conv;
33377         this_obj_conv.inner = (void*)(this_obj & (~1));
33378         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33380         RevokeAndACK_free(this_obj_conv);
33381 }
33382
33383 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33384         LDKRevokeAndACK this_ptr_conv;
33385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33386         this_ptr_conv.is_owned = false;
33387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33388         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33389         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
33390         return ret_arr;
33391 }
33392
33393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33394         LDKRevokeAndACK this_ptr_conv;
33395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33396         this_ptr_conv.is_owned = false;
33397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33398         LDKThirtyTwoBytes val_ref;
33399         CHECK((*env)->GetArrayLength(env, val) == 32);
33400         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33401         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
33402 }
33403
33404 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
33405         LDKRevokeAndACK this_ptr_conv;
33406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33407         this_ptr_conv.is_owned = false;
33408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33409         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33410         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
33411         return ret_arr;
33412 }
33413
33414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33415         LDKRevokeAndACK this_ptr_conv;
33416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33417         this_ptr_conv.is_owned = false;
33418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33419         LDKThirtyTwoBytes val_ref;
33420         CHECK((*env)->GetArrayLength(env, val) == 32);
33421         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33422         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
33423 }
33424
33425 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33426         LDKRevokeAndACK this_ptr_conv;
33427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33428         this_ptr_conv.is_owned = false;
33429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33430         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33431         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
33432         return ret_arr;
33433 }
33434
33435 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) {
33436         LDKRevokeAndACK this_ptr_conv;
33437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33438         this_ptr_conv.is_owned = false;
33439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33440         LDKPublicKey val_ref;
33441         CHECK((*env)->GetArrayLength(env, val) == 33);
33442         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33443         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
33444 }
33445
33446 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) {
33447         LDKThirtyTwoBytes channel_id_arg_ref;
33448         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33449         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33450         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
33451         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
33452         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
33453         LDKPublicKey next_per_commitment_point_arg_ref;
33454         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
33455         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
33456         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
33457         int64_t ret_ref = 0;
33458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33461         ret_ref = (uintptr_t)ret_var.inner;
33462         if (ret_var.is_owned) {
33463                 ret_ref |= 1;
33464         }
33465         return ret_ref;
33466 }
33467
33468 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
33469         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
33470 int64_t ret_ref = 0;
33471 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33472 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33473 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33474 ret_ref = (uintptr_t)ret_var.inner;
33475 if (ret_var.is_owned) {
33476         ret_ref |= 1;
33477 }
33478         return ret_ref;
33479 }
33480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33481         LDKRevokeAndACK arg_conv;
33482         arg_conv.inner = (void*)(arg & (~1));
33483         arg_conv.is_owned = false;
33484         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33485         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
33486         return ret_conv;
33487 }
33488
33489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33490         LDKRevokeAndACK orig_conv;
33491         orig_conv.inner = (void*)(orig & (~1));
33492         orig_conv.is_owned = false;
33493         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33494         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
33495         int64_t ret_ref = 0;
33496         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33497         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33499         ret_ref = (uintptr_t)ret_var.inner;
33500         if (ret_var.is_owned) {
33501                 ret_ref |= 1;
33502         }
33503         return ret_ref;
33504 }
33505
33506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33507         LDKUpdateFee this_obj_conv;
33508         this_obj_conv.inner = (void*)(this_obj & (~1));
33509         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33511         UpdateFee_free(this_obj_conv);
33512 }
33513
33514 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33515         LDKUpdateFee this_ptr_conv;
33516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33517         this_ptr_conv.is_owned = false;
33518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33519         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33520         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
33521         return ret_arr;
33522 }
33523
33524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33525         LDKUpdateFee this_ptr_conv;
33526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33527         this_ptr_conv.is_owned = false;
33528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33529         LDKThirtyTwoBytes val_ref;
33530         CHECK((*env)->GetArrayLength(env, val) == 32);
33531         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33532         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
33533 }
33534
33535 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
33536         LDKUpdateFee this_ptr_conv;
33537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33538         this_ptr_conv.is_owned = false;
33539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33540         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
33541         return ret_conv;
33542 }
33543
33544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33545         LDKUpdateFee this_ptr_conv;
33546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33547         this_ptr_conv.is_owned = false;
33548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33549         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
33550 }
33551
33552 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) {
33553         LDKThirtyTwoBytes channel_id_arg_ref;
33554         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33555         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33556         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
33557         int64_t ret_ref = 0;
33558         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33559         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33561         ret_ref = (uintptr_t)ret_var.inner;
33562         if (ret_var.is_owned) {
33563                 ret_ref |= 1;
33564         }
33565         return ret_ref;
33566 }
33567
33568 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
33569         LDKUpdateFee ret_var = UpdateFee_clone(arg);
33570 int64_t ret_ref = 0;
33571 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33572 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33573 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33574 ret_ref = (uintptr_t)ret_var.inner;
33575 if (ret_var.is_owned) {
33576         ret_ref |= 1;
33577 }
33578         return ret_ref;
33579 }
33580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33581         LDKUpdateFee arg_conv;
33582         arg_conv.inner = (void*)(arg & (~1));
33583         arg_conv.is_owned = false;
33584         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33585         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
33586         return ret_conv;
33587 }
33588
33589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33590         LDKUpdateFee orig_conv;
33591         orig_conv.inner = (void*)(orig & (~1));
33592         orig_conv.is_owned = false;
33593         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33594         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
33595         int64_t ret_ref = 0;
33596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33599         ret_ref = (uintptr_t)ret_var.inner;
33600         if (ret_var.is_owned) {
33601                 ret_ref |= 1;
33602         }
33603         return ret_ref;
33604 }
33605
33606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33607         LDKDataLossProtect this_obj_conv;
33608         this_obj_conv.inner = (void*)(this_obj & (~1));
33609         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33611         DataLossProtect_free(this_obj_conv);
33612 }
33613
33614 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
33615         LDKDataLossProtect this_ptr_conv;
33616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33617         this_ptr_conv.is_owned = false;
33618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33619         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33620         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
33621         return ret_arr;
33622 }
33623
33624 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) {
33625         LDKDataLossProtect this_ptr_conv;
33626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33627         this_ptr_conv.is_owned = false;
33628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33629         LDKThirtyTwoBytes val_ref;
33630         CHECK((*env)->GetArrayLength(env, val) == 32);
33631         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33632         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
33633 }
33634
33635 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33636         LDKDataLossProtect this_ptr_conv;
33637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33638         this_ptr_conv.is_owned = false;
33639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33640         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33641         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
33642         return ret_arr;
33643 }
33644
33645 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) {
33646         LDKDataLossProtect this_ptr_conv;
33647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33648         this_ptr_conv.is_owned = false;
33649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33650         LDKPublicKey val_ref;
33651         CHECK((*env)->GetArrayLength(env, val) == 33);
33652         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33653         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
33654 }
33655
33656 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) {
33657         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
33658         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
33659         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
33660         LDKPublicKey my_current_per_commitment_point_arg_ref;
33661         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
33662         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
33663         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
33664         int64_t ret_ref = 0;
33665         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33666         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33668         ret_ref = (uintptr_t)ret_var.inner;
33669         if (ret_var.is_owned) {
33670                 ret_ref |= 1;
33671         }
33672         return ret_ref;
33673 }
33674
33675 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
33676         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
33677 int64_t ret_ref = 0;
33678 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33679 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33680 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33681 ret_ref = (uintptr_t)ret_var.inner;
33682 if (ret_var.is_owned) {
33683         ret_ref |= 1;
33684 }
33685         return ret_ref;
33686 }
33687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33688         LDKDataLossProtect arg_conv;
33689         arg_conv.inner = (void*)(arg & (~1));
33690         arg_conv.is_owned = false;
33691         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33692         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
33693         return ret_conv;
33694 }
33695
33696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33697         LDKDataLossProtect orig_conv;
33698         orig_conv.inner = (void*)(orig & (~1));
33699         orig_conv.is_owned = false;
33700         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33701         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
33702         int64_t ret_ref = 0;
33703         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33704         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33706         ret_ref = (uintptr_t)ret_var.inner;
33707         if (ret_var.is_owned) {
33708                 ret_ref |= 1;
33709         }
33710         return ret_ref;
33711 }
33712
33713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33714         LDKChannelReestablish this_obj_conv;
33715         this_obj_conv.inner = (void*)(this_obj & (~1));
33716         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33718         ChannelReestablish_free(this_obj_conv);
33719 }
33720
33721 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33722         LDKChannelReestablish this_ptr_conv;
33723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33724         this_ptr_conv.is_owned = false;
33725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33726         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33727         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
33728         return ret_arr;
33729 }
33730
33731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33732         LDKChannelReestablish this_ptr_conv;
33733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33734         this_ptr_conv.is_owned = false;
33735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33736         LDKThirtyTwoBytes val_ref;
33737         CHECK((*env)->GetArrayLength(env, val) == 32);
33738         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33739         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
33740 }
33741
33742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
33743         LDKChannelReestablish this_ptr_conv;
33744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33745         this_ptr_conv.is_owned = false;
33746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33747         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
33748         return ret_conv;
33749 }
33750
33751 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) {
33752         LDKChannelReestablish this_ptr_conv;
33753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33754         this_ptr_conv.is_owned = false;
33755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33756         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
33757 }
33758
33759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
33760         LDKChannelReestablish this_ptr_conv;
33761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33762         this_ptr_conv.is_owned = false;
33763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33764         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
33765         return ret_conv;
33766 }
33767
33768 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) {
33769         LDKChannelReestablish this_ptr_conv;
33770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33771         this_ptr_conv.is_owned = false;
33772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33773         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
33774 }
33775
33776 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
33777         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
33778 int64_t ret_ref = 0;
33779 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33780 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33781 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33782 ret_ref = (uintptr_t)ret_var.inner;
33783 if (ret_var.is_owned) {
33784         ret_ref |= 1;
33785 }
33786         return ret_ref;
33787 }
33788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33789         LDKChannelReestablish arg_conv;
33790         arg_conv.inner = (void*)(arg & (~1));
33791         arg_conv.is_owned = false;
33792         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33793         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
33794         return ret_conv;
33795 }
33796
33797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33798         LDKChannelReestablish orig_conv;
33799         orig_conv.inner = (void*)(orig & (~1));
33800         orig_conv.is_owned = false;
33801         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33802         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
33803         int64_t ret_ref = 0;
33804         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33805         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33807         ret_ref = (uintptr_t)ret_var.inner;
33808         if (ret_var.is_owned) {
33809                 ret_ref |= 1;
33810         }
33811         return ret_ref;
33812 }
33813
33814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33815         LDKAnnouncementSignatures this_obj_conv;
33816         this_obj_conv.inner = (void*)(this_obj & (~1));
33817         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33819         AnnouncementSignatures_free(this_obj_conv);
33820 }
33821
33822 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33823         LDKAnnouncementSignatures this_ptr_conv;
33824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33825         this_ptr_conv.is_owned = false;
33826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33827         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33828         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
33829         return ret_arr;
33830 }
33831
33832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33833         LDKAnnouncementSignatures this_ptr_conv;
33834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33835         this_ptr_conv.is_owned = false;
33836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33837         LDKThirtyTwoBytes val_ref;
33838         CHECK((*env)->GetArrayLength(env, val) == 32);
33839         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33840         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
33841 }
33842
33843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33844         LDKAnnouncementSignatures this_ptr_conv;
33845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33846         this_ptr_conv.is_owned = false;
33847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33848         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
33849         return ret_conv;
33850 }
33851
33852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33853         LDKAnnouncementSignatures this_ptr_conv;
33854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33855         this_ptr_conv.is_owned = false;
33856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33857         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
33858 }
33859
33860 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33861         LDKAnnouncementSignatures this_ptr_conv;
33862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33863         this_ptr_conv.is_owned = false;
33864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33865         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33866         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
33867         return ret_arr;
33868 }
33869
33870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33871         LDKAnnouncementSignatures this_ptr_conv;
33872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33873         this_ptr_conv.is_owned = false;
33874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33875         LDKSignature val_ref;
33876         CHECK((*env)->GetArrayLength(env, val) == 64);
33877         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33878         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
33879 }
33880
33881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33882         LDKAnnouncementSignatures this_ptr_conv;
33883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33884         this_ptr_conv.is_owned = false;
33885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33886         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33887         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
33888         return ret_arr;
33889 }
33890
33891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33892         LDKAnnouncementSignatures this_ptr_conv;
33893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33894         this_ptr_conv.is_owned = false;
33895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33896         LDKSignature val_ref;
33897         CHECK((*env)->GetArrayLength(env, val) == 64);
33898         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33899         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
33900 }
33901
33902 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) {
33903         LDKThirtyTwoBytes channel_id_arg_ref;
33904         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33905         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33906         LDKSignature node_signature_arg_ref;
33907         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
33908         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
33909         LDKSignature bitcoin_signature_arg_ref;
33910         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
33911         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
33912         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
33913         int64_t ret_ref = 0;
33914         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33915         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33917         ret_ref = (uintptr_t)ret_var.inner;
33918         if (ret_var.is_owned) {
33919                 ret_ref |= 1;
33920         }
33921         return ret_ref;
33922 }
33923
33924 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
33925         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
33926 int64_t ret_ref = 0;
33927 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33928 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33929 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33930 ret_ref = (uintptr_t)ret_var.inner;
33931 if (ret_var.is_owned) {
33932         ret_ref |= 1;
33933 }
33934         return ret_ref;
33935 }
33936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33937         LDKAnnouncementSignatures arg_conv;
33938         arg_conv.inner = (void*)(arg & (~1));
33939         arg_conv.is_owned = false;
33940         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33941         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
33942         return ret_conv;
33943 }
33944
33945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33946         LDKAnnouncementSignatures orig_conv;
33947         orig_conv.inner = (void*)(orig & (~1));
33948         orig_conv.is_owned = false;
33949         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33950         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
33951         int64_t ret_ref = 0;
33952         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33953         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33955         ret_ref = (uintptr_t)ret_var.inner;
33956         if (ret_var.is_owned) {
33957                 ret_ref |= 1;
33958         }
33959         return ret_ref;
33960 }
33961
33962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
33963         if ((this_ptr & 1) != 0) return;
33964         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33965         CHECK_ACCESS(this_ptr_ptr);
33966         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
33967         FREE((void*)this_ptr);
33968         NetAddress_free(this_ptr_conv);
33969 }
33970
33971 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
33972         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33973         *ret_copy = NetAddress_clone(arg);
33974 int64_t ret_ref = (uintptr_t)ret_copy;
33975         return ret_ref;
33976 }
33977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33978         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
33979         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
33980         return ret_conv;
33981 }
33982
33983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33984         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
33985         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33986         *ret_copy = NetAddress_clone(orig_conv);
33987         int64_t ret_ref = (uintptr_t)ret_copy;
33988         return ret_ref;
33989 }
33990
33991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
33992         LDKFourBytes addr_ref;
33993         CHECK((*env)->GetArrayLength(env, addr) == 4);
33994         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
33995         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33996         *ret_copy = NetAddress_ipv4(addr_ref, port);
33997         int64_t ret_ref = (uintptr_t)ret_copy;
33998         return ret_ref;
33999 }
34000
34001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
34002         LDKSixteenBytes addr_ref;
34003         CHECK((*env)->GetArrayLength(env, addr) == 16);
34004         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
34005         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34006         *ret_copy = NetAddress_ipv6(addr_ref, port);
34007         int64_t ret_ref = (uintptr_t)ret_copy;
34008         return ret_ref;
34009 }
34010
34011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
34012         LDKTwelveBytes a_ref;
34013         CHECK((*env)->GetArrayLength(env, a) == 12);
34014         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
34015         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34016         *ret_copy = NetAddress_onion_v2(a_ref);
34017         int64_t ret_ref = (uintptr_t)ret_copy;
34018         return ret_ref;
34019 }
34020
34021 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) {
34022         LDKThirtyTwoBytes ed25519_pubkey_ref;
34023         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
34024         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
34025         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34026         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
34027         int64_t ret_ref = (uintptr_t)ret_copy;
34028         return ret_ref;
34029 }
34030
34031 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
34032         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
34033         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
34034         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34035         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34036         CVec_u8Z_free(ret_var);
34037         return ret_arr;
34038 }
34039
34040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34041         LDKu8slice ser_ref;
34042         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34043         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34044         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
34045         *ret_conv = NetAddress_read(ser_ref);
34046         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34047         return (int64_t)ret_conv;
34048 }
34049
34050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34051         LDKUnsignedNodeAnnouncement this_obj_conv;
34052         this_obj_conv.inner = (void*)(this_obj & (~1));
34053         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34055         UnsignedNodeAnnouncement_free(this_obj_conv);
34056 }
34057
34058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
34059         LDKUnsignedNodeAnnouncement this_ptr_conv;
34060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34061         this_ptr_conv.is_owned = false;
34062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34063         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
34064         int64_t ret_ref = 0;
34065         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34066         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34068         ret_ref = (uintptr_t)ret_var.inner;
34069         if (ret_var.is_owned) {
34070                 ret_ref |= 1;
34071         }
34072         return ret_ref;
34073 }
34074
34075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34076         LDKUnsignedNodeAnnouncement this_ptr_conv;
34077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34078         this_ptr_conv.is_owned = false;
34079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34080         LDKNodeFeatures val_conv;
34081         val_conv.inner = (void*)(val & (~1));
34082         val_conv.is_owned = (val & 1) || (val == 0);
34083         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34084         val_conv = NodeFeatures_clone(&val_conv);
34085         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
34086 }
34087
34088 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
34089         LDKUnsignedNodeAnnouncement this_ptr_conv;
34090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34091         this_ptr_conv.is_owned = false;
34092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34093         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
34094         return ret_conv;
34095 }
34096
34097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34098         LDKUnsignedNodeAnnouncement this_ptr_conv;
34099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34100         this_ptr_conv.is_owned = false;
34101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34102         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
34103 }
34104
34105 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34106         LDKUnsignedNodeAnnouncement this_ptr_conv;
34107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34108         this_ptr_conv.is_owned = false;
34109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34110         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34111         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
34112         return ret_arr;
34113 }
34114
34115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34116         LDKUnsignedNodeAnnouncement this_ptr_conv;
34117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34118         this_ptr_conv.is_owned = false;
34119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34120         LDKPublicKey val_ref;
34121         CHECK((*env)->GetArrayLength(env, val) == 33);
34122         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34123         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
34124 }
34125
34126 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
34127         LDKUnsignedNodeAnnouncement this_ptr_conv;
34128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34129         this_ptr_conv.is_owned = false;
34130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34131         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
34132         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
34133         return ret_arr;
34134 }
34135
34136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34137         LDKUnsignedNodeAnnouncement this_ptr_conv;
34138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34139         this_ptr_conv.is_owned = false;
34140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34141         LDKThreeBytes val_ref;
34142         CHECK((*env)->GetArrayLength(env, val) == 3);
34143         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
34144         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
34145 }
34146
34147 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
34148         LDKUnsignedNodeAnnouncement this_ptr_conv;
34149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34150         this_ptr_conv.is_owned = false;
34151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34152         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34153         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
34154         return ret_arr;
34155 }
34156
34157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34158         LDKUnsignedNodeAnnouncement this_ptr_conv;
34159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34160         this_ptr_conv.is_owned = false;
34161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34162         LDKThirtyTwoBytes val_ref;
34163         CHECK((*env)->GetArrayLength(env, val) == 32);
34164         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34165         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
34166 }
34167
34168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34169         LDKUnsignedNodeAnnouncement this_ptr_conv;
34170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34171         this_ptr_conv.is_owned = false;
34172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34173         LDKCVec_NetAddressZ val_constr;
34174         val_constr.datalen = (*env)->GetArrayLength(env, val);
34175         if (val_constr.datalen > 0)
34176                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
34177         else
34178                 val_constr.data = NULL;
34179         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34180         for (size_t m = 0; m < val_constr.datalen; m++) {
34181                 int64_t val_conv_12 = val_vals[m];
34182                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
34183                 CHECK_ACCESS(val_conv_12_ptr);
34184                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
34185                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
34186                 val_constr.data[m] = val_conv_12_conv;
34187         }
34188         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34189         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
34190 }
34191
34192 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
34193         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
34194 int64_t ret_ref = 0;
34195 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34196 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34197 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34198 ret_ref = (uintptr_t)ret_var.inner;
34199 if (ret_var.is_owned) {
34200         ret_ref |= 1;
34201 }
34202         return ret_ref;
34203 }
34204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34205         LDKUnsignedNodeAnnouncement arg_conv;
34206         arg_conv.inner = (void*)(arg & (~1));
34207         arg_conv.is_owned = false;
34208         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34209         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
34210         return ret_conv;
34211 }
34212
34213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34214         LDKUnsignedNodeAnnouncement orig_conv;
34215         orig_conv.inner = (void*)(orig & (~1));
34216         orig_conv.is_owned = false;
34217         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34218         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
34219         int64_t ret_ref = 0;
34220         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34221         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34223         ret_ref = (uintptr_t)ret_var.inner;
34224         if (ret_var.is_owned) {
34225                 ret_ref |= 1;
34226         }
34227         return ret_ref;
34228 }
34229
34230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34231         LDKNodeAnnouncement this_obj_conv;
34232         this_obj_conv.inner = (void*)(this_obj & (~1));
34233         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34235         NodeAnnouncement_free(this_obj_conv);
34236 }
34237
34238 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34239         LDKNodeAnnouncement this_ptr_conv;
34240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34241         this_ptr_conv.is_owned = false;
34242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34243         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34244         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
34245         return ret_arr;
34246 }
34247
34248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34249         LDKNodeAnnouncement this_ptr_conv;
34250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34251         this_ptr_conv.is_owned = false;
34252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34253         LDKSignature val_ref;
34254         CHECK((*env)->GetArrayLength(env, val) == 64);
34255         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34256         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
34257 }
34258
34259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
34260         LDKNodeAnnouncement this_ptr_conv;
34261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34262         this_ptr_conv.is_owned = false;
34263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34264         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
34265         int64_t ret_ref = 0;
34266         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34267         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34269         ret_ref = (uintptr_t)ret_var.inner;
34270         if (ret_var.is_owned) {
34271                 ret_ref |= 1;
34272         }
34273         return ret_ref;
34274 }
34275
34276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34277         LDKNodeAnnouncement this_ptr_conv;
34278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34279         this_ptr_conv.is_owned = false;
34280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34281         LDKUnsignedNodeAnnouncement val_conv;
34282         val_conv.inner = (void*)(val & (~1));
34283         val_conv.is_owned = (val & 1) || (val == 0);
34284         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34285         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
34286         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
34287 }
34288
34289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
34290         LDKSignature signature_arg_ref;
34291         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34292         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34293         LDKUnsignedNodeAnnouncement contents_arg_conv;
34294         contents_arg_conv.inner = (void*)(contents_arg & (~1));
34295         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
34296         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
34297         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
34298         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
34299         int64_t ret_ref = 0;
34300         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34301         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34303         ret_ref = (uintptr_t)ret_var.inner;
34304         if (ret_var.is_owned) {
34305                 ret_ref |= 1;
34306         }
34307         return ret_ref;
34308 }
34309
34310 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
34311         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
34312 int64_t ret_ref = 0;
34313 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34314 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34315 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34316 ret_ref = (uintptr_t)ret_var.inner;
34317 if (ret_var.is_owned) {
34318         ret_ref |= 1;
34319 }
34320         return ret_ref;
34321 }
34322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34323         LDKNodeAnnouncement arg_conv;
34324         arg_conv.inner = (void*)(arg & (~1));
34325         arg_conv.is_owned = false;
34326         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34327         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
34328         return ret_conv;
34329 }
34330
34331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34332         LDKNodeAnnouncement orig_conv;
34333         orig_conv.inner = (void*)(orig & (~1));
34334         orig_conv.is_owned = false;
34335         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34336         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
34337         int64_t ret_ref = 0;
34338         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34339         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34341         ret_ref = (uintptr_t)ret_var.inner;
34342         if (ret_var.is_owned) {
34343                 ret_ref |= 1;
34344         }
34345         return ret_ref;
34346 }
34347
34348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34349         LDKUnsignedChannelAnnouncement this_obj_conv;
34350         this_obj_conv.inner = (void*)(this_obj & (~1));
34351         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34353         UnsignedChannelAnnouncement_free(this_obj_conv);
34354 }
34355
34356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
34357         LDKUnsignedChannelAnnouncement this_ptr_conv;
34358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34359         this_ptr_conv.is_owned = false;
34360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34361         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
34362         int64_t ret_ref = 0;
34363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34366         ret_ref = (uintptr_t)ret_var.inner;
34367         if (ret_var.is_owned) {
34368                 ret_ref |= 1;
34369         }
34370         return ret_ref;
34371 }
34372
34373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34374         LDKUnsignedChannelAnnouncement this_ptr_conv;
34375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34376         this_ptr_conv.is_owned = false;
34377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34378         LDKChannelFeatures val_conv;
34379         val_conv.inner = (void*)(val & (~1));
34380         val_conv.is_owned = (val & 1) || (val == 0);
34381         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34382         val_conv = ChannelFeatures_clone(&val_conv);
34383         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
34384 }
34385
34386 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34387         LDKUnsignedChannelAnnouncement this_ptr_conv;
34388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34389         this_ptr_conv.is_owned = false;
34390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34391         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34392         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
34393         return ret_arr;
34394 }
34395
34396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34397         LDKUnsignedChannelAnnouncement this_ptr_conv;
34398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34399         this_ptr_conv.is_owned = false;
34400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34401         LDKThirtyTwoBytes val_ref;
34402         CHECK((*env)->GetArrayLength(env, val) == 32);
34403         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34404         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
34405 }
34406
34407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34408         LDKUnsignedChannelAnnouncement this_ptr_conv;
34409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34410         this_ptr_conv.is_owned = false;
34411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34412         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
34413         return ret_conv;
34414 }
34415
34416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34417         LDKUnsignedChannelAnnouncement this_ptr_conv;
34418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34419         this_ptr_conv.is_owned = false;
34420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34421         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
34422 }
34423
34424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34425         LDKUnsignedChannelAnnouncement this_ptr_conv;
34426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34427         this_ptr_conv.is_owned = false;
34428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34429         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34430         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
34431         return ret_arr;
34432 }
34433
34434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34435         LDKUnsignedChannelAnnouncement 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         LDKPublicKey val_ref;
34440         CHECK((*env)->GetArrayLength(env, val) == 33);
34441         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34442         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
34443 }
34444
34445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34446         LDKUnsignedChannelAnnouncement this_ptr_conv;
34447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34448         this_ptr_conv.is_owned = false;
34449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34450         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34451         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
34452         return ret_arr;
34453 }
34454
34455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34456         LDKUnsignedChannelAnnouncement 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         LDKPublicKey val_ref;
34461         CHECK((*env)->GetArrayLength(env, val) == 33);
34462         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34463         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
34464 }
34465
34466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34467         LDKUnsignedChannelAnnouncement this_ptr_conv;
34468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34469         this_ptr_conv.is_owned = false;
34470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34471         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34472         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
34473         return ret_arr;
34474 }
34475
34476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34477         LDKUnsignedChannelAnnouncement 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         LDKPublicKey val_ref;
34482         CHECK((*env)->GetArrayLength(env, val) == 33);
34483         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34484         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
34485 }
34486
34487 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34488         LDKUnsignedChannelAnnouncement this_ptr_conv;
34489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34490         this_ptr_conv.is_owned = false;
34491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34492         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34493         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
34494         return ret_arr;
34495 }
34496
34497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34498         LDKUnsignedChannelAnnouncement 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         LDKPublicKey val_ref;
34503         CHECK((*env)->GetArrayLength(env, val) == 33);
34504         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34505         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
34506 }
34507
34508 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
34509         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
34510 int64_t ret_ref = 0;
34511 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34512 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34513 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34514 ret_ref = (uintptr_t)ret_var.inner;
34515 if (ret_var.is_owned) {
34516         ret_ref |= 1;
34517 }
34518         return ret_ref;
34519 }
34520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34521         LDKUnsignedChannelAnnouncement arg_conv;
34522         arg_conv.inner = (void*)(arg & (~1));
34523         arg_conv.is_owned = false;
34524         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34525         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
34526         return ret_conv;
34527 }
34528
34529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34530         LDKUnsignedChannelAnnouncement orig_conv;
34531         orig_conv.inner = (void*)(orig & (~1));
34532         orig_conv.is_owned = false;
34533         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34534         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
34535         int64_t ret_ref = 0;
34536         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34537         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34539         ret_ref = (uintptr_t)ret_var.inner;
34540         if (ret_var.is_owned) {
34541                 ret_ref |= 1;
34542         }
34543         return ret_ref;
34544 }
34545
34546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34547         LDKChannelAnnouncement this_obj_conv;
34548         this_obj_conv.inner = (void*)(this_obj & (~1));
34549         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34551         ChannelAnnouncement_free(this_obj_conv);
34552 }
34553
34554 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34555         LDKChannelAnnouncement this_ptr_conv;
34556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34557         this_ptr_conv.is_owned = false;
34558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34559         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34560         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
34561         return ret_arr;
34562 }
34563
34564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34565         LDKChannelAnnouncement this_ptr_conv;
34566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34567         this_ptr_conv.is_owned = false;
34568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34569         LDKSignature val_ref;
34570         CHECK((*env)->GetArrayLength(env, val) == 64);
34571         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34572         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
34573 }
34574
34575 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34576         LDKChannelAnnouncement this_ptr_conv;
34577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34578         this_ptr_conv.is_owned = false;
34579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34580         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34581         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
34582         return ret_arr;
34583 }
34584
34585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34586         LDKChannelAnnouncement this_ptr_conv;
34587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34588         this_ptr_conv.is_owned = false;
34589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34590         LDKSignature val_ref;
34591         CHECK((*env)->GetArrayLength(env, val) == 64);
34592         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34593         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
34594 }
34595
34596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34597         LDKChannelAnnouncement this_ptr_conv;
34598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34599         this_ptr_conv.is_owned = false;
34600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34601         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34602         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
34603         return ret_arr;
34604 }
34605
34606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34607         LDKChannelAnnouncement this_ptr_conv;
34608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34609         this_ptr_conv.is_owned = false;
34610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34611         LDKSignature val_ref;
34612         CHECK((*env)->GetArrayLength(env, val) == 64);
34613         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34614         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
34615 }
34616
34617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34618         LDKChannelAnnouncement this_ptr_conv;
34619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34620         this_ptr_conv.is_owned = false;
34621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34622         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34623         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
34624         return ret_arr;
34625 }
34626
34627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34628         LDKChannelAnnouncement this_ptr_conv;
34629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34630         this_ptr_conv.is_owned = false;
34631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34632         LDKSignature val_ref;
34633         CHECK((*env)->GetArrayLength(env, val) == 64);
34634         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34635         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
34636 }
34637
34638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
34639         LDKChannelAnnouncement this_ptr_conv;
34640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34641         this_ptr_conv.is_owned = false;
34642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34643         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
34644         int64_t ret_ref = 0;
34645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34648         ret_ref = (uintptr_t)ret_var.inner;
34649         if (ret_var.is_owned) {
34650                 ret_ref |= 1;
34651         }
34652         return ret_ref;
34653 }
34654
34655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34656         LDKChannelAnnouncement this_ptr_conv;
34657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34658         this_ptr_conv.is_owned = false;
34659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34660         LDKUnsignedChannelAnnouncement val_conv;
34661         val_conv.inner = (void*)(val & (~1));
34662         val_conv.is_owned = (val & 1) || (val == 0);
34663         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34664         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
34665         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
34666 }
34667
34668 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) {
34669         LDKSignature node_signature_1_arg_ref;
34670         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
34671         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
34672         LDKSignature node_signature_2_arg_ref;
34673         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
34674         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
34675         LDKSignature bitcoin_signature_1_arg_ref;
34676         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
34677         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
34678         LDKSignature bitcoin_signature_2_arg_ref;
34679         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
34680         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
34681         LDKUnsignedChannelAnnouncement contents_arg_conv;
34682         contents_arg_conv.inner = (void*)(contents_arg & (~1));
34683         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
34684         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
34685         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
34686         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);
34687         int64_t ret_ref = 0;
34688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34691         ret_ref = (uintptr_t)ret_var.inner;
34692         if (ret_var.is_owned) {
34693                 ret_ref |= 1;
34694         }
34695         return ret_ref;
34696 }
34697
34698 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
34699         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
34700 int64_t ret_ref = 0;
34701 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34702 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34703 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34704 ret_ref = (uintptr_t)ret_var.inner;
34705 if (ret_var.is_owned) {
34706         ret_ref |= 1;
34707 }
34708         return ret_ref;
34709 }
34710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34711         LDKChannelAnnouncement arg_conv;
34712         arg_conv.inner = (void*)(arg & (~1));
34713         arg_conv.is_owned = false;
34714         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34715         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
34716         return ret_conv;
34717 }
34718
34719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34720         LDKChannelAnnouncement orig_conv;
34721         orig_conv.inner = (void*)(orig & (~1));
34722         orig_conv.is_owned = false;
34723         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34724         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
34725         int64_t ret_ref = 0;
34726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34729         ret_ref = (uintptr_t)ret_var.inner;
34730         if (ret_var.is_owned) {
34731                 ret_ref |= 1;
34732         }
34733         return ret_ref;
34734 }
34735
34736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34737         LDKUnsignedChannelUpdate this_obj_conv;
34738         this_obj_conv.inner = (void*)(this_obj & (~1));
34739         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34741         UnsignedChannelUpdate_free(this_obj_conv);
34742 }
34743
34744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34745         LDKUnsignedChannelUpdate this_ptr_conv;
34746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34747         this_ptr_conv.is_owned = false;
34748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34749         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34750         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
34751         return ret_arr;
34752 }
34753
34754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34755         LDKUnsignedChannelUpdate this_ptr_conv;
34756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34757         this_ptr_conv.is_owned = false;
34758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34759         LDKThirtyTwoBytes val_ref;
34760         CHECK((*env)->GetArrayLength(env, val) == 32);
34761         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34762         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
34763 }
34764
34765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34766         LDKUnsignedChannelUpdate this_ptr_conv;
34767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34768         this_ptr_conv.is_owned = false;
34769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34770         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
34771         return ret_conv;
34772 }
34773
34774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34775         LDKUnsignedChannelUpdate this_ptr_conv;
34776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34777         this_ptr_conv.is_owned = false;
34778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34779         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
34780 }
34781
34782 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
34783         LDKUnsignedChannelUpdate this_ptr_conv;
34784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34785         this_ptr_conv.is_owned = false;
34786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34787         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
34788         return ret_conv;
34789 }
34790
34791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34792         LDKUnsignedChannelUpdate this_ptr_conv;
34793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34794         this_ptr_conv.is_owned = false;
34795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34796         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
34797 }
34798
34799 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
34800         LDKUnsignedChannelUpdate this_ptr_conv;
34801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34802         this_ptr_conv.is_owned = false;
34803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34804         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
34805         return ret_conv;
34806 }
34807
34808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
34809         LDKUnsignedChannelUpdate this_ptr_conv;
34810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34811         this_ptr_conv.is_owned = false;
34812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34813         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
34814 }
34815
34816 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
34817         LDKUnsignedChannelUpdate this_ptr_conv;
34818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34819         this_ptr_conv.is_owned = false;
34820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34821         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
34822         return ret_conv;
34823 }
34824
34825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34826         LDKUnsignedChannelUpdate this_ptr_conv;
34827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34828         this_ptr_conv.is_owned = false;
34829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34830         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
34831 }
34832
34833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34834         LDKUnsignedChannelUpdate this_ptr_conv;
34835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34836         this_ptr_conv.is_owned = false;
34837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34838         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
34839         return ret_conv;
34840 }
34841
34842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34843         LDKUnsignedChannelUpdate this_ptr_conv;
34844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34845         this_ptr_conv.is_owned = false;
34846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34847         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
34848 }
34849
34850 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34851         LDKUnsignedChannelUpdate this_ptr_conv;
34852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34853         this_ptr_conv.is_owned = false;
34854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34855         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
34856         return ret_conv;
34857 }
34858
34859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34860         LDKUnsignedChannelUpdate this_ptr_conv;
34861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34862         this_ptr_conv.is_owned = false;
34863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34864         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
34865 }
34866
34867 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
34868         LDKUnsignedChannelUpdate this_ptr_conv;
34869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34870         this_ptr_conv.is_owned = false;
34871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34872         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
34873         return ret_conv;
34874 }
34875
34876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34877         LDKUnsignedChannelUpdate this_ptr_conv;
34878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34879         this_ptr_conv.is_owned = false;
34880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34881         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
34882 }
34883
34884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34885         LDKUnsignedChannelUpdate this_ptr_conv;
34886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34887         this_ptr_conv.is_owned = false;
34888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34889         LDKCVec_u8Z val_ref;
34890         val_ref.datalen = (*env)->GetArrayLength(env, val);
34891         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
34892         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
34893         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
34894 }
34895
34896 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
34897         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
34898 int64_t ret_ref = 0;
34899 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34900 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34901 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34902 ret_ref = (uintptr_t)ret_var.inner;
34903 if (ret_var.is_owned) {
34904         ret_ref |= 1;
34905 }
34906         return ret_ref;
34907 }
34908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34909         LDKUnsignedChannelUpdate arg_conv;
34910         arg_conv.inner = (void*)(arg & (~1));
34911         arg_conv.is_owned = false;
34912         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34913         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
34914         return ret_conv;
34915 }
34916
34917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34918         LDKUnsignedChannelUpdate orig_conv;
34919         orig_conv.inner = (void*)(orig & (~1));
34920         orig_conv.is_owned = false;
34921         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34922         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
34923         int64_t ret_ref = 0;
34924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34927         ret_ref = (uintptr_t)ret_var.inner;
34928         if (ret_var.is_owned) {
34929                 ret_ref |= 1;
34930         }
34931         return ret_ref;
34932 }
34933
34934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34935         LDKChannelUpdate this_obj_conv;
34936         this_obj_conv.inner = (void*)(this_obj & (~1));
34937         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34939         ChannelUpdate_free(this_obj_conv);
34940 }
34941
34942 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34943         LDKChannelUpdate this_ptr_conv;
34944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34945         this_ptr_conv.is_owned = false;
34946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34947         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34948         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
34949         return ret_arr;
34950 }
34951
34952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34953         LDKChannelUpdate this_ptr_conv;
34954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34955         this_ptr_conv.is_owned = false;
34956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34957         LDKSignature val_ref;
34958         CHECK((*env)->GetArrayLength(env, val) == 64);
34959         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34960         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
34961 }
34962
34963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
34964         LDKChannelUpdate 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         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
34969         int64_t ret_ref = 0;
34970         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34971         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34973         ret_ref = (uintptr_t)ret_var.inner;
34974         if (ret_var.is_owned) {
34975                 ret_ref |= 1;
34976         }
34977         return ret_ref;
34978 }
34979
34980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34981         LDKChannelUpdate 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         LDKUnsignedChannelUpdate val_conv;
34986         val_conv.inner = (void*)(val & (~1));
34987         val_conv.is_owned = (val & 1) || (val == 0);
34988         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34989         val_conv = UnsignedChannelUpdate_clone(&val_conv);
34990         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
34991 }
34992
34993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
34994         LDKSignature signature_arg_ref;
34995         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34996         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34997         LDKUnsignedChannelUpdate contents_arg_conv;
34998         contents_arg_conv.inner = (void*)(contents_arg & (~1));
34999         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
35000         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35001         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
35002         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
35003         int64_t ret_ref = 0;
35004         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35005         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35007         ret_ref = (uintptr_t)ret_var.inner;
35008         if (ret_var.is_owned) {
35009                 ret_ref |= 1;
35010         }
35011         return ret_ref;
35012 }
35013
35014 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
35015         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
35016 int64_t ret_ref = 0;
35017 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35018 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35019 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35020 ret_ref = (uintptr_t)ret_var.inner;
35021 if (ret_var.is_owned) {
35022         ret_ref |= 1;
35023 }
35024         return ret_ref;
35025 }
35026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35027         LDKChannelUpdate arg_conv;
35028         arg_conv.inner = (void*)(arg & (~1));
35029         arg_conv.is_owned = false;
35030         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35031         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
35032         return ret_conv;
35033 }
35034
35035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35036         LDKChannelUpdate orig_conv;
35037         orig_conv.inner = (void*)(orig & (~1));
35038         orig_conv.is_owned = false;
35039         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35040         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
35041         int64_t ret_ref = 0;
35042         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35043         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35045         ret_ref = (uintptr_t)ret_var.inner;
35046         if (ret_var.is_owned) {
35047                 ret_ref |= 1;
35048         }
35049         return ret_ref;
35050 }
35051
35052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35053         LDKQueryChannelRange this_obj_conv;
35054         this_obj_conv.inner = (void*)(this_obj & (~1));
35055         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35057         QueryChannelRange_free(this_obj_conv);
35058 }
35059
35060 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35061         LDKQueryChannelRange this_ptr_conv;
35062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35063         this_ptr_conv.is_owned = false;
35064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35065         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35066         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
35067         return ret_arr;
35068 }
35069
35070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35071         LDKQueryChannelRange 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         LDKThirtyTwoBytes val_ref;
35076         CHECK((*env)->GetArrayLength(env, val) == 32);
35077         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35078         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
35079 }
35080
35081 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
35082         LDKQueryChannelRange this_ptr_conv;
35083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35084         this_ptr_conv.is_owned = false;
35085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35086         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
35087         return ret_conv;
35088 }
35089
35090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35091         LDKQueryChannelRange this_ptr_conv;
35092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35093         this_ptr_conv.is_owned = false;
35094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35095         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
35096 }
35097
35098 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
35099         LDKQueryChannelRange this_ptr_conv;
35100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35101         this_ptr_conv.is_owned = false;
35102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35103         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
35104         return ret_conv;
35105 }
35106
35107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35108         LDKQueryChannelRange this_ptr_conv;
35109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35110         this_ptr_conv.is_owned = false;
35111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35112         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
35113 }
35114
35115 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) {
35116         LDKThirtyTwoBytes chain_hash_arg_ref;
35117         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35118         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35119         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
35120         int64_t ret_ref = 0;
35121         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35122         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35124         ret_ref = (uintptr_t)ret_var.inner;
35125         if (ret_var.is_owned) {
35126                 ret_ref |= 1;
35127         }
35128         return ret_ref;
35129 }
35130
35131 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
35132         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
35133 int64_t ret_ref = 0;
35134 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35135 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35136 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35137 ret_ref = (uintptr_t)ret_var.inner;
35138 if (ret_var.is_owned) {
35139         ret_ref |= 1;
35140 }
35141         return ret_ref;
35142 }
35143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35144         LDKQueryChannelRange arg_conv;
35145         arg_conv.inner = (void*)(arg & (~1));
35146         arg_conv.is_owned = false;
35147         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35148         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
35149         return ret_conv;
35150 }
35151
35152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35153         LDKQueryChannelRange orig_conv;
35154         orig_conv.inner = (void*)(orig & (~1));
35155         orig_conv.is_owned = false;
35156         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35157         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
35158         int64_t ret_ref = 0;
35159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35162         ret_ref = (uintptr_t)ret_var.inner;
35163         if (ret_var.is_owned) {
35164                 ret_ref |= 1;
35165         }
35166         return ret_ref;
35167 }
35168
35169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35170         LDKReplyChannelRange this_obj_conv;
35171         this_obj_conv.inner = (void*)(this_obj & (~1));
35172         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35174         ReplyChannelRange_free(this_obj_conv);
35175 }
35176
35177 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35178         LDKReplyChannelRange this_ptr_conv;
35179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35180         this_ptr_conv.is_owned = false;
35181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35182         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35183         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
35184         return ret_arr;
35185 }
35186
35187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35188         LDKReplyChannelRange this_ptr_conv;
35189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35190         this_ptr_conv.is_owned = false;
35191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35192         LDKThirtyTwoBytes val_ref;
35193         CHECK((*env)->GetArrayLength(env, val) == 32);
35194         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35195         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
35196 }
35197
35198 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
35199         LDKReplyChannelRange this_ptr_conv;
35200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35201         this_ptr_conv.is_owned = false;
35202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35203         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
35204         return ret_conv;
35205 }
35206
35207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35208         LDKReplyChannelRange this_ptr_conv;
35209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35210         this_ptr_conv.is_owned = false;
35211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35212         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
35213 }
35214
35215 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
35216         LDKReplyChannelRange this_ptr_conv;
35217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35218         this_ptr_conv.is_owned = false;
35219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35220         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
35221         return ret_conv;
35222 }
35223
35224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35225         LDKReplyChannelRange this_ptr_conv;
35226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35227         this_ptr_conv.is_owned = false;
35228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35229         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
35230 }
35231
35232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
35233         LDKReplyChannelRange this_ptr_conv;
35234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35235         this_ptr_conv.is_owned = false;
35236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35237         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
35238         return ret_conv;
35239 }
35240
35241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
35242         LDKReplyChannelRange this_ptr_conv;
35243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35244         this_ptr_conv.is_owned = false;
35245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35246         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
35247 }
35248
35249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35250         LDKReplyChannelRange this_ptr_conv;
35251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35252         this_ptr_conv.is_owned = false;
35253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35254         LDKCVec_u64Z val_constr;
35255         val_constr.datalen = (*env)->GetArrayLength(env, val);
35256         if (val_constr.datalen > 0)
35257                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35258         else
35259                 val_constr.data = NULL;
35260         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35261         for (size_t g = 0; g < val_constr.datalen; g++) {
35262                 int64_t val_conv_6 = val_vals[g];
35263                 val_constr.data[g] = val_conv_6;
35264         }
35265         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35266         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
35267 }
35268
35269 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) {
35270         LDKThirtyTwoBytes chain_hash_arg_ref;
35271         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35272         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35273         LDKCVec_u64Z short_channel_ids_arg_constr;
35274         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
35275         if (short_channel_ids_arg_constr.datalen > 0)
35276                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35277         else
35278                 short_channel_ids_arg_constr.data = NULL;
35279         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
35280         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
35281                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
35282                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
35283         }
35284         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
35285         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
35286         int64_t ret_ref = 0;
35287         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35288         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35290         ret_ref = (uintptr_t)ret_var.inner;
35291         if (ret_var.is_owned) {
35292                 ret_ref |= 1;
35293         }
35294         return ret_ref;
35295 }
35296
35297 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
35298         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
35299 int64_t ret_ref = 0;
35300 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35301 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35302 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35303 ret_ref = (uintptr_t)ret_var.inner;
35304 if (ret_var.is_owned) {
35305         ret_ref |= 1;
35306 }
35307         return ret_ref;
35308 }
35309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35310         LDKReplyChannelRange arg_conv;
35311         arg_conv.inner = (void*)(arg & (~1));
35312         arg_conv.is_owned = false;
35313         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35314         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
35315         return ret_conv;
35316 }
35317
35318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35319         LDKReplyChannelRange orig_conv;
35320         orig_conv.inner = (void*)(orig & (~1));
35321         orig_conv.is_owned = false;
35322         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35323         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
35324         int64_t ret_ref = 0;
35325         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35326         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35328         ret_ref = (uintptr_t)ret_var.inner;
35329         if (ret_var.is_owned) {
35330                 ret_ref |= 1;
35331         }
35332         return ret_ref;
35333 }
35334
35335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35336         LDKQueryShortChannelIds this_obj_conv;
35337         this_obj_conv.inner = (void*)(this_obj & (~1));
35338         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35340         QueryShortChannelIds_free(this_obj_conv);
35341 }
35342
35343 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35344         LDKQueryShortChannelIds this_ptr_conv;
35345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35346         this_ptr_conv.is_owned = false;
35347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35348         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35349         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
35350         return ret_arr;
35351 }
35352
35353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35354         LDKQueryShortChannelIds this_ptr_conv;
35355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35356         this_ptr_conv.is_owned = false;
35357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35358         LDKThirtyTwoBytes val_ref;
35359         CHECK((*env)->GetArrayLength(env, val) == 32);
35360         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35361         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
35362 }
35363
35364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35365         LDKQueryShortChannelIds this_ptr_conv;
35366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35367         this_ptr_conv.is_owned = false;
35368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35369         LDKCVec_u64Z val_constr;
35370         val_constr.datalen = (*env)->GetArrayLength(env, val);
35371         if (val_constr.datalen > 0)
35372                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35373         else
35374                 val_constr.data = NULL;
35375         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35376         for (size_t g = 0; g < val_constr.datalen; g++) {
35377                 int64_t val_conv_6 = val_vals[g];
35378                 val_constr.data[g] = val_conv_6;
35379         }
35380         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35381         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
35382 }
35383
35384 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) {
35385         LDKThirtyTwoBytes chain_hash_arg_ref;
35386         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35387         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35388         LDKCVec_u64Z short_channel_ids_arg_constr;
35389         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
35390         if (short_channel_ids_arg_constr.datalen > 0)
35391                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35392         else
35393                 short_channel_ids_arg_constr.data = NULL;
35394         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
35395         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
35396                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
35397                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
35398         }
35399         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
35400         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
35401         int64_t ret_ref = 0;
35402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35405         ret_ref = (uintptr_t)ret_var.inner;
35406         if (ret_var.is_owned) {
35407                 ret_ref |= 1;
35408         }
35409         return ret_ref;
35410 }
35411
35412 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
35413         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
35414 int64_t ret_ref = 0;
35415 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35416 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35417 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35418 ret_ref = (uintptr_t)ret_var.inner;
35419 if (ret_var.is_owned) {
35420         ret_ref |= 1;
35421 }
35422         return ret_ref;
35423 }
35424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35425         LDKQueryShortChannelIds arg_conv;
35426         arg_conv.inner = (void*)(arg & (~1));
35427         arg_conv.is_owned = false;
35428         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35429         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
35430         return ret_conv;
35431 }
35432
35433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35434         LDKQueryShortChannelIds orig_conv;
35435         orig_conv.inner = (void*)(orig & (~1));
35436         orig_conv.is_owned = false;
35437         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35438         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
35439         int64_t ret_ref = 0;
35440         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35441         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35443         ret_ref = (uintptr_t)ret_var.inner;
35444         if (ret_var.is_owned) {
35445                 ret_ref |= 1;
35446         }
35447         return ret_ref;
35448 }
35449
35450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35451         LDKReplyShortChannelIdsEnd this_obj_conv;
35452         this_obj_conv.inner = (void*)(this_obj & (~1));
35453         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35455         ReplyShortChannelIdsEnd_free(this_obj_conv);
35456 }
35457
35458 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35459         LDKReplyShortChannelIdsEnd this_ptr_conv;
35460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35461         this_ptr_conv.is_owned = false;
35462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35463         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35464         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
35465         return ret_arr;
35466 }
35467
35468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35469         LDKReplyShortChannelIdsEnd this_ptr_conv;
35470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35471         this_ptr_conv.is_owned = false;
35472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35473         LDKThirtyTwoBytes val_ref;
35474         CHECK((*env)->GetArrayLength(env, val) == 32);
35475         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35476         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
35477 }
35478
35479 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
35480         LDKReplyShortChannelIdsEnd this_ptr_conv;
35481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35482         this_ptr_conv.is_owned = false;
35483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35484         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
35485         return ret_conv;
35486 }
35487
35488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
35489         LDKReplyShortChannelIdsEnd this_ptr_conv;
35490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35491         this_ptr_conv.is_owned = false;
35492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35493         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
35494 }
35495
35496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
35497         LDKThirtyTwoBytes chain_hash_arg_ref;
35498         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35499         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35500         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
35501         int64_t ret_ref = 0;
35502         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35503         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35505         ret_ref = (uintptr_t)ret_var.inner;
35506         if (ret_var.is_owned) {
35507                 ret_ref |= 1;
35508         }
35509         return ret_ref;
35510 }
35511
35512 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
35513         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
35514 int64_t ret_ref = 0;
35515 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35516 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35517 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35518 ret_ref = (uintptr_t)ret_var.inner;
35519 if (ret_var.is_owned) {
35520         ret_ref |= 1;
35521 }
35522         return ret_ref;
35523 }
35524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35525         LDKReplyShortChannelIdsEnd arg_conv;
35526         arg_conv.inner = (void*)(arg & (~1));
35527         arg_conv.is_owned = false;
35528         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35529         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
35530         return ret_conv;
35531 }
35532
35533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35534         LDKReplyShortChannelIdsEnd orig_conv;
35535         orig_conv.inner = (void*)(orig & (~1));
35536         orig_conv.is_owned = false;
35537         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35538         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
35539         int64_t ret_ref = 0;
35540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35543         ret_ref = (uintptr_t)ret_var.inner;
35544         if (ret_var.is_owned) {
35545                 ret_ref |= 1;
35546         }
35547         return ret_ref;
35548 }
35549
35550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35551         LDKGossipTimestampFilter this_obj_conv;
35552         this_obj_conv.inner = (void*)(this_obj & (~1));
35553         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35555         GossipTimestampFilter_free(this_obj_conv);
35556 }
35557
35558 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35559         LDKGossipTimestampFilter this_ptr_conv;
35560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35561         this_ptr_conv.is_owned = false;
35562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35563         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35564         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
35565         return ret_arr;
35566 }
35567
35568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35569         LDKGossipTimestampFilter this_ptr_conv;
35570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35571         this_ptr_conv.is_owned = false;
35572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35573         LDKThirtyTwoBytes val_ref;
35574         CHECK((*env)->GetArrayLength(env, val) == 32);
35575         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35576         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
35577 }
35578
35579 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35580         LDKGossipTimestampFilter this_ptr_conv;
35581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35582         this_ptr_conv.is_owned = false;
35583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35584         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
35585         return ret_conv;
35586 }
35587
35588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35589         LDKGossipTimestampFilter 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         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
35594 }
35595
35596 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
35597         LDKGossipTimestampFilter this_ptr_conv;
35598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35599         this_ptr_conv.is_owned = false;
35600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35601         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
35602         return ret_conv;
35603 }
35604
35605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35606         LDKGossipTimestampFilter this_ptr_conv;
35607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35608         this_ptr_conv.is_owned = false;
35609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35610         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
35611 }
35612
35613 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) {
35614         LDKThirtyTwoBytes chain_hash_arg_ref;
35615         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35616         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35617         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
35618         int64_t ret_ref = 0;
35619         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35620         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35622         ret_ref = (uintptr_t)ret_var.inner;
35623         if (ret_var.is_owned) {
35624                 ret_ref |= 1;
35625         }
35626         return ret_ref;
35627 }
35628
35629 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
35630         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
35631 int64_t ret_ref = 0;
35632 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35633 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35634 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35635 ret_ref = (uintptr_t)ret_var.inner;
35636 if (ret_var.is_owned) {
35637         ret_ref |= 1;
35638 }
35639         return ret_ref;
35640 }
35641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35642         LDKGossipTimestampFilter arg_conv;
35643         arg_conv.inner = (void*)(arg & (~1));
35644         arg_conv.is_owned = false;
35645         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35646         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
35647         return ret_conv;
35648 }
35649
35650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35651         LDKGossipTimestampFilter orig_conv;
35652         orig_conv.inner = (void*)(orig & (~1));
35653         orig_conv.is_owned = false;
35654         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35655         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
35656         int64_t ret_ref = 0;
35657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35660         ret_ref = (uintptr_t)ret_var.inner;
35661         if (ret_var.is_owned) {
35662                 ret_ref |= 1;
35663         }
35664         return ret_ref;
35665 }
35666
35667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35668         if ((this_ptr & 1) != 0) return;
35669         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35670         CHECK_ACCESS(this_ptr_ptr);
35671         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
35672         FREE((void*)this_ptr);
35673         ErrorAction_free(this_ptr_conv);
35674 }
35675
35676 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
35677         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35678         *ret_copy = ErrorAction_clone(arg);
35679 int64_t ret_ref = (uintptr_t)ret_copy;
35680         return ret_ref;
35681 }
35682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35683         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
35684         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
35685         return ret_conv;
35686 }
35687
35688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35689         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
35690         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35691         *ret_copy = ErrorAction_clone(orig_conv);
35692         int64_t ret_ref = (uintptr_t)ret_copy;
35693         return ret_ref;
35694 }
35695
35696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
35697         LDKErrorMessage msg_conv;
35698         msg_conv.inner = (void*)(msg & (~1));
35699         msg_conv.is_owned = (msg & 1) || (msg == 0);
35700         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
35701         msg_conv = ErrorMessage_clone(&msg_conv);
35702         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35703         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
35704         int64_t ret_ref = (uintptr_t)ret_copy;
35705         return ret_ref;
35706 }
35707
35708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
35709         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35710         *ret_copy = ErrorAction_ignore_error();
35711         int64_t ret_ref = (uintptr_t)ret_copy;
35712         return ret_ref;
35713 }
35714
35715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
35716         LDKLevel a_conv = LDKLevel_from_java(env, a);
35717         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35718         *ret_copy = ErrorAction_ignore_and_log(a_conv);
35719         int64_t ret_ref = (uintptr_t)ret_copy;
35720         return ret_ref;
35721 }
35722
35723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
35724         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35725         *ret_copy = ErrorAction_ignore_duplicate_gossip();
35726         int64_t ret_ref = (uintptr_t)ret_copy;
35727         return ret_ref;
35728 }
35729
35730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
35731         LDKErrorMessage msg_conv;
35732         msg_conv.inner = (void*)(msg & (~1));
35733         msg_conv.is_owned = (msg & 1) || (msg == 0);
35734         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
35735         msg_conv = ErrorMessage_clone(&msg_conv);
35736         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35737         *ret_copy = ErrorAction_send_error_message(msg_conv);
35738         int64_t ret_ref = (uintptr_t)ret_copy;
35739         return ret_ref;
35740 }
35741
35742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
35743         LDKWarningMessage msg_conv;
35744         msg_conv.inner = (void*)(msg & (~1));
35745         msg_conv.is_owned = (msg & 1) || (msg == 0);
35746         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
35747         msg_conv = WarningMessage_clone(&msg_conv);
35748         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
35749         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35750         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
35751         int64_t ret_ref = (uintptr_t)ret_copy;
35752         return ret_ref;
35753 }
35754
35755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35756         LDKLightningError this_obj_conv;
35757         this_obj_conv.inner = (void*)(this_obj & (~1));
35758         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35760         LightningError_free(this_obj_conv);
35761 }
35762
35763 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
35764         LDKLightningError this_ptr_conv;
35765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35766         this_ptr_conv.is_owned = false;
35767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35768         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
35769         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
35770         Str_free(ret_str);
35771         return ret_conv;
35772 }
35773
35774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
35775         LDKLightningError this_ptr_conv;
35776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35777         this_ptr_conv.is_owned = false;
35778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35779         LDKStr val_conv = java_to_owned_str(env, val);
35780         LightningError_set_err(&this_ptr_conv, val_conv);
35781 }
35782
35783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
35784         LDKLightningError this_ptr_conv;
35785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35786         this_ptr_conv.is_owned = false;
35787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35788         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
35789         *ret_copy = LightningError_get_action(&this_ptr_conv);
35790         int64_t ret_ref = (uintptr_t)ret_copy;
35791         return ret_ref;
35792 }
35793
35794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35795         LDKLightningError this_ptr_conv;
35796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35797         this_ptr_conv.is_owned = false;
35798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35799         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35800         CHECK_ACCESS(val_ptr);
35801         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
35802         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
35803         LightningError_set_action(&this_ptr_conv, val_conv);
35804 }
35805
35806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
35807         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
35808         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
35809         CHECK_ACCESS(action_arg_ptr);
35810         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
35811         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
35812         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
35813         int64_t ret_ref = 0;
35814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35817         ret_ref = (uintptr_t)ret_var.inner;
35818         if (ret_var.is_owned) {
35819                 ret_ref |= 1;
35820         }
35821         return ret_ref;
35822 }
35823
35824 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
35825         LDKLightningError ret_var = LightningError_clone(arg);
35826 int64_t ret_ref = 0;
35827 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35828 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35829 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35830 ret_ref = (uintptr_t)ret_var.inner;
35831 if (ret_var.is_owned) {
35832         ret_ref |= 1;
35833 }
35834         return ret_ref;
35835 }
35836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35837         LDKLightningError arg_conv;
35838         arg_conv.inner = (void*)(arg & (~1));
35839         arg_conv.is_owned = false;
35840         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35841         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
35842         return ret_conv;
35843 }
35844
35845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35846         LDKLightningError orig_conv;
35847         orig_conv.inner = (void*)(orig & (~1));
35848         orig_conv.is_owned = false;
35849         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35850         LDKLightningError ret_var = LightningError_clone(&orig_conv);
35851         int64_t ret_ref = 0;
35852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35855         ret_ref = (uintptr_t)ret_var.inner;
35856         if (ret_var.is_owned) {
35857                 ret_ref |= 1;
35858         }
35859         return ret_ref;
35860 }
35861
35862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35863         LDKCommitmentUpdate this_obj_conv;
35864         this_obj_conv.inner = (void*)(this_obj & (~1));
35865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35867         CommitmentUpdate_free(this_obj_conv);
35868 }
35869
35870 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35871         LDKCommitmentUpdate this_ptr_conv;
35872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35873         this_ptr_conv.is_owned = false;
35874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35875         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
35876         int64_tArray ret_arr = NULL;
35877         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35878         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35879         for (size_t p = 0; p < ret_var.datalen; p++) {
35880                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
35881                 int64_t ret_conv_15_ref = 0;
35882                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35883                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35884                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
35885                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
35886                 if (ret_conv_15_var.is_owned) {
35887                         ret_conv_15_ref |= 1;
35888                 }
35889                 ret_arr_ptr[p] = ret_conv_15_ref;
35890         }
35891         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35892         FREE(ret_var.data);
35893         return ret_arr;
35894 }
35895
35896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35897         LDKCommitmentUpdate this_ptr_conv;
35898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35899         this_ptr_conv.is_owned = false;
35900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35901         LDKCVec_UpdateAddHTLCZ val_constr;
35902         val_constr.datalen = (*env)->GetArrayLength(env, val);
35903         if (val_constr.datalen > 0)
35904                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
35905         else
35906                 val_constr.data = NULL;
35907         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35908         for (size_t p = 0; p < val_constr.datalen; p++) {
35909                 int64_t val_conv_15 = val_vals[p];
35910                 LDKUpdateAddHTLC val_conv_15_conv;
35911                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
35912                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
35913                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
35914                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
35915                 val_constr.data[p] = val_conv_15_conv;
35916         }
35917         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35918         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
35919 }
35920
35921 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35922         LDKCommitmentUpdate this_ptr_conv;
35923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35924         this_ptr_conv.is_owned = false;
35925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35926         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
35927         int64_tArray ret_arr = NULL;
35928         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35929         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35930         for (size_t t = 0; t < ret_var.datalen; t++) {
35931                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
35932                 int64_t ret_conv_19_ref = 0;
35933                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35934                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35935                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
35936                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
35937                 if (ret_conv_19_var.is_owned) {
35938                         ret_conv_19_ref |= 1;
35939                 }
35940                 ret_arr_ptr[t] = ret_conv_19_ref;
35941         }
35942         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35943         FREE(ret_var.data);
35944         return ret_arr;
35945 }
35946
35947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35948         LDKCommitmentUpdate this_ptr_conv;
35949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35950         this_ptr_conv.is_owned = false;
35951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35952         LDKCVec_UpdateFulfillHTLCZ val_constr;
35953         val_constr.datalen = (*env)->GetArrayLength(env, val);
35954         if (val_constr.datalen > 0)
35955                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
35956         else
35957                 val_constr.data = NULL;
35958         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35959         for (size_t t = 0; t < val_constr.datalen; t++) {
35960                 int64_t val_conv_19 = val_vals[t];
35961                 LDKUpdateFulfillHTLC val_conv_19_conv;
35962                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
35963                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
35964                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
35965                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
35966                 val_constr.data[t] = val_conv_19_conv;
35967         }
35968         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35969         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
35970 }
35971
35972 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35973         LDKCommitmentUpdate this_ptr_conv;
35974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35975         this_ptr_conv.is_owned = false;
35976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35977         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
35978         int64_tArray ret_arr = NULL;
35979         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35980         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35981         for (size_t q = 0; q < ret_var.datalen; q++) {
35982                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
35983                 int64_t ret_conv_16_ref = 0;
35984                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35985                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35986                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
35987                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
35988                 if (ret_conv_16_var.is_owned) {
35989                         ret_conv_16_ref |= 1;
35990                 }
35991                 ret_arr_ptr[q] = ret_conv_16_ref;
35992         }
35993         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35994         FREE(ret_var.data);
35995         return ret_arr;
35996 }
35997
35998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35999         LDKCommitmentUpdate this_ptr_conv;
36000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36001         this_ptr_conv.is_owned = false;
36002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36003         LDKCVec_UpdateFailHTLCZ val_constr;
36004         val_constr.datalen = (*env)->GetArrayLength(env, val);
36005         if (val_constr.datalen > 0)
36006                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
36007         else
36008                 val_constr.data = NULL;
36009         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36010         for (size_t q = 0; q < val_constr.datalen; q++) {
36011                 int64_t val_conv_16 = val_vals[q];
36012                 LDKUpdateFailHTLC val_conv_16_conv;
36013                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
36014                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
36015                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
36016                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
36017                 val_constr.data[q] = val_conv_16_conv;
36018         }
36019         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36020         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
36021 }
36022
36023 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
36024         LDKCommitmentUpdate this_ptr_conv;
36025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36026         this_ptr_conv.is_owned = false;
36027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36028         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
36029         int64_tArray ret_arr = NULL;
36030         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36031         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36032         for (size_t z = 0; z < ret_var.datalen; z++) {
36033                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
36034                 int64_t ret_conv_25_ref = 0;
36035                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36036                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36037                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
36038                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
36039                 if (ret_conv_25_var.is_owned) {
36040                         ret_conv_25_ref |= 1;
36041                 }
36042                 ret_arr_ptr[z] = ret_conv_25_ref;
36043         }
36044         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36045         FREE(ret_var.data);
36046         return ret_arr;
36047 }
36048
36049 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) {
36050         LDKCommitmentUpdate this_ptr_conv;
36051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36052         this_ptr_conv.is_owned = false;
36053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36054         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
36055         val_constr.datalen = (*env)->GetArrayLength(env, val);
36056         if (val_constr.datalen > 0)
36057                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
36058         else
36059                 val_constr.data = NULL;
36060         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36061         for (size_t z = 0; z < val_constr.datalen; z++) {
36062                 int64_t val_conv_25 = val_vals[z];
36063                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
36064                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
36065                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
36066                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
36067                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
36068                 val_constr.data[z] = val_conv_25_conv;
36069         }
36070         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36071         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
36072 }
36073
36074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
36075         LDKCommitmentUpdate this_ptr_conv;
36076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36077         this_ptr_conv.is_owned = false;
36078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36079         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
36080         int64_t ret_ref = 0;
36081         if ((uintptr_t)ret_var.inner > 4096) {
36082                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36083                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36085                 ret_ref = (uintptr_t)ret_var.inner;
36086                 if (ret_var.is_owned) {
36087                         ret_ref |= 1;
36088                 }
36089         }
36090         return ret_ref;
36091 }
36092
36093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36094         LDKCommitmentUpdate this_ptr_conv;
36095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36096         this_ptr_conv.is_owned = false;
36097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36098         LDKUpdateFee val_conv;
36099         val_conv.inner = (void*)(val & (~1));
36100         val_conv.is_owned = (val & 1) || (val == 0);
36101         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36102         val_conv = UpdateFee_clone(&val_conv);
36103         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
36104 }
36105
36106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
36107         LDKCommitmentUpdate this_ptr_conv;
36108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36109         this_ptr_conv.is_owned = false;
36110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36111         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
36112         int64_t ret_ref = 0;
36113         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36114         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36116         ret_ref = (uintptr_t)ret_var.inner;
36117         if (ret_var.is_owned) {
36118                 ret_ref |= 1;
36119         }
36120         return ret_ref;
36121 }
36122
36123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36124         LDKCommitmentUpdate this_ptr_conv;
36125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36126         this_ptr_conv.is_owned = false;
36127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36128         LDKCommitmentSigned val_conv;
36129         val_conv.inner = (void*)(val & (~1));
36130         val_conv.is_owned = (val & 1) || (val == 0);
36131         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36132         val_conv = CommitmentSigned_clone(&val_conv);
36133         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
36134 }
36135
36136 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) {
36137         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
36138         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
36139         if (update_add_htlcs_arg_constr.datalen > 0)
36140                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
36141         else
36142                 update_add_htlcs_arg_constr.data = NULL;
36143         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
36144         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
36145                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
36146                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
36147                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
36148                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
36149                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
36150                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
36151                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
36152         }
36153         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
36154         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
36155         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
36156         if (update_fulfill_htlcs_arg_constr.datalen > 0)
36157                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
36158         else
36159                 update_fulfill_htlcs_arg_constr.data = NULL;
36160         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
36161         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
36162                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
36163                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
36164                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
36165                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
36166                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
36167                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
36168                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
36169         }
36170         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
36171         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
36172         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
36173         if (update_fail_htlcs_arg_constr.datalen > 0)
36174                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
36175         else
36176                 update_fail_htlcs_arg_constr.data = NULL;
36177         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
36178         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
36179                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
36180                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
36181                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
36182                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
36183                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
36184                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
36185                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
36186         }
36187         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
36188         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
36189         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
36190         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
36191                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
36192         else
36193                 update_fail_malformed_htlcs_arg_constr.data = NULL;
36194         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
36195         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
36196                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
36197                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
36198                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
36199                 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);
36200                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
36201                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
36202                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
36203         }
36204         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
36205         LDKUpdateFee update_fee_arg_conv;
36206         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
36207         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
36208         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
36209         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
36210         LDKCommitmentSigned commitment_signed_arg_conv;
36211         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
36212         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
36213         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
36214         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
36215         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);
36216         int64_t ret_ref = 0;
36217         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36218         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36220         ret_ref = (uintptr_t)ret_var.inner;
36221         if (ret_var.is_owned) {
36222                 ret_ref |= 1;
36223         }
36224         return ret_ref;
36225 }
36226
36227 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
36228         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
36229 int64_t ret_ref = 0;
36230 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36231 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36232 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36233 ret_ref = (uintptr_t)ret_var.inner;
36234 if (ret_var.is_owned) {
36235         ret_ref |= 1;
36236 }
36237         return ret_ref;
36238 }
36239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36240         LDKCommitmentUpdate arg_conv;
36241         arg_conv.inner = (void*)(arg & (~1));
36242         arg_conv.is_owned = false;
36243         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36244         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
36245         return ret_conv;
36246 }
36247
36248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36249         LDKCommitmentUpdate orig_conv;
36250         orig_conv.inner = (void*)(orig & (~1));
36251         orig_conv.is_owned = false;
36252         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36253         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
36254         int64_t ret_ref = 0;
36255         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36256         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36258         ret_ref = (uintptr_t)ret_var.inner;
36259         if (ret_var.is_owned) {
36260                 ret_ref |= 1;
36261         }
36262         return ret_ref;
36263 }
36264
36265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36266         if ((this_ptr & 1) != 0) return;
36267         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36268         CHECK_ACCESS(this_ptr_ptr);
36269         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
36270         FREE((void*)this_ptr);
36271         ChannelMessageHandler_free(this_ptr_conv);
36272 }
36273
36274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36275         if ((this_ptr & 1) != 0) return;
36276         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36277         CHECK_ACCESS(this_ptr_ptr);
36278         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
36279         FREE((void*)this_ptr);
36280         RoutingMessageHandler_free(this_ptr_conv);
36281 }
36282
36283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
36284         LDKAcceptChannel obj_conv;
36285         obj_conv.inner = (void*)(obj & (~1));
36286         obj_conv.is_owned = false;
36287         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36288         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
36289         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36290         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36291         CVec_u8Z_free(ret_var);
36292         return ret_arr;
36293 }
36294
36295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36296         LDKu8slice ser_ref;
36297         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36298         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36299         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
36300         *ret_conv = AcceptChannel_read(ser_ref);
36301         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36302         return (int64_t)ret_conv;
36303 }
36304
36305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
36306         LDKAnnouncementSignatures obj_conv;
36307         obj_conv.inner = (void*)(obj & (~1));
36308         obj_conv.is_owned = false;
36309         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36310         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
36311         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36312         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36313         CVec_u8Z_free(ret_var);
36314         return ret_arr;
36315 }
36316
36317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36318         LDKu8slice ser_ref;
36319         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36320         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36321         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
36322         *ret_conv = AnnouncementSignatures_read(ser_ref);
36323         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36324         return (int64_t)ret_conv;
36325 }
36326
36327 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
36328         LDKChannelReestablish obj_conv;
36329         obj_conv.inner = (void*)(obj & (~1));
36330         obj_conv.is_owned = false;
36331         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36332         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
36333         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36334         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36335         CVec_u8Z_free(ret_var);
36336         return ret_arr;
36337 }
36338
36339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36340         LDKu8slice ser_ref;
36341         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36342         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36343         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
36344         *ret_conv = ChannelReestablish_read(ser_ref);
36345         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36346         return (int64_t)ret_conv;
36347 }
36348
36349 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
36350         LDKClosingSigned obj_conv;
36351         obj_conv.inner = (void*)(obj & (~1));
36352         obj_conv.is_owned = false;
36353         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36354         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
36355         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36356         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36357         CVec_u8Z_free(ret_var);
36358         return ret_arr;
36359 }
36360
36361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36362         LDKu8slice ser_ref;
36363         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36364         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36365         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
36366         *ret_conv = ClosingSigned_read(ser_ref);
36367         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36368         return (int64_t)ret_conv;
36369 }
36370
36371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
36372         LDKClosingSignedFeeRange obj_conv;
36373         obj_conv.inner = (void*)(obj & (~1));
36374         obj_conv.is_owned = false;
36375         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36376         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
36377         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36378         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36379         CVec_u8Z_free(ret_var);
36380         return ret_arr;
36381 }
36382
36383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36384         LDKu8slice ser_ref;
36385         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36386         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36387         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
36388         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
36389         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36390         return (int64_t)ret_conv;
36391 }
36392
36393 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
36394         LDKCommitmentSigned obj_conv;
36395         obj_conv.inner = (void*)(obj & (~1));
36396         obj_conv.is_owned = false;
36397         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36398         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
36399         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36400         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36401         CVec_u8Z_free(ret_var);
36402         return ret_arr;
36403 }
36404
36405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36406         LDKu8slice ser_ref;
36407         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36408         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36409         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
36410         *ret_conv = CommitmentSigned_read(ser_ref);
36411         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36412         return (int64_t)ret_conv;
36413 }
36414
36415 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
36416         LDKFundingCreated obj_conv;
36417         obj_conv.inner = (void*)(obj & (~1));
36418         obj_conv.is_owned = false;
36419         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36420         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
36421         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36422         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36423         CVec_u8Z_free(ret_var);
36424         return ret_arr;
36425 }
36426
36427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36428         LDKu8slice ser_ref;
36429         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36430         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36431         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
36432         *ret_conv = FundingCreated_read(ser_ref);
36433         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36434         return (int64_t)ret_conv;
36435 }
36436
36437 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
36438         LDKFundingSigned obj_conv;
36439         obj_conv.inner = (void*)(obj & (~1));
36440         obj_conv.is_owned = false;
36441         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36442         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
36443         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36444         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36445         CVec_u8Z_free(ret_var);
36446         return ret_arr;
36447 }
36448
36449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36450         LDKu8slice ser_ref;
36451         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36452         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36453         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
36454         *ret_conv = FundingSigned_read(ser_ref);
36455         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36456         return (int64_t)ret_conv;
36457 }
36458
36459 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
36460         LDKChannelReady obj_conv;
36461         obj_conv.inner = (void*)(obj & (~1));
36462         obj_conv.is_owned = false;
36463         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36464         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
36465         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36466         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36467         CVec_u8Z_free(ret_var);
36468         return ret_arr;
36469 }
36470
36471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36472         LDKu8slice ser_ref;
36473         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36474         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36475         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
36476         *ret_conv = ChannelReady_read(ser_ref);
36477         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36478         return (int64_t)ret_conv;
36479 }
36480
36481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
36482         LDKInit obj_conv;
36483         obj_conv.inner = (void*)(obj & (~1));
36484         obj_conv.is_owned = false;
36485         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36486         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
36487         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36488         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36489         CVec_u8Z_free(ret_var);
36490         return ret_arr;
36491 }
36492
36493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36494         LDKu8slice ser_ref;
36495         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36496         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36497         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
36498         *ret_conv = Init_read(ser_ref);
36499         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36500         return (int64_t)ret_conv;
36501 }
36502
36503 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
36504         LDKOpenChannel obj_conv;
36505         obj_conv.inner = (void*)(obj & (~1));
36506         obj_conv.is_owned = false;
36507         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36508         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
36509         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36510         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36511         CVec_u8Z_free(ret_var);
36512         return ret_arr;
36513 }
36514
36515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36516         LDKu8slice ser_ref;
36517         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36518         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36519         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
36520         *ret_conv = OpenChannel_read(ser_ref);
36521         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36522         return (int64_t)ret_conv;
36523 }
36524
36525 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
36526         LDKRevokeAndACK obj_conv;
36527         obj_conv.inner = (void*)(obj & (~1));
36528         obj_conv.is_owned = false;
36529         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36530         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
36531         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36532         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36533         CVec_u8Z_free(ret_var);
36534         return ret_arr;
36535 }
36536
36537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36538         LDKu8slice ser_ref;
36539         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36540         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36541         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
36542         *ret_conv = RevokeAndACK_read(ser_ref);
36543         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36544         return (int64_t)ret_conv;
36545 }
36546
36547 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
36548         LDKShutdown obj_conv;
36549         obj_conv.inner = (void*)(obj & (~1));
36550         obj_conv.is_owned = false;
36551         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36552         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
36553         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36554         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36555         CVec_u8Z_free(ret_var);
36556         return ret_arr;
36557 }
36558
36559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36560         LDKu8slice ser_ref;
36561         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36562         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36563         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
36564         *ret_conv = Shutdown_read(ser_ref);
36565         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36566         return (int64_t)ret_conv;
36567 }
36568
36569 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
36570         LDKUpdateFailHTLC obj_conv;
36571         obj_conv.inner = (void*)(obj & (~1));
36572         obj_conv.is_owned = false;
36573         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36574         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
36575         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36576         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36577         CVec_u8Z_free(ret_var);
36578         return ret_arr;
36579 }
36580
36581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36582         LDKu8slice ser_ref;
36583         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36584         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36585         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
36586         *ret_conv = UpdateFailHTLC_read(ser_ref);
36587         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36588         return (int64_t)ret_conv;
36589 }
36590
36591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
36592         LDKUpdateFailMalformedHTLC obj_conv;
36593         obj_conv.inner = (void*)(obj & (~1));
36594         obj_conv.is_owned = false;
36595         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36596         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
36597         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36598         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36599         CVec_u8Z_free(ret_var);
36600         return ret_arr;
36601 }
36602
36603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36604         LDKu8slice ser_ref;
36605         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36606         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36607         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
36608         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
36609         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36610         return (int64_t)ret_conv;
36611 }
36612
36613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
36614         LDKUpdateFee obj_conv;
36615         obj_conv.inner = (void*)(obj & (~1));
36616         obj_conv.is_owned = false;
36617         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36618         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
36619         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36620         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36621         CVec_u8Z_free(ret_var);
36622         return ret_arr;
36623 }
36624
36625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36626         LDKu8slice ser_ref;
36627         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36628         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36629         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
36630         *ret_conv = UpdateFee_read(ser_ref);
36631         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36632         return (int64_t)ret_conv;
36633 }
36634
36635 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
36636         LDKUpdateFulfillHTLC obj_conv;
36637         obj_conv.inner = (void*)(obj & (~1));
36638         obj_conv.is_owned = false;
36639         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36640         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
36641         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36642         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36643         CVec_u8Z_free(ret_var);
36644         return ret_arr;
36645 }
36646
36647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36648         LDKu8slice ser_ref;
36649         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36650         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36651         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
36652         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
36653         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36654         return (int64_t)ret_conv;
36655 }
36656
36657 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
36658         LDKUpdateAddHTLC obj_conv;
36659         obj_conv.inner = (void*)(obj & (~1));
36660         obj_conv.is_owned = false;
36661         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36662         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
36663         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36664         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36665         CVec_u8Z_free(ret_var);
36666         return ret_arr;
36667 }
36668
36669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36670         LDKu8slice ser_ref;
36671         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36672         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36673         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
36674         *ret_conv = UpdateAddHTLC_read(ser_ref);
36675         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36676         return (int64_t)ret_conv;
36677 }
36678
36679 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
36680         LDKPing obj_conv;
36681         obj_conv.inner = (void*)(obj & (~1));
36682         obj_conv.is_owned = false;
36683         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36684         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
36685         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36686         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36687         CVec_u8Z_free(ret_var);
36688         return ret_arr;
36689 }
36690
36691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36692         LDKu8slice ser_ref;
36693         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36694         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36695         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
36696         *ret_conv = Ping_read(ser_ref);
36697         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36698         return (int64_t)ret_conv;
36699 }
36700
36701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
36702         LDKPong obj_conv;
36703         obj_conv.inner = (void*)(obj & (~1));
36704         obj_conv.is_owned = false;
36705         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36706         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
36707         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36708         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36709         CVec_u8Z_free(ret_var);
36710         return ret_arr;
36711 }
36712
36713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36714         LDKu8slice ser_ref;
36715         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36716         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36717         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
36718         *ret_conv = Pong_read(ser_ref);
36719         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36720         return (int64_t)ret_conv;
36721 }
36722
36723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
36724         LDKUnsignedChannelAnnouncement obj_conv;
36725         obj_conv.inner = (void*)(obj & (~1));
36726         obj_conv.is_owned = false;
36727         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36728         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
36729         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36730         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36731         CVec_u8Z_free(ret_var);
36732         return ret_arr;
36733 }
36734
36735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36736         LDKu8slice ser_ref;
36737         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36738         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36739         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
36740         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
36741         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36742         return (int64_t)ret_conv;
36743 }
36744
36745 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
36746         LDKChannelAnnouncement obj_conv;
36747         obj_conv.inner = (void*)(obj & (~1));
36748         obj_conv.is_owned = false;
36749         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36750         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
36751         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36752         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36753         CVec_u8Z_free(ret_var);
36754         return ret_arr;
36755 }
36756
36757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36758         LDKu8slice ser_ref;
36759         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36760         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36761         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
36762         *ret_conv = ChannelAnnouncement_read(ser_ref);
36763         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36764         return (int64_t)ret_conv;
36765 }
36766
36767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
36768         LDKUnsignedChannelUpdate obj_conv;
36769         obj_conv.inner = (void*)(obj & (~1));
36770         obj_conv.is_owned = false;
36771         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36772         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
36773         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36774         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36775         CVec_u8Z_free(ret_var);
36776         return ret_arr;
36777 }
36778
36779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36780         LDKu8slice ser_ref;
36781         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36782         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36783         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
36784         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
36785         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36786         return (int64_t)ret_conv;
36787 }
36788
36789 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
36790         LDKChannelUpdate obj_conv;
36791         obj_conv.inner = (void*)(obj & (~1));
36792         obj_conv.is_owned = false;
36793         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36794         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
36795         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36796         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36797         CVec_u8Z_free(ret_var);
36798         return ret_arr;
36799 }
36800
36801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36802         LDKu8slice ser_ref;
36803         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36804         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36805         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
36806         *ret_conv = ChannelUpdate_read(ser_ref);
36807         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36808         return (int64_t)ret_conv;
36809 }
36810
36811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
36812         LDKErrorMessage obj_conv;
36813         obj_conv.inner = (void*)(obj & (~1));
36814         obj_conv.is_owned = false;
36815         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36816         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
36817         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36818         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36819         CVec_u8Z_free(ret_var);
36820         return ret_arr;
36821 }
36822
36823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36824         LDKu8slice ser_ref;
36825         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36826         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36827         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
36828         *ret_conv = ErrorMessage_read(ser_ref);
36829         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36830         return (int64_t)ret_conv;
36831 }
36832
36833 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
36834         LDKWarningMessage obj_conv;
36835         obj_conv.inner = (void*)(obj & (~1));
36836         obj_conv.is_owned = false;
36837         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36838         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
36839         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36840         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36841         CVec_u8Z_free(ret_var);
36842         return ret_arr;
36843 }
36844
36845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36846         LDKu8slice ser_ref;
36847         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36848         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36849         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
36850         *ret_conv = WarningMessage_read(ser_ref);
36851         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36852         return (int64_t)ret_conv;
36853 }
36854
36855 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
36856         LDKUnsignedNodeAnnouncement obj_conv;
36857         obj_conv.inner = (void*)(obj & (~1));
36858         obj_conv.is_owned = false;
36859         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36860         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
36861         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36862         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36863         CVec_u8Z_free(ret_var);
36864         return ret_arr;
36865 }
36866
36867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36868         LDKu8slice ser_ref;
36869         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36870         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36871         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
36872         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
36873         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36874         return (int64_t)ret_conv;
36875 }
36876
36877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
36878         LDKNodeAnnouncement obj_conv;
36879         obj_conv.inner = (void*)(obj & (~1));
36880         obj_conv.is_owned = false;
36881         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36882         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
36883         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36884         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36885         CVec_u8Z_free(ret_var);
36886         return ret_arr;
36887 }
36888
36889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36890         LDKu8slice ser_ref;
36891         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36892         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36893         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
36894         *ret_conv = NodeAnnouncement_read(ser_ref);
36895         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36896         return (int64_t)ret_conv;
36897 }
36898
36899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36900         LDKu8slice ser_ref;
36901         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36902         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36903         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
36904         *ret_conv = QueryShortChannelIds_read(ser_ref);
36905         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36906         return (int64_t)ret_conv;
36907 }
36908
36909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
36910         LDKQueryShortChannelIds obj_conv;
36911         obj_conv.inner = (void*)(obj & (~1));
36912         obj_conv.is_owned = false;
36913         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36914         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
36915         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36916         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36917         CVec_u8Z_free(ret_var);
36918         return ret_arr;
36919 }
36920
36921 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
36922         LDKReplyShortChannelIdsEnd obj_conv;
36923         obj_conv.inner = (void*)(obj & (~1));
36924         obj_conv.is_owned = false;
36925         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36926         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
36927         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36928         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36929         CVec_u8Z_free(ret_var);
36930         return ret_arr;
36931 }
36932
36933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36934         LDKu8slice ser_ref;
36935         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36936         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36937         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
36938         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
36939         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36940         return (int64_t)ret_conv;
36941 }
36942
36943 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
36944         LDKQueryChannelRange this_arg_conv;
36945         this_arg_conv.inner = (void*)(this_arg & (~1));
36946         this_arg_conv.is_owned = false;
36947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36948         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
36949         return ret_conv;
36950 }
36951
36952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
36953         LDKQueryChannelRange obj_conv;
36954         obj_conv.inner = (void*)(obj & (~1));
36955         obj_conv.is_owned = false;
36956         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36957         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
36958         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36959         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36960         CVec_u8Z_free(ret_var);
36961         return ret_arr;
36962 }
36963
36964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36965         LDKu8slice ser_ref;
36966         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36967         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36968         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
36969         *ret_conv = QueryChannelRange_read(ser_ref);
36970         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36971         return (int64_t)ret_conv;
36972 }
36973
36974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36975         LDKu8slice ser_ref;
36976         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36977         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36978         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
36979         *ret_conv = ReplyChannelRange_read(ser_ref);
36980         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36981         return (int64_t)ret_conv;
36982 }
36983
36984 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
36985         LDKReplyChannelRange obj_conv;
36986         obj_conv.inner = (void*)(obj & (~1));
36987         obj_conv.is_owned = false;
36988         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36989         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
36990         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36991         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36992         CVec_u8Z_free(ret_var);
36993         return ret_arr;
36994 }
36995
36996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
36997         LDKGossipTimestampFilter obj_conv;
36998         obj_conv.inner = (void*)(obj & (~1));
36999         obj_conv.is_owned = false;
37000         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37001         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
37002         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37003         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37004         CVec_u8Z_free(ret_var);
37005         return ret_arr;
37006 }
37007
37008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37009         LDKu8slice ser_ref;
37010         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37011         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37012         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
37013         *ret_conv = GossipTimestampFilter_read(ser_ref);
37014         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37015         return (int64_t)ret_conv;
37016 }
37017
37018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37019         if ((this_ptr & 1) != 0) return;
37020         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37021         CHECK_ACCESS(this_ptr_ptr);
37022         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
37023         FREE((void*)this_ptr);
37024         CustomMessageHandler_free(this_ptr_conv);
37025 }
37026
37027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37028         LDKIgnoringMessageHandler this_obj_conv;
37029         this_obj_conv.inner = (void*)(this_obj & (~1));
37030         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37032         IgnoringMessageHandler_free(this_obj_conv);
37033 }
37034
37035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
37036         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
37037         int64_t ret_ref = 0;
37038         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37039         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37041         ret_ref = (uintptr_t)ret_var.inner;
37042         if (ret_var.is_owned) {
37043                 ret_ref |= 1;
37044         }
37045         return ret_ref;
37046 }
37047
37048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
37049         LDKIgnoringMessageHandler this_arg_conv;
37050         this_arg_conv.inner = (void*)(this_arg & (~1));
37051         this_arg_conv.is_owned = false;
37052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37053         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
37054         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
37055         return (int64_t)ret_ret;
37056 }
37057
37058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
37059         LDKIgnoringMessageHandler this_arg_conv;
37060         this_arg_conv.inner = (void*)(this_arg & (~1));
37061         this_arg_conv.is_owned = false;
37062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37063         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
37064         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
37065         return (int64_t)ret_ret;
37066 }
37067
37068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
37069         LDKIgnoringMessageHandler this_arg_conv;
37070         this_arg_conv.inner = (void*)(this_arg & (~1));
37071         this_arg_conv.is_owned = false;
37072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37073         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
37074         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
37075         return (int64_t)ret_ret;
37076 }
37077
37078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
37079         LDKIgnoringMessageHandler this_arg_conv;
37080         this_arg_conv.inner = (void*)(this_arg & (~1));
37081         this_arg_conv.is_owned = false;
37082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37083         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
37084         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
37085         return (int64_t)ret_ret;
37086 }
37087
37088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37089         LDKErroringMessageHandler this_obj_conv;
37090         this_obj_conv.inner = (void*)(this_obj & (~1));
37091         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37093         ErroringMessageHandler_free(this_obj_conv);
37094 }
37095
37096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
37097         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
37098         int64_t ret_ref = 0;
37099         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37100         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37102         ret_ref = (uintptr_t)ret_var.inner;
37103         if (ret_var.is_owned) {
37104                 ret_ref |= 1;
37105         }
37106         return ret_ref;
37107 }
37108
37109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
37110         LDKErroringMessageHandler this_arg_conv;
37111         this_arg_conv.inner = (void*)(this_arg & (~1));
37112         this_arg_conv.is_owned = false;
37113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37114         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
37115         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
37116         return (int64_t)ret_ret;
37117 }
37118
37119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
37120         LDKErroringMessageHandler this_arg_conv;
37121         this_arg_conv.inner = (void*)(this_arg & (~1));
37122         this_arg_conv.is_owned = false;
37123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37124         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
37125         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
37126         return (int64_t)ret_ret;
37127 }
37128
37129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37130         LDKMessageHandler this_obj_conv;
37131         this_obj_conv.inner = (void*)(this_obj & (~1));
37132         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37134         MessageHandler_free(this_obj_conv);
37135 }
37136
37137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
37138         LDKMessageHandler this_ptr_conv;
37139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37140         this_ptr_conv.is_owned = false;
37141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37142         // WARNING: This object doesn't live past this scope, needs clone!
37143         int64_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
37144         return ret_ret;
37145 }
37146
37147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37148         LDKMessageHandler this_ptr_conv;
37149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37150         this_ptr_conv.is_owned = false;
37151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37152         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37153         CHECK_ACCESS(val_ptr);
37154         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
37155         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
37156                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37157                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
37158         }
37159         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
37160 }
37161
37162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
37163         LDKMessageHandler this_ptr_conv;
37164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37165         this_ptr_conv.is_owned = false;
37166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37167         // WARNING: This object doesn't live past this scope, needs clone!
37168         int64_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
37169         return ret_ret;
37170 }
37171
37172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37173         LDKMessageHandler this_ptr_conv;
37174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37175         this_ptr_conv.is_owned = false;
37176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37177         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37178         CHECK_ACCESS(val_ptr);
37179         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
37180         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
37181                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37182                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
37183         }
37184         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
37185 }
37186
37187 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) {
37188         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
37189         CHECK_ACCESS(chan_handler_arg_ptr);
37190         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
37191         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
37192                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37193                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
37194         }
37195         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
37196         CHECK_ACCESS(route_handler_arg_ptr);
37197         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
37198         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
37199                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37200                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
37201         }
37202         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
37203         int64_t ret_ref = 0;
37204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37207         ret_ref = (uintptr_t)ret_var.inner;
37208         if (ret_var.is_owned) {
37209                 ret_ref |= 1;
37210         }
37211         return ret_ref;
37212 }
37213
37214 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
37215         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
37216         *ret_ret = SocketDescriptor_clone(arg);
37217         return (int64_t)ret_ret;
37218 }
37219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37220         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
37221         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
37222         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
37223         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
37224         return ret_conv;
37225 }
37226
37227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37228         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
37229         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
37230         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
37231         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
37232         *ret_ret = SocketDescriptor_clone(orig_conv);
37233         return (int64_t)ret_ret;
37234 }
37235
37236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37237         if ((this_ptr & 1) != 0) return;
37238         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37239         CHECK_ACCESS(this_ptr_ptr);
37240         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
37241         FREE((void*)this_ptr);
37242         SocketDescriptor_free(this_ptr_conv);
37243 }
37244
37245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37246         LDKPeerHandleError this_obj_conv;
37247         this_obj_conv.inner = (void*)(this_obj & (~1));
37248         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37250         PeerHandleError_free(this_obj_conv);
37251 }
37252
37253 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
37254         LDKPeerHandleError this_ptr_conv;
37255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37256         this_ptr_conv.is_owned = false;
37257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37258         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
37259         return ret_conv;
37260 }
37261
37262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37263         LDKPeerHandleError this_ptr_conv;
37264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37265         this_ptr_conv.is_owned = false;
37266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37267         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
37268 }
37269
37270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
37271         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
37272         int64_t ret_ref = 0;
37273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37276         ret_ref = (uintptr_t)ret_var.inner;
37277         if (ret_var.is_owned) {
37278                 ret_ref |= 1;
37279         }
37280         return ret_ref;
37281 }
37282
37283 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
37284         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
37285 int64_t ret_ref = 0;
37286 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37287 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37288 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37289 ret_ref = (uintptr_t)ret_var.inner;
37290 if (ret_var.is_owned) {
37291         ret_ref |= 1;
37292 }
37293         return ret_ref;
37294 }
37295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37296         LDKPeerHandleError arg_conv;
37297         arg_conv.inner = (void*)(arg & (~1));
37298         arg_conv.is_owned = false;
37299         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37300         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
37301         return ret_conv;
37302 }
37303
37304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37305         LDKPeerHandleError orig_conv;
37306         orig_conv.inner = (void*)(orig & (~1));
37307         orig_conv.is_owned = false;
37308         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37309         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
37310         int64_t ret_ref = 0;
37311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37314         ret_ref = (uintptr_t)ret_var.inner;
37315         if (ret_var.is_owned) {
37316                 ret_ref |= 1;
37317         }
37318         return ret_ref;
37319 }
37320
37321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37322         LDKPeerManager this_obj_conv;
37323         this_obj_conv.inner = (void*)(this_obj & (~1));
37324         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37326         PeerManager_free(this_obj_conv);
37327 }
37328
37329 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) {
37330         LDKMessageHandler message_handler_conv;
37331         message_handler_conv.inner = (void*)(message_handler & (~1));
37332         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
37333         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
37334         // WARNING: we need a move here but no clone is available for LDKMessageHandler
37335         LDKSecretKey our_node_secret_ref;
37336         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
37337         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
37338         unsigned char ephemeral_random_data_arr[32];
37339         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
37340         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
37341         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
37342         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
37343         CHECK_ACCESS(logger_ptr);
37344         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
37345         if (logger_conv.free == LDKLogger_JCalls_free) {
37346                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37347                 LDKLogger_JCalls_cloned(&logger_conv);
37348         }
37349         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
37350         CHECK_ACCESS(custom_message_handler_ptr);
37351         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
37352         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
37353                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37354                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
37355         }
37356         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
37357         int64_t ret_ref = 0;
37358         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37359         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37361         ret_ref = (uintptr_t)ret_var.inner;
37362         if (ret_var.is_owned) {
37363                 ret_ref |= 1;
37364         }
37365         return ret_ref;
37366 }
37367
37368 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
37369         LDKPeerManager this_arg_conv;
37370         this_arg_conv.inner = (void*)(this_arg & (~1));
37371         this_arg_conv.is_owned = false;
37372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37373         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
37374         jobjectArray ret_arr = NULL;
37375         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
37376         ;
37377         for (size_t i = 0; i < ret_var.datalen; i++) {
37378                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
37379                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
37380                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
37381         }
37382         
37383         FREE(ret_var.data);
37384         return ret_arr;
37385 }
37386
37387 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, int64_t remote_network_address) {
37388         LDKPeerManager this_arg_conv;
37389         this_arg_conv.inner = (void*)(this_arg & (~1));
37390         this_arg_conv.is_owned = false;
37391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37392         LDKPublicKey their_node_id_ref;
37393         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
37394         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
37395         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
37396         CHECK_ACCESS(descriptor_ptr);
37397         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
37398         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
37399                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37400                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
37401         }
37402         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
37403         CHECK_ACCESS(remote_network_address_ptr);
37404         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
37405         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
37406         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
37407         return (int64_t)ret_conv;
37408 }
37409
37410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor, int64_t remote_network_address) {
37411         LDKPeerManager this_arg_conv;
37412         this_arg_conv.inner = (void*)(this_arg & (~1));
37413         this_arg_conv.is_owned = false;
37414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37415         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
37416         CHECK_ACCESS(descriptor_ptr);
37417         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
37418         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
37419                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37420                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
37421         }
37422         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
37423         CHECK_ACCESS(remote_network_address_ptr);
37424         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
37425         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
37426         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
37427         return (int64_t)ret_conv;
37428 }
37429
37430 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) {
37431         LDKPeerManager this_arg_conv;
37432         this_arg_conv.inner = (void*)(this_arg & (~1));
37433         this_arg_conv.is_owned = false;
37434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37435         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
37436         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
37437         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
37438         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
37439         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
37440         return (int64_t)ret_conv;
37441 }
37442
37443 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) {
37444         LDKPeerManager this_arg_conv;
37445         this_arg_conv.inner = (void*)(this_arg & (~1));
37446         this_arg_conv.is_owned = false;
37447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37448         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
37449         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
37450         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
37451         LDKu8slice data_ref;
37452         data_ref.datalen = (*env)->GetArrayLength(env, data);
37453         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
37454         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
37455         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
37456         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
37457         return (int64_t)ret_conv;
37458 }
37459
37460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
37461         LDKPeerManager this_arg_conv;
37462         this_arg_conv.inner = (void*)(this_arg & (~1));
37463         this_arg_conv.is_owned = false;
37464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37465         PeerManager_process_events(&this_arg_conv);
37466 }
37467
37468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
37469         LDKPeerManager this_arg_conv;
37470         this_arg_conv.inner = (void*)(this_arg & (~1));
37471         this_arg_conv.is_owned = false;
37472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37473         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
37474         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
37475         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
37476         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
37477 }
37478
37479 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) {
37480         LDKPeerManager this_arg_conv;
37481         this_arg_conv.inner = (void*)(this_arg & (~1));
37482         this_arg_conv.is_owned = false;
37483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37484         LDKPublicKey node_id_ref;
37485         CHECK((*env)->GetArrayLength(env, node_id) == 33);
37486         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
37487         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
37488 }
37489
37490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
37491         LDKPeerManager this_arg_conv;
37492         this_arg_conv.inner = (void*)(this_arg & (~1));
37493         this_arg_conv.is_owned = false;
37494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37495         PeerManager_disconnect_all_peers(&this_arg_conv);
37496 }
37497
37498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
37499         LDKPeerManager this_arg_conv;
37500         this_arg_conv.inner = (void*)(this_arg & (~1));
37501         this_arg_conv.is_owned = false;
37502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37503         PeerManager_timer_tick_occurred(&this_arg_conv);
37504 }
37505
37506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
37507         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
37508         return ret_conv;
37509 }
37510
37511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
37512         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
37513         return ret_conv;
37514 }
37515
37516 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
37517         unsigned char commitment_seed_arr[32];
37518         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
37519         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
37520         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
37521         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37522         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
37523         return ret_arr;
37524 }
37525
37526 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) {
37527         LDKCVec_u8Z to_holder_script_ref;
37528         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
37529         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
37530         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
37531         LDKCVec_u8Z to_counterparty_script_ref;
37532         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
37533         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
37534         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
37535         LDKOutPoint funding_outpoint_conv;
37536         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
37537         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
37538         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
37539         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
37540         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);
37541         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37542         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37543         Transaction_free(ret_var);
37544         return ret_arr;
37545 }
37546
37547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37548         LDKCounterpartyCommitmentSecrets this_obj_conv;
37549         this_obj_conv.inner = (void*)(this_obj & (~1));
37550         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37552         CounterpartyCommitmentSecrets_free(this_obj_conv);
37553 }
37554
37555 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
37556         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
37557 int64_t ret_ref = 0;
37558 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37559 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37560 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37561 ret_ref = (uintptr_t)ret_var.inner;
37562 if (ret_var.is_owned) {
37563         ret_ref |= 1;
37564 }
37565         return ret_ref;
37566 }
37567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37568         LDKCounterpartyCommitmentSecrets arg_conv;
37569         arg_conv.inner = (void*)(arg & (~1));
37570         arg_conv.is_owned = false;
37571         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37572         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
37573         return ret_conv;
37574 }
37575
37576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37577         LDKCounterpartyCommitmentSecrets orig_conv;
37578         orig_conv.inner = (void*)(orig & (~1));
37579         orig_conv.is_owned = false;
37580         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37581         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
37582         int64_t ret_ref = 0;
37583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37586         ret_ref = (uintptr_t)ret_var.inner;
37587         if (ret_var.is_owned) {
37588                 ret_ref |= 1;
37589         }
37590         return ret_ref;
37591 }
37592
37593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
37594         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
37595         int64_t ret_ref = 0;
37596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37599         ret_ref = (uintptr_t)ret_var.inner;
37600         if (ret_var.is_owned) {
37601                 ret_ref |= 1;
37602         }
37603         return ret_ref;
37604 }
37605
37606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
37607         LDKCounterpartyCommitmentSecrets this_arg_conv;
37608         this_arg_conv.inner = (void*)(this_arg & (~1));
37609         this_arg_conv.is_owned = false;
37610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37611         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
37612         return ret_conv;
37613 }
37614
37615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1provide_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx, int8_tArray secret) {
37616         LDKCounterpartyCommitmentSecrets this_arg_conv;
37617         this_arg_conv.inner = (void*)(this_arg & (~1));
37618         this_arg_conv.is_owned = false;
37619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37620         LDKThirtyTwoBytes secret_ref;
37621         CHECK((*env)->GetArrayLength(env, secret) == 32);
37622         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
37623         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
37624         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
37625         return (int64_t)ret_conv;
37626 }
37627
37628 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
37629         LDKCounterpartyCommitmentSecrets this_arg_conv;
37630         this_arg_conv.inner = (void*)(this_arg & (~1));
37631         this_arg_conv.is_owned = false;
37632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37633         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37634         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
37635         return ret_arr;
37636 }
37637
37638 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
37639         LDKCounterpartyCommitmentSecrets obj_conv;
37640         obj_conv.inner = (void*)(obj & (~1));
37641         obj_conv.is_owned = false;
37642         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37643         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
37644         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37645         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37646         CVec_u8Z_free(ret_var);
37647         return ret_arr;
37648 }
37649
37650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37651         LDKu8slice ser_ref;
37652         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37653         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37654         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
37655         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
37656         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37657         return (int64_t)ret_conv;
37658 }
37659
37660 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) {
37661         LDKPublicKey per_commitment_point_ref;
37662         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37663         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37664         unsigned char base_secret_arr[32];
37665         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
37666         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
37667         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
37668         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
37669         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
37670         return (int64_t)ret_conv;
37671 }
37672
37673 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) {
37674         LDKPublicKey per_commitment_point_ref;
37675         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37676         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37677         LDKPublicKey base_point_ref;
37678         CHECK((*env)->GetArrayLength(env, base_point) == 33);
37679         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
37680         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
37681         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
37682         return (int64_t)ret_conv;
37683 }
37684
37685 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) {
37686         unsigned char per_commitment_secret_arr[32];
37687         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
37688         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
37689         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
37690         unsigned char countersignatory_revocation_base_secret_arr[32];
37691         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
37692         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
37693         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
37694         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
37695         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
37696         return (int64_t)ret_conv;
37697 }
37698
37699 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) {
37700         LDKPublicKey per_commitment_point_ref;
37701         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37702         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37703         LDKPublicKey countersignatory_revocation_base_point_ref;
37704         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
37705         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
37706         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
37707         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
37708         return (int64_t)ret_conv;
37709 }
37710
37711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37712         LDKTxCreationKeys this_obj_conv;
37713         this_obj_conv.inner = (void*)(this_obj & (~1));
37714         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37716         TxCreationKeys_free(this_obj_conv);
37717 }
37718
37719 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37720         LDKTxCreationKeys this_ptr_conv;
37721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37722         this_ptr_conv.is_owned = false;
37723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37724         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37725         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
37726         return ret_arr;
37727 }
37728
37729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37730         LDKTxCreationKeys this_ptr_conv;
37731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37732         this_ptr_conv.is_owned = false;
37733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37734         LDKPublicKey val_ref;
37735         CHECK((*env)->GetArrayLength(env, val) == 33);
37736         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37737         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
37738 }
37739
37740 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
37741         LDKTxCreationKeys this_ptr_conv;
37742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37743         this_ptr_conv.is_owned = false;
37744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37745         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37746         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
37747         return ret_arr;
37748 }
37749
37750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37751         LDKTxCreationKeys this_ptr_conv;
37752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37753         this_ptr_conv.is_owned = false;
37754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37755         LDKPublicKey val_ref;
37756         CHECK((*env)->GetArrayLength(env, val) == 33);
37757         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37758         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
37759 }
37760
37761 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
37762         LDKTxCreationKeys this_ptr_conv;
37763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37764         this_ptr_conv.is_owned = false;
37765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37766         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37767         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
37768         return ret_arr;
37769 }
37770
37771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37772         LDKTxCreationKeys this_ptr_conv;
37773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37774         this_ptr_conv.is_owned = false;
37775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37776         LDKPublicKey val_ref;
37777         CHECK((*env)->GetArrayLength(env, val) == 33);
37778         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37779         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
37780 }
37781
37782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
37783         LDKTxCreationKeys this_ptr_conv;
37784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37785         this_ptr_conv.is_owned = false;
37786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37787         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37788         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
37789         return ret_arr;
37790 }
37791
37792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37793         LDKTxCreationKeys this_ptr_conv;
37794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37795         this_ptr_conv.is_owned = false;
37796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37797         LDKPublicKey val_ref;
37798         CHECK((*env)->GetArrayLength(env, val) == 33);
37799         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37800         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
37801 }
37802
37803 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
37804         LDKTxCreationKeys this_ptr_conv;
37805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37806         this_ptr_conv.is_owned = false;
37807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37808         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37809         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
37810         return ret_arr;
37811 }
37812
37813 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) {
37814         LDKTxCreationKeys this_ptr_conv;
37815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37816         this_ptr_conv.is_owned = false;
37817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37818         LDKPublicKey val_ref;
37819         CHECK((*env)->GetArrayLength(env, val) == 33);
37820         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37821         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
37822 }
37823
37824 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) {
37825         LDKPublicKey per_commitment_point_arg_ref;
37826         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
37827         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
37828         LDKPublicKey revocation_key_arg_ref;
37829         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
37830         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
37831         LDKPublicKey broadcaster_htlc_key_arg_ref;
37832         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
37833         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
37834         LDKPublicKey countersignatory_htlc_key_arg_ref;
37835         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
37836         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
37837         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
37838         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
37839         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
37840         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);
37841         int64_t ret_ref = 0;
37842         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37843         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37845         ret_ref = (uintptr_t)ret_var.inner;
37846         if (ret_var.is_owned) {
37847                 ret_ref |= 1;
37848         }
37849         return ret_ref;
37850 }
37851
37852 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
37853         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
37854 int64_t ret_ref = 0;
37855 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37856 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37857 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37858 ret_ref = (uintptr_t)ret_var.inner;
37859 if (ret_var.is_owned) {
37860         ret_ref |= 1;
37861 }
37862         return ret_ref;
37863 }
37864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37865         LDKTxCreationKeys arg_conv;
37866         arg_conv.inner = (void*)(arg & (~1));
37867         arg_conv.is_owned = false;
37868         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37869         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
37870         return ret_conv;
37871 }
37872
37873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37874         LDKTxCreationKeys orig_conv;
37875         orig_conv.inner = (void*)(orig & (~1));
37876         orig_conv.is_owned = false;
37877         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37878         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
37879         int64_t ret_ref = 0;
37880         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37881         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37883         ret_ref = (uintptr_t)ret_var.inner;
37884         if (ret_var.is_owned) {
37885                 ret_ref |= 1;
37886         }
37887         return ret_ref;
37888 }
37889
37890 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
37891         LDKTxCreationKeys obj_conv;
37892         obj_conv.inner = (void*)(obj & (~1));
37893         obj_conv.is_owned = false;
37894         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37895         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
37896         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37897         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37898         CVec_u8Z_free(ret_var);
37899         return ret_arr;
37900 }
37901
37902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37903         LDKu8slice ser_ref;
37904         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37905         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37906         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
37907         *ret_conv = TxCreationKeys_read(ser_ref);
37908         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37909         return (int64_t)ret_conv;
37910 }
37911
37912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37913         LDKChannelPublicKeys this_obj_conv;
37914         this_obj_conv.inner = (void*)(this_obj & (~1));
37915         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37917         ChannelPublicKeys_free(this_obj_conv);
37918 }
37919
37920 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
37921         LDKChannelPublicKeys this_ptr_conv;
37922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37923         this_ptr_conv.is_owned = false;
37924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37925         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37926         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
37927         return ret_arr;
37928 }
37929
37930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37931         LDKChannelPublicKeys this_ptr_conv;
37932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37933         this_ptr_conv.is_owned = false;
37934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37935         LDKPublicKey val_ref;
37936         CHECK((*env)->GetArrayLength(env, val) == 33);
37937         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37938         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
37939 }
37940
37941 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37942         LDKChannelPublicKeys this_ptr_conv;
37943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37944         this_ptr_conv.is_owned = false;
37945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37946         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37947         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
37948         return ret_arr;
37949 }
37950
37951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37952         LDKChannelPublicKeys this_ptr_conv;
37953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37954         this_ptr_conv.is_owned = false;
37955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37956         LDKPublicKey val_ref;
37957         CHECK((*env)->GetArrayLength(env, val) == 33);
37958         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37959         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
37960 }
37961
37962 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37963         LDKChannelPublicKeys this_ptr_conv;
37964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37965         this_ptr_conv.is_owned = false;
37966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37967         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37968         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
37969         return ret_arr;
37970 }
37971
37972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37973         LDKChannelPublicKeys this_ptr_conv;
37974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37975         this_ptr_conv.is_owned = false;
37976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37977         LDKPublicKey val_ref;
37978         CHECK((*env)->GetArrayLength(env, val) == 33);
37979         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37980         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
37981 }
37982
37983 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37984         LDKChannelPublicKeys this_ptr_conv;
37985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37986         this_ptr_conv.is_owned = false;
37987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37988         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37989         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
37990         return ret_arr;
37991 }
37992
37993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37994         LDKChannelPublicKeys this_ptr_conv;
37995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37996         this_ptr_conv.is_owned = false;
37997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37998         LDKPublicKey val_ref;
37999         CHECK((*env)->GetArrayLength(env, val) == 33);
38000         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38001         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
38002 }
38003
38004 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
38005         LDKChannelPublicKeys this_ptr_conv;
38006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38007         this_ptr_conv.is_owned = false;
38008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38009         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38010         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
38011         return ret_arr;
38012 }
38013
38014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38015         LDKChannelPublicKeys this_ptr_conv;
38016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38017         this_ptr_conv.is_owned = false;
38018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38019         LDKPublicKey val_ref;
38020         CHECK((*env)->GetArrayLength(env, val) == 33);
38021         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38022         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
38023 }
38024
38025 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) {
38026         LDKPublicKey funding_pubkey_arg_ref;
38027         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
38028         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
38029         LDKPublicKey revocation_basepoint_arg_ref;
38030         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
38031         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
38032         LDKPublicKey payment_point_arg_ref;
38033         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
38034         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
38035         LDKPublicKey delayed_payment_basepoint_arg_ref;
38036         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
38037         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
38038         LDKPublicKey htlc_basepoint_arg_ref;
38039         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
38040         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
38041         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);
38042         int64_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 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
38054         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
38055 int64_t ret_ref = 0;
38056 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38057 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38058 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38059 ret_ref = (uintptr_t)ret_var.inner;
38060 if (ret_var.is_owned) {
38061         ret_ref |= 1;
38062 }
38063         return ret_ref;
38064 }
38065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38066         LDKChannelPublicKeys arg_conv;
38067         arg_conv.inner = (void*)(arg & (~1));
38068         arg_conv.is_owned = false;
38069         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38070         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
38071         return ret_conv;
38072 }
38073
38074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38075         LDKChannelPublicKeys orig_conv;
38076         orig_conv.inner = (void*)(orig & (~1));
38077         orig_conv.is_owned = false;
38078         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38079         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
38080         int64_t ret_ref = 0;
38081         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38082         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38084         ret_ref = (uintptr_t)ret_var.inner;
38085         if (ret_var.is_owned) {
38086                 ret_ref |= 1;
38087         }
38088         return ret_ref;
38089 }
38090
38091 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
38092         LDKChannelPublicKeys obj_conv;
38093         obj_conv.inner = (void*)(obj & (~1));
38094         obj_conv.is_owned = false;
38095         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38096         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
38097         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38098         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38099         CVec_u8Z_free(ret_var);
38100         return ret_arr;
38101 }
38102
38103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38104         LDKu8slice ser_ref;
38105         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38106         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38107         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
38108         *ret_conv = ChannelPublicKeys_read(ser_ref);
38109         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38110         return (int64_t)ret_conv;
38111 }
38112
38113 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) {
38114         LDKPublicKey per_commitment_point_ref;
38115         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38116         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38117         LDKPublicKey broadcaster_delayed_payment_base_ref;
38118         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
38119         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
38120         LDKPublicKey broadcaster_htlc_base_ref;
38121         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
38122         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
38123         LDKPublicKey countersignatory_revocation_base_ref;
38124         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
38125         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
38126         LDKPublicKey countersignatory_htlc_base_ref;
38127         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
38128         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
38129         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
38130         *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);
38131         return (int64_t)ret_conv;
38132 }
38133
38134 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) {
38135         LDKPublicKey per_commitment_point_ref;
38136         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38137         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38138         LDKChannelPublicKeys broadcaster_keys_conv;
38139         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
38140         broadcaster_keys_conv.is_owned = false;
38141         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
38142         LDKChannelPublicKeys countersignatory_keys_conv;
38143         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
38144         countersignatory_keys_conv.is_owned = false;
38145         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
38146         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
38147         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
38148         return (int64_t)ret_conv;
38149 }
38150
38151 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) {
38152         LDKPublicKey revocation_key_ref;
38153         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
38154         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
38155         LDKPublicKey broadcaster_delayed_payment_key_ref;
38156         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
38157         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
38158         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
38159         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38160         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38161         CVec_u8Z_free(ret_var);
38162         return ret_arr;
38163 }
38164
38165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38166         LDKHTLCOutputInCommitment this_obj_conv;
38167         this_obj_conv.inner = (void*)(this_obj & (~1));
38168         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38170         HTLCOutputInCommitment_free(this_obj_conv);
38171 }
38172
38173 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
38174         LDKHTLCOutputInCommitment this_ptr_conv;
38175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38176         this_ptr_conv.is_owned = false;
38177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38178         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
38179         return ret_conv;
38180 }
38181
38182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38183         LDKHTLCOutputInCommitment this_ptr_conv;
38184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38185         this_ptr_conv.is_owned = false;
38186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38187         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
38188 }
38189
38190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38191         LDKHTLCOutputInCommitment this_ptr_conv;
38192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38193         this_ptr_conv.is_owned = false;
38194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38195         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
38196         return ret_conv;
38197 }
38198
38199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38200         LDKHTLCOutputInCommitment this_ptr_conv;
38201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38202         this_ptr_conv.is_owned = false;
38203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38204         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
38205 }
38206
38207 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
38208         LDKHTLCOutputInCommitment this_ptr_conv;
38209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38210         this_ptr_conv.is_owned = false;
38211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38212         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
38213         return ret_conv;
38214 }
38215
38216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38217         LDKHTLCOutputInCommitment this_ptr_conv;
38218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38219         this_ptr_conv.is_owned = false;
38220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38221         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
38222 }
38223
38224 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38225         LDKHTLCOutputInCommitment this_ptr_conv;
38226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38227         this_ptr_conv.is_owned = false;
38228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38229         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38230         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
38231         return ret_arr;
38232 }
38233
38234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38235         LDKHTLCOutputInCommitment this_ptr_conv;
38236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38237         this_ptr_conv.is_owned = false;
38238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38239         LDKThirtyTwoBytes val_ref;
38240         CHECK((*env)->GetArrayLength(env, val) == 32);
38241         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38242         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
38243 }
38244
38245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
38246         LDKHTLCOutputInCommitment this_ptr_conv;
38247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38248         this_ptr_conv.is_owned = false;
38249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38250         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
38251         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
38252         int64_t ret_ref = (uintptr_t)ret_copy;
38253         return ret_ref;
38254 }
38255
38256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38257         LDKHTLCOutputInCommitment this_ptr_conv;
38258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38259         this_ptr_conv.is_owned = false;
38260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38261         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38262         CHECK_ACCESS(val_ptr);
38263         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
38264         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
38265         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
38266 }
38267
38268 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) {
38269         LDKThirtyTwoBytes payment_hash_arg_ref;
38270         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
38271         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
38272         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
38273         CHECK_ACCESS(transaction_output_index_arg_ptr);
38274         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
38275         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
38276         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
38277         int64_t ret_ref = 0;
38278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38281         ret_ref = (uintptr_t)ret_var.inner;
38282         if (ret_var.is_owned) {
38283                 ret_ref |= 1;
38284         }
38285         return ret_ref;
38286 }
38287
38288 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
38289         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
38290 int64_t ret_ref = 0;
38291 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38292 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38293 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38294 ret_ref = (uintptr_t)ret_var.inner;
38295 if (ret_var.is_owned) {
38296         ret_ref |= 1;
38297 }
38298         return ret_ref;
38299 }
38300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38301         LDKHTLCOutputInCommitment arg_conv;
38302         arg_conv.inner = (void*)(arg & (~1));
38303         arg_conv.is_owned = false;
38304         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38305         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
38306         return ret_conv;
38307 }
38308
38309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38310         LDKHTLCOutputInCommitment orig_conv;
38311         orig_conv.inner = (void*)(orig & (~1));
38312         orig_conv.is_owned = false;
38313         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38314         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
38315         int64_t ret_ref = 0;
38316         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38317         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38319         ret_ref = (uintptr_t)ret_var.inner;
38320         if (ret_var.is_owned) {
38321                 ret_ref |= 1;
38322         }
38323         return ret_ref;
38324 }
38325
38326 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
38327         LDKHTLCOutputInCommitment obj_conv;
38328         obj_conv.inner = (void*)(obj & (~1));
38329         obj_conv.is_owned = false;
38330         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38331         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
38332         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38333         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38334         CVec_u8Z_free(ret_var);
38335         return ret_arr;
38336 }
38337
38338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38339         LDKu8slice ser_ref;
38340         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38341         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38342         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
38343         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
38344         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38345         return (int64_t)ret_conv;
38346 }
38347
38348 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) {
38349         LDKHTLCOutputInCommitment htlc_conv;
38350         htlc_conv.inner = (void*)(htlc & (~1));
38351         htlc_conv.is_owned = false;
38352         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
38353         LDKTxCreationKeys keys_conv;
38354         keys_conv.inner = (void*)(keys & (~1));
38355         keys_conv.is_owned = false;
38356         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
38357         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
38358         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38359         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38360         CVec_u8Z_free(ret_var);
38361         return ret_arr;
38362 }
38363
38364 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
38365         LDKPublicKey broadcaster_ref;
38366         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
38367         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
38368         LDKPublicKey countersignatory_ref;
38369         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
38370         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
38371         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
38372         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38373         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38374         CVec_u8Z_free(ret_var);
38375         return ret_arr;
38376 }
38377
38378 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) {
38379         unsigned char commitment_txid_arr[32];
38380         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
38381         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
38382         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
38383         LDKHTLCOutputInCommitment htlc_conv;
38384         htlc_conv.inner = (void*)(htlc & (~1));
38385         htlc_conv.is_owned = false;
38386         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
38387         LDKPublicKey broadcaster_delayed_payment_key_ref;
38388         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
38389         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
38390         LDKPublicKey revocation_key_ref;
38391         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
38392         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
38393         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);
38394         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38395         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38396         Transaction_free(ret_var);
38397         return ret_arr;
38398 }
38399
38400 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
38401         LDKPublicKey funding_pubkey_ref;
38402         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
38403         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
38404         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
38405         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38406         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38407         CVec_u8Z_free(ret_var);
38408         return ret_arr;
38409 }
38410
38411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38412         LDKChannelTransactionParameters this_obj_conv;
38413         this_obj_conv.inner = (void*)(this_obj & (~1));
38414         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38416         ChannelTransactionParameters_free(this_obj_conv);
38417 }
38418
38419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
38420         LDKChannelTransactionParameters this_ptr_conv;
38421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38422         this_ptr_conv.is_owned = false;
38423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38424         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
38425         int64_t ret_ref = 0;
38426         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38427         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38429         ret_ref = (uintptr_t)ret_var.inner;
38430         if (ret_var.is_owned) {
38431                 ret_ref |= 1;
38432         }
38433         return ret_ref;
38434 }
38435
38436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38437         LDKChannelTransactionParameters this_ptr_conv;
38438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38439         this_ptr_conv.is_owned = false;
38440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38441         LDKChannelPublicKeys val_conv;
38442         val_conv.inner = (void*)(val & (~1));
38443         val_conv.is_owned = (val & 1) || (val == 0);
38444         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38445         val_conv = ChannelPublicKeys_clone(&val_conv);
38446         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
38447 }
38448
38449 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
38450         LDKChannelTransactionParameters this_ptr_conv;
38451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38452         this_ptr_conv.is_owned = false;
38453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38454         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
38455         return ret_conv;
38456 }
38457
38458 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) {
38459         LDKChannelTransactionParameters this_ptr_conv;
38460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38461         this_ptr_conv.is_owned = false;
38462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38463         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
38464 }
38465
38466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
38467         LDKChannelTransactionParameters this_ptr_conv;
38468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38469         this_ptr_conv.is_owned = false;
38470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38471         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
38472         return ret_conv;
38473 }
38474
38475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38476         LDKChannelTransactionParameters this_ptr_conv;
38477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38478         this_ptr_conv.is_owned = false;
38479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38480         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
38481 }
38482
38483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
38484         LDKChannelTransactionParameters this_ptr_conv;
38485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38486         this_ptr_conv.is_owned = false;
38487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38488         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
38489         int64_t ret_ref = 0;
38490         if ((uintptr_t)ret_var.inner > 4096) {
38491                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38492                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38494                 ret_ref = (uintptr_t)ret_var.inner;
38495                 if (ret_var.is_owned) {
38496                         ret_ref |= 1;
38497                 }
38498         }
38499         return ret_ref;
38500 }
38501
38502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38503         LDKChannelTransactionParameters this_ptr_conv;
38504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38505         this_ptr_conv.is_owned = false;
38506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38507         LDKCounterpartyChannelTransactionParameters val_conv;
38508         val_conv.inner = (void*)(val & (~1));
38509         val_conv.is_owned = (val & 1) || (val == 0);
38510         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38511         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
38512         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
38513 }
38514
38515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
38516         LDKChannelTransactionParameters this_ptr_conv;
38517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38518         this_ptr_conv.is_owned = false;
38519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38520         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
38521         int64_t ret_ref = 0;
38522         if ((uintptr_t)ret_var.inner > 4096) {
38523                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38524                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38526                 ret_ref = (uintptr_t)ret_var.inner;
38527                 if (ret_var.is_owned) {
38528                         ret_ref |= 1;
38529                 }
38530         }
38531         return ret_ref;
38532 }
38533
38534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38535         LDKChannelTransactionParameters this_ptr_conv;
38536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38537         this_ptr_conv.is_owned = false;
38538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38539         LDKOutPoint val_conv;
38540         val_conv.inner = (void*)(val & (~1));
38541         val_conv.is_owned = (val & 1) || (val == 0);
38542         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38543         val_conv = OutPoint_clone(&val_conv);
38544         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
38545 }
38546
38547 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
38548         LDKChannelTransactionParameters this_ptr_conv;
38549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38550         this_ptr_conv.is_owned = false;
38551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38552         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
38553         return ret_conv;
38554 }
38555
38556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
38557         LDKChannelTransactionParameters this_ptr_conv;
38558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38559         this_ptr_conv.is_owned = false;
38560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38561         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
38562         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
38563 }
38564
38565 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) {
38566         LDKChannelPublicKeys holder_pubkeys_arg_conv;
38567         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
38568         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
38569         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
38570         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
38571         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
38572         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
38573         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
38574         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
38575         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
38576         LDKOutPoint funding_outpoint_arg_conv;
38577         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
38578         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
38579         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
38580         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
38581         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
38582         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);
38583         int64_t ret_ref = 0;
38584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38587         ret_ref = (uintptr_t)ret_var.inner;
38588         if (ret_var.is_owned) {
38589                 ret_ref |= 1;
38590         }
38591         return ret_ref;
38592 }
38593
38594 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
38595         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
38596 int64_t ret_ref = 0;
38597 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38598 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38599 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38600 ret_ref = (uintptr_t)ret_var.inner;
38601 if (ret_var.is_owned) {
38602         ret_ref |= 1;
38603 }
38604         return ret_ref;
38605 }
38606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38607         LDKChannelTransactionParameters arg_conv;
38608         arg_conv.inner = (void*)(arg & (~1));
38609         arg_conv.is_owned = false;
38610         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38611         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
38612         return ret_conv;
38613 }
38614
38615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38616         LDKChannelTransactionParameters orig_conv;
38617         orig_conv.inner = (void*)(orig & (~1));
38618         orig_conv.is_owned = false;
38619         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38620         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
38621         int64_t ret_ref = 0;
38622         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38623         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38625         ret_ref = (uintptr_t)ret_var.inner;
38626         if (ret_var.is_owned) {
38627                 ret_ref |= 1;
38628         }
38629         return ret_ref;
38630 }
38631
38632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38633         LDKCounterpartyChannelTransactionParameters this_obj_conv;
38634         this_obj_conv.inner = (void*)(this_obj & (~1));
38635         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38637         CounterpartyChannelTransactionParameters_free(this_obj_conv);
38638 }
38639
38640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
38641         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
38642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38643         this_ptr_conv.is_owned = false;
38644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38645         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
38646         int64_t ret_ref = 0;
38647         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38648         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38650         ret_ref = (uintptr_t)ret_var.inner;
38651         if (ret_var.is_owned) {
38652                 ret_ref |= 1;
38653         }
38654         return ret_ref;
38655 }
38656
38657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38658         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
38659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38660         this_ptr_conv.is_owned = false;
38661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38662         LDKChannelPublicKeys val_conv;
38663         val_conv.inner = (void*)(val & (~1));
38664         val_conv.is_owned = (val & 1) || (val == 0);
38665         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38666         val_conv = ChannelPublicKeys_clone(&val_conv);
38667         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
38668 }
38669
38670 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
38671         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
38672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38673         this_ptr_conv.is_owned = false;
38674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38675         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
38676         return ret_conv;
38677 }
38678
38679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
38680         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
38681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38682         this_ptr_conv.is_owned = false;
38683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38684         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
38685 }
38686
38687 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) {
38688         LDKChannelPublicKeys pubkeys_arg_conv;
38689         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
38690         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
38691         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
38692         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
38693         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
38694         int64_t ret_ref = 0;
38695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38698         ret_ref = (uintptr_t)ret_var.inner;
38699         if (ret_var.is_owned) {
38700                 ret_ref |= 1;
38701         }
38702         return ret_ref;
38703 }
38704
38705 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
38706         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
38707 int64_t ret_ref = 0;
38708 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38709 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38710 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38711 ret_ref = (uintptr_t)ret_var.inner;
38712 if (ret_var.is_owned) {
38713         ret_ref |= 1;
38714 }
38715         return ret_ref;
38716 }
38717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38718         LDKCounterpartyChannelTransactionParameters arg_conv;
38719         arg_conv.inner = (void*)(arg & (~1));
38720         arg_conv.is_owned = false;
38721         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38722         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
38723         return ret_conv;
38724 }
38725
38726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38727         LDKCounterpartyChannelTransactionParameters orig_conv;
38728         orig_conv.inner = (void*)(orig & (~1));
38729         orig_conv.is_owned = false;
38730         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38731         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
38732         int64_t ret_ref = 0;
38733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38736         ret_ref = (uintptr_t)ret_var.inner;
38737         if (ret_var.is_owned) {
38738                 ret_ref |= 1;
38739         }
38740         return ret_ref;
38741 }
38742
38743 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
38744         LDKChannelTransactionParameters this_arg_conv;
38745         this_arg_conv.inner = (void*)(this_arg & (~1));
38746         this_arg_conv.is_owned = false;
38747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38748         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
38749         return ret_conv;
38750 }
38751
38752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
38753         LDKChannelTransactionParameters this_arg_conv;
38754         this_arg_conv.inner = (void*)(this_arg & (~1));
38755         this_arg_conv.is_owned = false;
38756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38757         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
38758         int64_t ret_ref = 0;
38759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38762         ret_ref = (uintptr_t)ret_var.inner;
38763         if (ret_var.is_owned) {
38764                 ret_ref |= 1;
38765         }
38766         return ret_ref;
38767 }
38768
38769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
38770         LDKChannelTransactionParameters this_arg_conv;
38771         this_arg_conv.inner = (void*)(this_arg & (~1));
38772         this_arg_conv.is_owned = false;
38773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38774         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
38775         int64_t ret_ref = 0;
38776         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38777         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38779         ret_ref = (uintptr_t)ret_var.inner;
38780         if (ret_var.is_owned) {
38781                 ret_ref |= 1;
38782         }
38783         return ret_ref;
38784 }
38785
38786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
38787         LDKCounterpartyChannelTransactionParameters obj_conv;
38788         obj_conv.inner = (void*)(obj & (~1));
38789         obj_conv.is_owned = false;
38790         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38791         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
38792         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38793         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38794         CVec_u8Z_free(ret_var);
38795         return ret_arr;
38796 }
38797
38798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38799         LDKu8slice ser_ref;
38800         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38801         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38802         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
38803         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
38804         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38805         return (int64_t)ret_conv;
38806 }
38807
38808 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
38809         LDKChannelTransactionParameters obj_conv;
38810         obj_conv.inner = (void*)(obj & (~1));
38811         obj_conv.is_owned = false;
38812         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38813         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
38814         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38815         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38816         CVec_u8Z_free(ret_var);
38817         return ret_arr;
38818 }
38819
38820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38821         LDKu8slice ser_ref;
38822         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38823         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38824         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
38825         *ret_conv = ChannelTransactionParameters_read(ser_ref);
38826         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38827         return (int64_t)ret_conv;
38828 }
38829
38830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38831         LDKDirectedChannelTransactionParameters this_obj_conv;
38832         this_obj_conv.inner = (void*)(this_obj & (~1));
38833         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38835         DirectedChannelTransactionParameters_free(this_obj_conv);
38836 }
38837
38838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
38839         LDKDirectedChannelTransactionParameters this_arg_conv;
38840         this_arg_conv.inner = (void*)(this_arg & (~1));
38841         this_arg_conv.is_owned = false;
38842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38843         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
38844         int64_t ret_ref = 0;
38845         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38846         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38848         ret_ref = (uintptr_t)ret_var.inner;
38849         if (ret_var.is_owned) {
38850                 ret_ref |= 1;
38851         }
38852         return ret_ref;
38853 }
38854
38855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
38856         LDKDirectedChannelTransactionParameters this_arg_conv;
38857         this_arg_conv.inner = (void*)(this_arg & (~1));
38858         this_arg_conv.is_owned = false;
38859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38860         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
38861         int64_t ret_ref = 0;
38862         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38863         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38865         ret_ref = (uintptr_t)ret_var.inner;
38866         if (ret_var.is_owned) {
38867                 ret_ref |= 1;
38868         }
38869         return ret_ref;
38870 }
38871
38872 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
38873         LDKDirectedChannelTransactionParameters this_arg_conv;
38874         this_arg_conv.inner = (void*)(this_arg & (~1));
38875         this_arg_conv.is_owned = false;
38876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38877         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
38878         return ret_conv;
38879 }
38880
38881 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
38882         LDKDirectedChannelTransactionParameters this_arg_conv;
38883         this_arg_conv.inner = (void*)(this_arg & (~1));
38884         this_arg_conv.is_owned = false;
38885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38886         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
38887         return ret_conv;
38888 }
38889
38890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
38891         LDKDirectedChannelTransactionParameters this_arg_conv;
38892         this_arg_conv.inner = (void*)(this_arg & (~1));
38893         this_arg_conv.is_owned = false;
38894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38895         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
38896         int64_t ret_ref = 0;
38897         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38898         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38900         ret_ref = (uintptr_t)ret_var.inner;
38901         if (ret_var.is_owned) {
38902                 ret_ref |= 1;
38903         }
38904         return ret_ref;
38905 }
38906
38907 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
38908         LDKDirectedChannelTransactionParameters this_arg_conv;
38909         this_arg_conv.inner = (void*)(this_arg & (~1));
38910         this_arg_conv.is_owned = false;
38911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38912         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
38913         return ret_conv;
38914 }
38915
38916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38917         LDKHolderCommitmentTransaction this_obj_conv;
38918         this_obj_conv.inner = (void*)(this_obj & (~1));
38919         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38921         HolderCommitmentTransaction_free(this_obj_conv);
38922 }
38923
38924 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
38925         LDKHolderCommitmentTransaction this_ptr_conv;
38926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38927         this_ptr_conv.is_owned = false;
38928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38929         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38930         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
38931         return ret_arr;
38932 }
38933
38934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38935         LDKHolderCommitmentTransaction this_ptr_conv;
38936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38937         this_ptr_conv.is_owned = false;
38938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38939         LDKSignature val_ref;
38940         CHECK((*env)->GetArrayLength(env, val) == 64);
38941         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38942         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
38943 }
38944
38945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
38946         LDKHolderCommitmentTransaction this_ptr_conv;
38947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38948         this_ptr_conv.is_owned = false;
38949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38950         LDKCVec_SignatureZ val_constr;
38951         val_constr.datalen = (*env)->GetArrayLength(env, val);
38952         if (val_constr.datalen > 0)
38953                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
38954         else
38955                 val_constr.data = NULL;
38956         for (size_t i = 0; i < val_constr.datalen; i++) {
38957                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
38958                 LDKSignature val_conv_8_ref;
38959                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
38960                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
38961                 val_constr.data[i] = val_conv_8_ref;
38962         }
38963         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
38964 }
38965
38966 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
38967         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
38968 int64_t ret_ref = 0;
38969 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38970 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38971 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38972 ret_ref = (uintptr_t)ret_var.inner;
38973 if (ret_var.is_owned) {
38974         ret_ref |= 1;
38975 }
38976         return ret_ref;
38977 }
38978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38979         LDKHolderCommitmentTransaction arg_conv;
38980         arg_conv.inner = (void*)(arg & (~1));
38981         arg_conv.is_owned = false;
38982         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38983         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
38984         return ret_conv;
38985 }
38986
38987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38988         LDKHolderCommitmentTransaction orig_conv;
38989         orig_conv.inner = (void*)(orig & (~1));
38990         orig_conv.is_owned = false;
38991         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38992         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
38993         int64_t ret_ref = 0;
38994         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38995         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38997         ret_ref = (uintptr_t)ret_var.inner;
38998         if (ret_var.is_owned) {
38999                 ret_ref |= 1;
39000         }
39001         return ret_ref;
39002 }
39003
39004 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
39005         LDKHolderCommitmentTransaction obj_conv;
39006         obj_conv.inner = (void*)(obj & (~1));
39007         obj_conv.is_owned = false;
39008         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39009         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
39010         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39011         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39012         CVec_u8Z_free(ret_var);
39013         return ret_arr;
39014 }
39015
39016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39017         LDKu8slice ser_ref;
39018         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39019         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39020         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
39021         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
39022         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39023         return (int64_t)ret_conv;
39024 }
39025
39026 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) {
39027         LDKCommitmentTransaction commitment_tx_conv;
39028         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
39029         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
39030         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
39031         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
39032         LDKSignature counterparty_sig_ref;
39033         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
39034         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
39035         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
39036         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
39037         if (counterparty_htlc_sigs_constr.datalen > 0)
39038                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
39039         else
39040                 counterparty_htlc_sigs_constr.data = NULL;
39041         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
39042                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
39043                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
39044                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
39045                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
39046                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
39047         }
39048         LDKPublicKey holder_funding_key_ref;
39049         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
39050         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
39051         LDKPublicKey counterparty_funding_key_ref;
39052         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
39053         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
39054         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
39055         int64_t ret_ref = 0;
39056         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39057         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39059         ret_ref = (uintptr_t)ret_var.inner;
39060         if (ret_var.is_owned) {
39061                 ret_ref |= 1;
39062         }
39063         return ret_ref;
39064 }
39065
39066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39067         LDKBuiltCommitmentTransaction this_obj_conv;
39068         this_obj_conv.inner = (void*)(this_obj & (~1));
39069         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39071         BuiltCommitmentTransaction_free(this_obj_conv);
39072 }
39073
39074 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
39075         LDKBuiltCommitmentTransaction this_ptr_conv;
39076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39077         this_ptr_conv.is_owned = false;
39078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39079         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
39080         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39081         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39082         Transaction_free(ret_var);
39083         return ret_arr;
39084 }
39085
39086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39087         LDKBuiltCommitmentTransaction this_ptr_conv;
39088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39089         this_ptr_conv.is_owned = false;
39090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39091         LDKTransaction val_ref;
39092         val_ref.datalen = (*env)->GetArrayLength(env, val);
39093         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
39094         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
39095         val_ref.data_is_owned = true;
39096         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
39097 }
39098
39099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
39100         LDKBuiltCommitmentTransaction this_ptr_conv;
39101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39102         this_ptr_conv.is_owned = false;
39103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39104         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39105         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
39106         return ret_arr;
39107 }
39108
39109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39110         LDKBuiltCommitmentTransaction this_ptr_conv;
39111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39112         this_ptr_conv.is_owned = false;
39113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39114         LDKThirtyTwoBytes val_ref;
39115         CHECK((*env)->GetArrayLength(env, val) == 32);
39116         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39117         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
39118 }
39119
39120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
39121         LDKTransaction transaction_arg_ref;
39122         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
39123         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
39124         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
39125         transaction_arg_ref.data_is_owned = true;
39126         LDKThirtyTwoBytes txid_arg_ref;
39127         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
39128         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
39129         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
39130         int64_t ret_ref = 0;
39131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39134         ret_ref = (uintptr_t)ret_var.inner;
39135         if (ret_var.is_owned) {
39136                 ret_ref |= 1;
39137         }
39138         return ret_ref;
39139 }
39140
39141 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
39142         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
39143 int64_t ret_ref = 0;
39144 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39145 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39146 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39147 ret_ref = (uintptr_t)ret_var.inner;
39148 if (ret_var.is_owned) {
39149         ret_ref |= 1;
39150 }
39151         return ret_ref;
39152 }
39153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39154         LDKBuiltCommitmentTransaction arg_conv;
39155         arg_conv.inner = (void*)(arg & (~1));
39156         arg_conv.is_owned = false;
39157         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39158         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
39159         return ret_conv;
39160 }
39161
39162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39163         LDKBuiltCommitmentTransaction orig_conv;
39164         orig_conv.inner = (void*)(orig & (~1));
39165         orig_conv.is_owned = false;
39166         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39167         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
39168         int64_t ret_ref = 0;
39169         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39170         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39172         ret_ref = (uintptr_t)ret_var.inner;
39173         if (ret_var.is_owned) {
39174                 ret_ref |= 1;
39175         }
39176         return ret_ref;
39177 }
39178
39179 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
39180         LDKBuiltCommitmentTransaction obj_conv;
39181         obj_conv.inner = (void*)(obj & (~1));
39182         obj_conv.is_owned = false;
39183         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39184         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
39185         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39186         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39187         CVec_u8Z_free(ret_var);
39188         return ret_arr;
39189 }
39190
39191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39192         LDKu8slice ser_ref;
39193         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39194         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39195         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
39196         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
39197         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39198         return (int64_t)ret_conv;
39199 }
39200
39201 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) {
39202         LDKBuiltCommitmentTransaction this_arg_conv;
39203         this_arg_conv.inner = (void*)(this_arg & (~1));
39204         this_arg_conv.is_owned = false;
39205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39206         LDKu8slice funding_redeemscript_ref;
39207         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
39208         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
39209         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39210         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
39211         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
39212         return ret_arr;
39213 }
39214
39215 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) {
39216         LDKBuiltCommitmentTransaction this_arg_conv;
39217         this_arg_conv.inner = (void*)(this_arg & (~1));
39218         this_arg_conv.is_owned = false;
39219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39220         unsigned char funding_key_arr[32];
39221         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
39222         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
39223         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
39224         LDKu8slice funding_redeemscript_ref;
39225         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
39226         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
39227         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39228         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
39229         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
39230         return ret_arr;
39231 }
39232
39233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39234         LDKClosingTransaction this_obj_conv;
39235         this_obj_conv.inner = (void*)(this_obj & (~1));
39236         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39238         ClosingTransaction_free(this_obj_conv);
39239 }
39240
39241 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
39242         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
39243 int64_t ret_ref = 0;
39244 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39245 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39246 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39247 ret_ref = (uintptr_t)ret_var.inner;
39248 if (ret_var.is_owned) {
39249         ret_ref |= 1;
39250 }
39251         return ret_ref;
39252 }
39253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39254         LDKClosingTransaction arg_conv;
39255         arg_conv.inner = (void*)(arg & (~1));
39256         arg_conv.is_owned = false;
39257         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39258         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
39259         return ret_conv;
39260 }
39261
39262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39263         LDKClosingTransaction orig_conv;
39264         orig_conv.inner = (void*)(orig & (~1));
39265         orig_conv.is_owned = false;
39266         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39267         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
39268         int64_t ret_ref = 0;
39269         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39270         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39272         ret_ref = (uintptr_t)ret_var.inner;
39273         if (ret_var.is_owned) {
39274                 ret_ref |= 1;
39275         }
39276         return ret_ref;
39277 }
39278
39279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
39280         LDKClosingTransaction o_conv;
39281         o_conv.inner = (void*)(o & (~1));
39282         o_conv.is_owned = false;
39283         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39284         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
39285         return ret_conv;
39286 }
39287
39288 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) {
39289         LDKCVec_u8Z to_holder_script_ref;
39290         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
39291         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
39292         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
39293         LDKCVec_u8Z to_counterparty_script_ref;
39294         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
39295         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
39296         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
39297         LDKOutPoint funding_outpoint_conv;
39298         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
39299         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
39300         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
39301         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
39302         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
39303         int64_t ret_ref = 0;
39304         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39305         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39307         ret_ref = (uintptr_t)ret_var.inner;
39308         if (ret_var.is_owned) {
39309                 ret_ref |= 1;
39310         }
39311         return ret_ref;
39312 }
39313
39314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
39315         LDKClosingTransaction this_arg_conv;
39316         this_arg_conv.inner = (void*)(this_arg & (~1));
39317         this_arg_conv.is_owned = false;
39318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39319         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
39320         int64_t ret_ref = 0;
39321         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39322         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39324         ret_ref = (uintptr_t)ret_var.inner;
39325         if (ret_var.is_owned) {
39326                 ret_ref |= 1;
39327         }
39328         return ret_ref;
39329 }
39330
39331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
39332         LDKClosingTransaction this_arg_conv;
39333         this_arg_conv.inner = (void*)(this_arg & (~1));
39334         this_arg_conv.is_owned = false;
39335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39336         LDKOutPoint funding_outpoint_conv;
39337         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
39338         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
39339         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
39340         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
39341         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
39342         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
39343         return (int64_t)ret_conv;
39344 }
39345
39346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39347         LDKClosingTransaction this_arg_conv;
39348         this_arg_conv.inner = (void*)(this_arg & (~1));
39349         this_arg_conv.is_owned = false;
39350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39351         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
39352         return ret_conv;
39353 }
39354
39355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39356         LDKClosingTransaction this_arg_conv;
39357         this_arg_conv.inner = (void*)(this_arg & (~1));
39358         this_arg_conv.is_owned = false;
39359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39360         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
39361         return ret_conv;
39362 }
39363
39364 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
39365         LDKClosingTransaction this_arg_conv;
39366         this_arg_conv.inner = (void*)(this_arg & (~1));
39367         this_arg_conv.is_owned = false;
39368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39369         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
39370         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39371         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39372         return ret_arr;
39373 }
39374
39375 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
39376         LDKClosingTransaction this_arg_conv;
39377         this_arg_conv.inner = (void*)(this_arg & (~1));
39378         this_arg_conv.is_owned = false;
39379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39380         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
39381         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39382         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39383         return ret_arr;
39384 }
39385
39386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39387         LDKTrustedClosingTransaction this_obj_conv;
39388         this_obj_conv.inner = (void*)(this_obj & (~1));
39389         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39391         TrustedClosingTransaction_free(this_obj_conv);
39392 }
39393
39394 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
39395         LDKTrustedClosingTransaction this_arg_conv;
39396         this_arg_conv.inner = (void*)(this_arg & (~1));
39397         this_arg_conv.is_owned = false;
39398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39399         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
39400         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39401         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39402         Transaction_free(ret_var);
39403         return ret_arr;
39404 }
39405
39406 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) {
39407         LDKTrustedClosingTransaction this_arg_conv;
39408         this_arg_conv.inner = (void*)(this_arg & (~1));
39409         this_arg_conv.is_owned = false;
39410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39411         LDKu8slice funding_redeemscript_ref;
39412         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
39413         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
39414         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39415         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
39416         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
39417         return ret_arr;
39418 }
39419
39420 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) {
39421         LDKTrustedClosingTransaction this_arg_conv;
39422         this_arg_conv.inner = (void*)(this_arg & (~1));
39423         this_arg_conv.is_owned = false;
39424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39425         unsigned char funding_key_arr[32];
39426         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
39427         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
39428         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
39429         LDKu8slice funding_redeemscript_ref;
39430         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
39431         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
39432         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39433         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
39434         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
39435         return ret_arr;
39436 }
39437
39438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39439         LDKCommitmentTransaction this_obj_conv;
39440         this_obj_conv.inner = (void*)(this_obj & (~1));
39441         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39443         CommitmentTransaction_free(this_obj_conv);
39444 }
39445
39446 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
39447         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
39448 int64_t ret_ref = 0;
39449 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39450 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39451 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39452 ret_ref = (uintptr_t)ret_var.inner;
39453 if (ret_var.is_owned) {
39454         ret_ref |= 1;
39455 }
39456         return ret_ref;
39457 }
39458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39459         LDKCommitmentTransaction arg_conv;
39460         arg_conv.inner = (void*)(arg & (~1));
39461         arg_conv.is_owned = false;
39462         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39463         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
39464         return ret_conv;
39465 }
39466
39467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39468         LDKCommitmentTransaction orig_conv;
39469         orig_conv.inner = (void*)(orig & (~1));
39470         orig_conv.is_owned = false;
39471         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39472         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
39473         int64_t ret_ref = 0;
39474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39477         ret_ref = (uintptr_t)ret_var.inner;
39478         if (ret_var.is_owned) {
39479                 ret_ref |= 1;
39480         }
39481         return ret_ref;
39482 }
39483
39484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
39485         LDKCommitmentTransaction obj_conv;
39486         obj_conv.inner = (void*)(obj & (~1));
39487         obj_conv.is_owned = false;
39488         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39489         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
39490         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39491         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39492         CVec_u8Z_free(ret_var);
39493         return ret_arr;
39494 }
39495
39496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39497         LDKu8slice ser_ref;
39498         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39499         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39500         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
39501         *ret_conv = CommitmentTransaction_read(ser_ref);
39502         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39503         return (int64_t)ret_conv;
39504 }
39505
39506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
39507         LDKCommitmentTransaction this_arg_conv;
39508         this_arg_conv.inner = (void*)(this_arg & (~1));
39509         this_arg_conv.is_owned = false;
39510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39511         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
39512         return ret_conv;
39513 }
39514
39515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39516         LDKCommitmentTransaction this_arg_conv;
39517         this_arg_conv.inner = (void*)(this_arg & (~1));
39518         this_arg_conv.is_owned = false;
39519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39520         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
39521         return ret_conv;
39522 }
39523
39524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39525         LDKCommitmentTransaction this_arg_conv;
39526         this_arg_conv.inner = (void*)(this_arg & (~1));
39527         this_arg_conv.is_owned = false;
39528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39529         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
39530         return ret_conv;
39531 }
39532
39533 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
39534         LDKCommitmentTransaction this_arg_conv;
39535         this_arg_conv.inner = (void*)(this_arg & (~1));
39536         this_arg_conv.is_owned = false;
39537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39538         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
39539         return ret_conv;
39540 }
39541
39542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
39543         LDKCommitmentTransaction this_arg_conv;
39544         this_arg_conv.inner = (void*)(this_arg & (~1));
39545         this_arg_conv.is_owned = false;
39546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39547         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
39548         int64_t ret_ref = 0;
39549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39552         ret_ref = (uintptr_t)ret_var.inner;
39553         if (ret_var.is_owned) {
39554                 ret_ref |= 1;
39555         }
39556         return ret_ref;
39557 }
39558
39559 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) {
39560         LDKCommitmentTransaction this_arg_conv;
39561         this_arg_conv.inner = (void*)(this_arg & (~1));
39562         this_arg_conv.is_owned = false;
39563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39564         LDKDirectedChannelTransactionParameters channel_parameters_conv;
39565         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
39566         channel_parameters_conv.is_owned = false;
39567         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
39568         LDKChannelPublicKeys broadcaster_keys_conv;
39569         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
39570         broadcaster_keys_conv.is_owned = false;
39571         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
39572         LDKChannelPublicKeys countersignatory_keys_conv;
39573         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
39574         countersignatory_keys_conv.is_owned = false;
39575         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
39576         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
39577         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
39578         return (int64_t)ret_conv;
39579 }
39580
39581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39582         LDKTrustedCommitmentTransaction this_obj_conv;
39583         this_obj_conv.inner = (void*)(this_obj & (~1));
39584         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39586         TrustedCommitmentTransaction_free(this_obj_conv);
39587 }
39588
39589 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
39590         LDKTrustedCommitmentTransaction this_arg_conv;
39591         this_arg_conv.inner = (void*)(this_arg & (~1));
39592         this_arg_conv.is_owned = false;
39593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39594         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39595         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
39596         return ret_arr;
39597 }
39598
39599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
39600         LDKTrustedCommitmentTransaction this_arg_conv;
39601         this_arg_conv.inner = (void*)(this_arg & (~1));
39602         this_arg_conv.is_owned = false;
39603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39604         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
39605         int64_t ret_ref = 0;
39606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39609         ret_ref = (uintptr_t)ret_var.inner;
39610         if (ret_var.is_owned) {
39611                 ret_ref |= 1;
39612         }
39613         return ret_ref;
39614 }
39615
39616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
39617         LDKTrustedCommitmentTransaction this_arg_conv;
39618         this_arg_conv.inner = (void*)(this_arg & (~1));
39619         this_arg_conv.is_owned = false;
39620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39621         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
39622         int64_t ret_ref = 0;
39623         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39624         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39626         ret_ref = (uintptr_t)ret_var.inner;
39627         if (ret_var.is_owned) {
39628                 ret_ref |= 1;
39629         }
39630         return ret_ref;
39631 }
39632
39633 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
39634         LDKTrustedCommitmentTransaction this_arg_conv;
39635         this_arg_conv.inner = (void*)(this_arg & (~1));
39636         this_arg_conv.is_owned = false;
39637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39638         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
39639         return ret_conv;
39640 }
39641
39642 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) {
39643         LDKTrustedCommitmentTransaction this_arg_conv;
39644         this_arg_conv.inner = (void*)(this_arg & (~1));
39645         this_arg_conv.is_owned = false;
39646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39647         unsigned char htlc_base_key_arr[32];
39648         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
39649         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
39650         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
39651         LDKDirectedChannelTransactionParameters channel_parameters_conv;
39652         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
39653         channel_parameters_conv.is_owned = false;
39654         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
39655         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
39656         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
39657         return (int64_t)ret_conv;
39658 }
39659
39660 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) {
39661         LDKPublicKey broadcaster_payment_basepoint_ref;
39662         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
39663         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
39664         LDKPublicKey countersignatory_payment_basepoint_ref;
39665         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
39666         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
39667         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
39668         return ret_conv;
39669 }
39670
39671 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39672         LDKInitFeatures a_conv;
39673         a_conv.inner = (void*)(a & (~1));
39674         a_conv.is_owned = false;
39675         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39676         LDKInitFeatures b_conv;
39677         b_conv.inner = (void*)(b & (~1));
39678         b_conv.is_owned = false;
39679         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39680         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
39681         return ret_conv;
39682 }
39683
39684 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39685         LDKNodeFeatures a_conv;
39686         a_conv.inner = (void*)(a & (~1));
39687         a_conv.is_owned = false;
39688         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39689         LDKNodeFeatures b_conv;
39690         b_conv.inner = (void*)(b & (~1));
39691         b_conv.is_owned = false;
39692         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39693         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
39694         return ret_conv;
39695 }
39696
39697 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39698         LDKChannelFeatures a_conv;
39699         a_conv.inner = (void*)(a & (~1));
39700         a_conv.is_owned = false;
39701         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39702         LDKChannelFeatures b_conv;
39703         b_conv.inner = (void*)(b & (~1));
39704         b_conv.is_owned = false;
39705         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39706         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
39707         return ret_conv;
39708 }
39709
39710 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39711         LDKInvoiceFeatures a_conv;
39712         a_conv.inner = (void*)(a & (~1));
39713         a_conv.is_owned = false;
39714         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39715         LDKInvoiceFeatures b_conv;
39716         b_conv.inner = (void*)(b & (~1));
39717         b_conv.is_owned = false;
39718         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39719         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
39720         return ret_conv;
39721 }
39722
39723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39724         LDKChannelTypeFeatures a_conv;
39725         a_conv.inner = (void*)(a & (~1));
39726         a_conv.is_owned = false;
39727         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39728         LDKChannelTypeFeatures b_conv;
39729         b_conv.inner = (void*)(b & (~1));
39730         b_conv.is_owned = false;
39731         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39732         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
39733         return ret_conv;
39734 }
39735
39736 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
39737         LDKInitFeatures ret_var = InitFeatures_clone(arg);
39738 int64_t ret_ref = 0;
39739 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39740 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39741 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39742 ret_ref = (uintptr_t)ret_var.inner;
39743 if (ret_var.is_owned) {
39744         ret_ref |= 1;
39745 }
39746         return ret_ref;
39747 }
39748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39749         LDKInitFeatures arg_conv;
39750         arg_conv.inner = (void*)(arg & (~1));
39751         arg_conv.is_owned = false;
39752         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39753         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
39754         return ret_conv;
39755 }
39756
39757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39758         LDKInitFeatures orig_conv;
39759         orig_conv.inner = (void*)(orig & (~1));
39760         orig_conv.is_owned = false;
39761         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39762         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
39763         int64_t ret_ref = 0;
39764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39767         ret_ref = (uintptr_t)ret_var.inner;
39768         if (ret_var.is_owned) {
39769                 ret_ref |= 1;
39770         }
39771         return ret_ref;
39772 }
39773
39774 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
39775         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
39776 int64_t ret_ref = 0;
39777 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39778 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39779 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39780 ret_ref = (uintptr_t)ret_var.inner;
39781 if (ret_var.is_owned) {
39782         ret_ref |= 1;
39783 }
39784         return ret_ref;
39785 }
39786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39787         LDKNodeFeatures arg_conv;
39788         arg_conv.inner = (void*)(arg & (~1));
39789         arg_conv.is_owned = false;
39790         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39791         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
39792         return ret_conv;
39793 }
39794
39795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39796         LDKNodeFeatures orig_conv;
39797         orig_conv.inner = (void*)(orig & (~1));
39798         orig_conv.is_owned = false;
39799         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39800         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
39801         int64_t ret_ref = 0;
39802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39805         ret_ref = (uintptr_t)ret_var.inner;
39806         if (ret_var.is_owned) {
39807                 ret_ref |= 1;
39808         }
39809         return ret_ref;
39810 }
39811
39812 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
39813         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
39814 int64_t ret_ref = 0;
39815 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39816 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39817 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39818 ret_ref = (uintptr_t)ret_var.inner;
39819 if (ret_var.is_owned) {
39820         ret_ref |= 1;
39821 }
39822         return ret_ref;
39823 }
39824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39825         LDKChannelFeatures arg_conv;
39826         arg_conv.inner = (void*)(arg & (~1));
39827         arg_conv.is_owned = false;
39828         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39829         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
39830         return ret_conv;
39831 }
39832
39833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39834         LDKChannelFeatures orig_conv;
39835         orig_conv.inner = (void*)(orig & (~1));
39836         orig_conv.is_owned = false;
39837         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39838         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
39839         int64_t ret_ref = 0;
39840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39843         ret_ref = (uintptr_t)ret_var.inner;
39844         if (ret_var.is_owned) {
39845                 ret_ref |= 1;
39846         }
39847         return ret_ref;
39848 }
39849
39850 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
39851         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
39852 int64_t ret_ref = 0;
39853 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39854 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39855 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39856 ret_ref = (uintptr_t)ret_var.inner;
39857 if (ret_var.is_owned) {
39858         ret_ref |= 1;
39859 }
39860         return ret_ref;
39861 }
39862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39863         LDKInvoiceFeatures arg_conv;
39864         arg_conv.inner = (void*)(arg & (~1));
39865         arg_conv.is_owned = false;
39866         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39867         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
39868         return ret_conv;
39869 }
39870
39871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39872         LDKInvoiceFeatures orig_conv;
39873         orig_conv.inner = (void*)(orig & (~1));
39874         orig_conv.is_owned = false;
39875         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39876         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
39877         int64_t ret_ref = 0;
39878         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39879         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39881         ret_ref = (uintptr_t)ret_var.inner;
39882         if (ret_var.is_owned) {
39883                 ret_ref |= 1;
39884         }
39885         return ret_ref;
39886 }
39887
39888 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
39889         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
39890 int64_t ret_ref = 0;
39891 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39892 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39893 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39894 ret_ref = (uintptr_t)ret_var.inner;
39895 if (ret_var.is_owned) {
39896         ret_ref |= 1;
39897 }
39898         return ret_ref;
39899 }
39900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39901         LDKChannelTypeFeatures arg_conv;
39902         arg_conv.inner = (void*)(arg & (~1));
39903         arg_conv.is_owned = false;
39904         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39905         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
39906         return ret_conv;
39907 }
39908
39909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39910         LDKChannelTypeFeatures orig_conv;
39911         orig_conv.inner = (void*)(orig & (~1));
39912         orig_conv.is_owned = false;
39913         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39914         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
39915         int64_t ret_ref = 0;
39916         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39917         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39919         ret_ref = (uintptr_t)ret_var.inner;
39920         if (ret_var.is_owned) {
39921                 ret_ref |= 1;
39922         }
39923         return ret_ref;
39924 }
39925
39926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39927         LDKInitFeatures this_obj_conv;
39928         this_obj_conv.inner = (void*)(this_obj & (~1));
39929         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39931         InitFeatures_free(this_obj_conv);
39932 }
39933
39934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39935         LDKNodeFeatures this_obj_conv;
39936         this_obj_conv.inner = (void*)(this_obj & (~1));
39937         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39939         NodeFeatures_free(this_obj_conv);
39940 }
39941
39942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39943         LDKChannelFeatures this_obj_conv;
39944         this_obj_conv.inner = (void*)(this_obj & (~1));
39945         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39947         ChannelFeatures_free(this_obj_conv);
39948 }
39949
39950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39951         LDKInvoiceFeatures this_obj_conv;
39952         this_obj_conv.inner = (void*)(this_obj & (~1));
39953         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39955         InvoiceFeatures_free(this_obj_conv);
39956 }
39957
39958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39959         LDKChannelTypeFeatures this_obj_conv;
39960         this_obj_conv.inner = (void*)(this_obj & (~1));
39961         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39963         ChannelTypeFeatures_free(this_obj_conv);
39964 }
39965
39966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
39967         LDKInitFeatures ret_var = InitFeatures_empty();
39968         int64_t ret_ref = 0;
39969         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39970         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39972         ret_ref = (uintptr_t)ret_var.inner;
39973         if (ret_var.is_owned) {
39974                 ret_ref |= 1;
39975         }
39976         return ret_ref;
39977 }
39978
39979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
39980         LDKInitFeatures ret_var = InitFeatures_known();
39981         int64_t ret_ref = 0;
39982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39985         ret_ref = (uintptr_t)ret_var.inner;
39986         if (ret_var.is_owned) {
39987                 ret_ref |= 1;
39988         }
39989         return ret_ref;
39990 }
39991
39992 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39993         LDKInitFeatures this_arg_conv;
39994         this_arg_conv.inner = (void*)(this_arg & (~1));
39995         this_arg_conv.is_owned = false;
39996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39997         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
39998         return ret_conv;
39999 }
40000
40001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
40002         LDKNodeFeatures ret_var = NodeFeatures_empty();
40003         int64_t ret_ref = 0;
40004         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40005         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40007         ret_ref = (uintptr_t)ret_var.inner;
40008         if (ret_var.is_owned) {
40009                 ret_ref |= 1;
40010         }
40011         return ret_ref;
40012 }
40013
40014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
40015         LDKNodeFeatures ret_var = NodeFeatures_known();
40016         int64_t ret_ref = 0;
40017         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40018         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40020         ret_ref = (uintptr_t)ret_var.inner;
40021         if (ret_var.is_owned) {
40022                 ret_ref |= 1;
40023         }
40024         return ret_ref;
40025 }
40026
40027 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40028         LDKNodeFeatures this_arg_conv;
40029         this_arg_conv.inner = (void*)(this_arg & (~1));
40030         this_arg_conv.is_owned = false;
40031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40032         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
40033         return ret_conv;
40034 }
40035
40036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
40037         LDKChannelFeatures ret_var = ChannelFeatures_empty();
40038         int64_t ret_ref = 0;
40039         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40040         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40042         ret_ref = (uintptr_t)ret_var.inner;
40043         if (ret_var.is_owned) {
40044                 ret_ref |= 1;
40045         }
40046         return ret_ref;
40047 }
40048
40049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
40050         LDKChannelFeatures ret_var = ChannelFeatures_known();
40051         int64_t ret_ref = 0;
40052         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40053         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40055         ret_ref = (uintptr_t)ret_var.inner;
40056         if (ret_var.is_owned) {
40057                 ret_ref |= 1;
40058         }
40059         return ret_ref;
40060 }
40061
40062 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40063         LDKChannelFeatures this_arg_conv;
40064         this_arg_conv.inner = (void*)(this_arg & (~1));
40065         this_arg_conv.is_owned = false;
40066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40067         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
40068         return ret_conv;
40069 }
40070
40071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
40072         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
40073         int64_t ret_ref = 0;
40074         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40075         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40077         ret_ref = (uintptr_t)ret_var.inner;
40078         if (ret_var.is_owned) {
40079                 ret_ref |= 1;
40080         }
40081         return ret_ref;
40082 }
40083
40084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
40085         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
40086         int64_t ret_ref = 0;
40087         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40088         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40090         ret_ref = (uintptr_t)ret_var.inner;
40091         if (ret_var.is_owned) {
40092                 ret_ref |= 1;
40093         }
40094         return ret_ref;
40095 }
40096
40097 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40098         LDKInvoiceFeatures this_arg_conv;
40099         this_arg_conv.inner = (void*)(this_arg & (~1));
40100         this_arg_conv.is_owned = false;
40101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40102         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
40103         return ret_conv;
40104 }
40105
40106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
40107         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
40108         int64_t ret_ref = 0;
40109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40112         ret_ref = (uintptr_t)ret_var.inner;
40113         if (ret_var.is_owned) {
40114                 ret_ref |= 1;
40115         }
40116         return ret_ref;
40117 }
40118
40119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
40120         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
40121         int64_t ret_ref = 0;
40122         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40123         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40125         ret_ref = (uintptr_t)ret_var.inner;
40126         if (ret_var.is_owned) {
40127                 ret_ref |= 1;
40128         }
40129         return ret_ref;
40130 }
40131
40132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40133         LDKChannelTypeFeatures this_arg_conv;
40134         this_arg_conv.inner = (void*)(this_arg & (~1));
40135         this_arg_conv.is_owned = false;
40136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40137         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
40138         return ret_conv;
40139 }
40140
40141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40142         LDKInitFeatures obj_conv;
40143         obj_conv.inner = (void*)(obj & (~1));
40144         obj_conv.is_owned = false;
40145         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40146         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
40147         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40148         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40149         CVec_u8Z_free(ret_var);
40150         return ret_arr;
40151 }
40152
40153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40154         LDKu8slice ser_ref;
40155         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40156         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40157         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
40158         *ret_conv = InitFeatures_read(ser_ref);
40159         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40160         return (int64_t)ret_conv;
40161 }
40162
40163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40164         LDKChannelFeatures obj_conv;
40165         obj_conv.inner = (void*)(obj & (~1));
40166         obj_conv.is_owned = false;
40167         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40168         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
40169         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40170         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40171         CVec_u8Z_free(ret_var);
40172         return ret_arr;
40173 }
40174
40175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40176         LDKu8slice ser_ref;
40177         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40178         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40179         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
40180         *ret_conv = ChannelFeatures_read(ser_ref);
40181         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40182         return (int64_t)ret_conv;
40183 }
40184
40185 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40186         LDKNodeFeatures obj_conv;
40187         obj_conv.inner = (void*)(obj & (~1));
40188         obj_conv.is_owned = false;
40189         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40190         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
40191         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40192         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40193         CVec_u8Z_free(ret_var);
40194         return ret_arr;
40195 }
40196
40197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40198         LDKu8slice ser_ref;
40199         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40200         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40201         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
40202         *ret_conv = NodeFeatures_read(ser_ref);
40203         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40204         return (int64_t)ret_conv;
40205 }
40206
40207 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40208         LDKInvoiceFeatures obj_conv;
40209         obj_conv.inner = (void*)(obj & (~1));
40210         obj_conv.is_owned = false;
40211         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40212         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
40213         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40214         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40215         CVec_u8Z_free(ret_var);
40216         return ret_arr;
40217 }
40218
40219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40220         LDKu8slice ser_ref;
40221         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40222         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40223         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
40224         *ret_conv = InvoiceFeatures_read(ser_ref);
40225         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40226         return (int64_t)ret_conv;
40227 }
40228
40229 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40230         LDKChannelTypeFeatures obj_conv;
40231         obj_conv.inner = (void*)(obj & (~1));
40232         obj_conv.is_owned = false;
40233         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40234         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
40235         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40236         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40237         CVec_u8Z_free(ret_var);
40238         return ret_arr;
40239 }
40240
40241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40242         LDKu8slice ser_ref;
40243         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40244         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40245         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
40246         *ret_conv = ChannelTypeFeatures_read(ser_ref);
40247         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40248         return (int64_t)ret_conv;
40249 }
40250
40251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40252         LDKInitFeatures this_arg_conv;
40253         this_arg_conv.inner = (void*)(this_arg & (~1));
40254         this_arg_conv.is_owned = false;
40255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40256         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
40257 }
40258
40259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40260         LDKInitFeatures this_arg_conv;
40261         this_arg_conv.inner = (void*)(this_arg & (~1));
40262         this_arg_conv.is_owned = false;
40263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40264         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
40265 }
40266
40267 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
40268         LDKInitFeatures this_arg_conv;
40269         this_arg_conv.inner = (void*)(this_arg & (~1));
40270         this_arg_conv.is_owned = false;
40271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40272         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
40273         return ret_conv;
40274 }
40275
40276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40277         LDKNodeFeatures this_arg_conv;
40278         this_arg_conv.inner = (void*)(this_arg & (~1));
40279         this_arg_conv.is_owned = false;
40280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40281         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
40282 }
40283
40284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40285         LDKNodeFeatures this_arg_conv;
40286         this_arg_conv.inner = (void*)(this_arg & (~1));
40287         this_arg_conv.is_owned = false;
40288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40289         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
40290 }
40291
40292 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
40293         LDKNodeFeatures this_arg_conv;
40294         this_arg_conv.inner = (void*)(this_arg & (~1));
40295         this_arg_conv.is_owned = false;
40296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40297         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
40298         return ret_conv;
40299 }
40300
40301 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
40302         LDKInitFeatures this_arg_conv;
40303         this_arg_conv.inner = (void*)(this_arg & (~1));
40304         this_arg_conv.is_owned = false;
40305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40306         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
40307         return ret_conv;
40308 }
40309
40310 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
40311         LDKNodeFeatures this_arg_conv;
40312         this_arg_conv.inner = (void*)(this_arg & (~1));
40313         this_arg_conv.is_owned = false;
40314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40315         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
40316         return ret_conv;
40317 }
40318
40319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40320         LDKInitFeatures this_arg_conv;
40321         this_arg_conv.inner = (void*)(this_arg & (~1));
40322         this_arg_conv.is_owned = false;
40323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40324         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
40325 }
40326
40327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40328         LDKInitFeatures this_arg_conv;
40329         this_arg_conv.inner = (void*)(this_arg & (~1));
40330         this_arg_conv.is_owned = false;
40331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40332         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
40333 }
40334
40335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
40336         LDKInitFeatures this_arg_conv;
40337         this_arg_conv.inner = (void*)(this_arg & (~1));
40338         this_arg_conv.is_owned = false;
40339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40340         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
40341         return ret_conv;
40342 }
40343
40344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40345         LDKInitFeatures this_arg_conv;
40346         this_arg_conv.inner = (void*)(this_arg & (~1));
40347         this_arg_conv.is_owned = false;
40348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40349         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
40350 }
40351
40352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40353         LDKInitFeatures this_arg_conv;
40354         this_arg_conv.inner = (void*)(this_arg & (~1));
40355         this_arg_conv.is_owned = false;
40356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40357         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
40358 }
40359
40360 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40361         LDKInitFeatures this_arg_conv;
40362         this_arg_conv.inner = (void*)(this_arg & (~1));
40363         this_arg_conv.is_owned = false;
40364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40365         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
40366         return ret_conv;
40367 }
40368
40369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40370         LDKNodeFeatures this_arg_conv;
40371         this_arg_conv.inner = (void*)(this_arg & (~1));
40372         this_arg_conv.is_owned = false;
40373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40374         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
40375 }
40376
40377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40378         LDKNodeFeatures this_arg_conv;
40379         this_arg_conv.inner = (void*)(this_arg & (~1));
40380         this_arg_conv.is_owned = false;
40381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40382         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
40383 }
40384
40385 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40386         LDKNodeFeatures this_arg_conv;
40387         this_arg_conv.inner = (void*)(this_arg & (~1));
40388         this_arg_conv.is_owned = false;
40389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40390         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
40391         return ret_conv;
40392 }
40393
40394 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40395         LDKInitFeatures this_arg_conv;
40396         this_arg_conv.inner = (void*)(this_arg & (~1));
40397         this_arg_conv.is_owned = false;
40398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40399         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
40400         return ret_conv;
40401 }
40402
40403 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40404         LDKNodeFeatures this_arg_conv;
40405         this_arg_conv.inner = (void*)(this_arg & (~1));
40406         this_arg_conv.is_owned = false;
40407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40408         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
40409         return ret_conv;
40410 }
40411
40412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40413         LDKInitFeatures this_arg_conv;
40414         this_arg_conv.inner = (void*)(this_arg & (~1));
40415         this_arg_conv.is_owned = false;
40416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40417         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
40418 }
40419
40420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40421         LDKInitFeatures this_arg_conv;
40422         this_arg_conv.inner = (void*)(this_arg & (~1));
40423         this_arg_conv.is_owned = false;
40424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40425         InitFeatures_set_gossip_queries_required(&this_arg_conv);
40426 }
40427
40428 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
40429         LDKInitFeatures this_arg_conv;
40430         this_arg_conv.inner = (void*)(this_arg & (~1));
40431         this_arg_conv.is_owned = false;
40432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40433         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
40434         return ret_conv;
40435 }
40436
40437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40438         LDKNodeFeatures this_arg_conv;
40439         this_arg_conv.inner = (void*)(this_arg & (~1));
40440         this_arg_conv.is_owned = false;
40441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40442         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
40443 }
40444
40445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40446         LDKNodeFeatures this_arg_conv;
40447         this_arg_conv.inner = (void*)(this_arg & (~1));
40448         this_arg_conv.is_owned = false;
40449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40450         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
40451 }
40452
40453 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
40454         LDKNodeFeatures this_arg_conv;
40455         this_arg_conv.inner = (void*)(this_arg & (~1));
40456         this_arg_conv.is_owned = false;
40457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40458         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
40459         return ret_conv;
40460 }
40461
40462 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
40463         LDKInitFeatures this_arg_conv;
40464         this_arg_conv.inner = (void*)(this_arg & (~1));
40465         this_arg_conv.is_owned = false;
40466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40467         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
40468         return ret_conv;
40469 }
40470
40471 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
40472         LDKNodeFeatures this_arg_conv;
40473         this_arg_conv.inner = (void*)(this_arg & (~1));
40474         this_arg_conv.is_owned = false;
40475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40476         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
40477         return ret_conv;
40478 }
40479
40480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40481         LDKInitFeatures this_arg_conv;
40482         this_arg_conv.inner = (void*)(this_arg & (~1));
40483         this_arg_conv.is_owned = false;
40484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40485         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
40486 }
40487
40488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40489         LDKInitFeatures this_arg_conv;
40490         this_arg_conv.inner = (void*)(this_arg & (~1));
40491         this_arg_conv.is_owned = false;
40492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40493         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
40494 }
40495
40496 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40497         LDKInitFeatures this_arg_conv;
40498         this_arg_conv.inner = (void*)(this_arg & (~1));
40499         this_arg_conv.is_owned = false;
40500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40501         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
40502         return ret_conv;
40503 }
40504
40505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40506         LDKNodeFeatures this_arg_conv;
40507         this_arg_conv.inner = (void*)(this_arg & (~1));
40508         this_arg_conv.is_owned = false;
40509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40510         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
40511 }
40512
40513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40514         LDKNodeFeatures this_arg_conv;
40515         this_arg_conv.inner = (void*)(this_arg & (~1));
40516         this_arg_conv.is_owned = false;
40517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40518         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
40519 }
40520
40521 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40522         LDKNodeFeatures this_arg_conv;
40523         this_arg_conv.inner = (void*)(this_arg & (~1));
40524         this_arg_conv.is_owned = false;
40525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40526         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
40527         return ret_conv;
40528 }
40529
40530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40531         LDKInvoiceFeatures this_arg_conv;
40532         this_arg_conv.inner = (void*)(this_arg & (~1));
40533         this_arg_conv.is_owned = false;
40534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40535         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
40536 }
40537
40538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40539         LDKInvoiceFeatures this_arg_conv;
40540         this_arg_conv.inner = (void*)(this_arg & (~1));
40541         this_arg_conv.is_owned = false;
40542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40543         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
40544 }
40545
40546 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40547         LDKInvoiceFeatures this_arg_conv;
40548         this_arg_conv.inner = (void*)(this_arg & (~1));
40549         this_arg_conv.is_owned = false;
40550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40551         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
40552         return ret_conv;
40553 }
40554
40555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40556         LDKInitFeatures this_arg_conv;
40557         this_arg_conv.inner = (void*)(this_arg & (~1));
40558         this_arg_conv.is_owned = false;
40559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40560         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
40561         return ret_conv;
40562 }
40563
40564 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40565         LDKNodeFeatures this_arg_conv;
40566         this_arg_conv.inner = (void*)(this_arg & (~1));
40567         this_arg_conv.is_owned = false;
40568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40569         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
40570         return ret_conv;
40571 }
40572
40573 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40574         LDKInvoiceFeatures this_arg_conv;
40575         this_arg_conv.inner = (void*)(this_arg & (~1));
40576         this_arg_conv.is_owned = false;
40577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40578         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
40579         return ret_conv;
40580 }
40581
40582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40583         LDKInitFeatures this_arg_conv;
40584         this_arg_conv.inner = (void*)(this_arg & (~1));
40585         this_arg_conv.is_owned = false;
40586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40587         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
40588 }
40589
40590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40591         LDKInitFeatures this_arg_conv;
40592         this_arg_conv.inner = (void*)(this_arg & (~1));
40593         this_arg_conv.is_owned = false;
40594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40595         InitFeatures_set_static_remote_key_required(&this_arg_conv);
40596 }
40597
40598 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40599         LDKInitFeatures this_arg_conv;
40600         this_arg_conv.inner = (void*)(this_arg & (~1));
40601         this_arg_conv.is_owned = false;
40602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40603         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
40604         return ret_conv;
40605 }
40606
40607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40608         LDKNodeFeatures this_arg_conv;
40609         this_arg_conv.inner = (void*)(this_arg & (~1));
40610         this_arg_conv.is_owned = false;
40611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40612         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
40613 }
40614
40615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40616         LDKNodeFeatures this_arg_conv;
40617         this_arg_conv.inner = (void*)(this_arg & (~1));
40618         this_arg_conv.is_owned = false;
40619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40620         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
40621 }
40622
40623 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40624         LDKNodeFeatures this_arg_conv;
40625         this_arg_conv.inner = (void*)(this_arg & (~1));
40626         this_arg_conv.is_owned = false;
40627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40628         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
40629         return ret_conv;
40630 }
40631
40632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40633         LDKChannelTypeFeatures this_arg_conv;
40634         this_arg_conv.inner = (void*)(this_arg & (~1));
40635         this_arg_conv.is_owned = false;
40636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40637         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
40638 }
40639
40640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40641         LDKChannelTypeFeatures this_arg_conv;
40642         this_arg_conv.inner = (void*)(this_arg & (~1));
40643         this_arg_conv.is_owned = false;
40644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40645         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
40646 }
40647
40648 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40649         LDKChannelTypeFeatures this_arg_conv;
40650         this_arg_conv.inner = (void*)(this_arg & (~1));
40651         this_arg_conv.is_owned = false;
40652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40653         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
40654         return ret_conv;
40655 }
40656
40657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40658         LDKInitFeatures this_arg_conv;
40659         this_arg_conv.inner = (void*)(this_arg & (~1));
40660         this_arg_conv.is_owned = false;
40661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40662         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
40663         return ret_conv;
40664 }
40665
40666 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40667         LDKNodeFeatures this_arg_conv;
40668         this_arg_conv.inner = (void*)(this_arg & (~1));
40669         this_arg_conv.is_owned = false;
40670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40671         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
40672         return ret_conv;
40673 }
40674
40675 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40676         LDKChannelTypeFeatures this_arg_conv;
40677         this_arg_conv.inner = (void*)(this_arg & (~1));
40678         this_arg_conv.is_owned = false;
40679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40680         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
40681         return ret_conv;
40682 }
40683
40684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40685         LDKInitFeatures this_arg_conv;
40686         this_arg_conv.inner = (void*)(this_arg & (~1));
40687         this_arg_conv.is_owned = false;
40688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40689         InitFeatures_set_payment_secret_optional(&this_arg_conv);
40690 }
40691
40692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40693         LDKInitFeatures this_arg_conv;
40694         this_arg_conv.inner = (void*)(this_arg & (~1));
40695         this_arg_conv.is_owned = false;
40696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40697         InitFeatures_set_payment_secret_required(&this_arg_conv);
40698 }
40699
40700 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40701         LDKInitFeatures this_arg_conv;
40702         this_arg_conv.inner = (void*)(this_arg & (~1));
40703         this_arg_conv.is_owned = false;
40704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40705         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
40706         return ret_conv;
40707 }
40708
40709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40710         LDKNodeFeatures this_arg_conv;
40711         this_arg_conv.inner = (void*)(this_arg & (~1));
40712         this_arg_conv.is_owned = false;
40713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40714         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
40715 }
40716
40717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40718         LDKNodeFeatures this_arg_conv;
40719         this_arg_conv.inner = (void*)(this_arg & (~1));
40720         this_arg_conv.is_owned = false;
40721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40722         NodeFeatures_set_payment_secret_required(&this_arg_conv);
40723 }
40724
40725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40726         LDKNodeFeatures this_arg_conv;
40727         this_arg_conv.inner = (void*)(this_arg & (~1));
40728         this_arg_conv.is_owned = false;
40729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40730         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
40731         return ret_conv;
40732 }
40733
40734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40735         LDKInvoiceFeatures this_arg_conv;
40736         this_arg_conv.inner = (void*)(this_arg & (~1));
40737         this_arg_conv.is_owned = false;
40738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40739         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
40740 }
40741
40742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40743         LDKInvoiceFeatures this_arg_conv;
40744         this_arg_conv.inner = (void*)(this_arg & (~1));
40745         this_arg_conv.is_owned = false;
40746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40747         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
40748 }
40749
40750 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40751         LDKInvoiceFeatures this_arg_conv;
40752         this_arg_conv.inner = (void*)(this_arg & (~1));
40753         this_arg_conv.is_owned = false;
40754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40755         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
40756         return ret_conv;
40757 }
40758
40759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40760         LDKInitFeatures this_arg_conv;
40761         this_arg_conv.inner = (void*)(this_arg & (~1));
40762         this_arg_conv.is_owned = false;
40763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40764         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
40765         return ret_conv;
40766 }
40767
40768 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40769         LDKNodeFeatures this_arg_conv;
40770         this_arg_conv.inner = (void*)(this_arg & (~1));
40771         this_arg_conv.is_owned = false;
40772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40773         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
40774         return ret_conv;
40775 }
40776
40777 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
40778         LDKInvoiceFeatures this_arg_conv;
40779         this_arg_conv.inner = (void*)(this_arg & (~1));
40780         this_arg_conv.is_owned = false;
40781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40782         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
40783         return ret_conv;
40784 }
40785
40786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40787         LDKInitFeatures this_arg_conv;
40788         this_arg_conv.inner = (void*)(this_arg & (~1));
40789         this_arg_conv.is_owned = false;
40790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40791         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
40792 }
40793
40794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40795         LDKInitFeatures this_arg_conv;
40796         this_arg_conv.inner = (void*)(this_arg & (~1));
40797         this_arg_conv.is_owned = false;
40798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40799         InitFeatures_set_basic_mpp_required(&this_arg_conv);
40800 }
40801
40802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
40803         LDKInitFeatures this_arg_conv;
40804         this_arg_conv.inner = (void*)(this_arg & (~1));
40805         this_arg_conv.is_owned = false;
40806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40807         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
40808         return ret_conv;
40809 }
40810
40811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40812         LDKNodeFeatures this_arg_conv;
40813         this_arg_conv.inner = (void*)(this_arg & (~1));
40814         this_arg_conv.is_owned = false;
40815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40816         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
40817 }
40818
40819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40820         LDKNodeFeatures this_arg_conv;
40821         this_arg_conv.inner = (void*)(this_arg & (~1));
40822         this_arg_conv.is_owned = false;
40823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40824         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
40825 }
40826
40827 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
40828         LDKNodeFeatures this_arg_conv;
40829         this_arg_conv.inner = (void*)(this_arg & (~1));
40830         this_arg_conv.is_owned = false;
40831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40832         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
40833         return ret_conv;
40834 }
40835
40836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40837         LDKInvoiceFeatures this_arg_conv;
40838         this_arg_conv.inner = (void*)(this_arg & (~1));
40839         this_arg_conv.is_owned = false;
40840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40841         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
40842 }
40843
40844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40845         LDKInvoiceFeatures this_arg_conv;
40846         this_arg_conv.inner = (void*)(this_arg & (~1));
40847         this_arg_conv.is_owned = false;
40848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40849         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
40850 }
40851
40852 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
40853         LDKInvoiceFeatures this_arg_conv;
40854         this_arg_conv.inner = (void*)(this_arg & (~1));
40855         this_arg_conv.is_owned = false;
40856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40857         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
40858         return ret_conv;
40859 }
40860
40861 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
40862         LDKInitFeatures this_arg_conv;
40863         this_arg_conv.inner = (void*)(this_arg & (~1));
40864         this_arg_conv.is_owned = false;
40865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40866         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
40867         return ret_conv;
40868 }
40869
40870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
40871         LDKNodeFeatures this_arg_conv;
40872         this_arg_conv.inner = (void*)(this_arg & (~1));
40873         this_arg_conv.is_owned = false;
40874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40875         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
40876         return ret_conv;
40877 }
40878
40879 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
40880         LDKInvoiceFeatures this_arg_conv;
40881         this_arg_conv.inner = (void*)(this_arg & (~1));
40882         this_arg_conv.is_owned = false;
40883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40884         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
40885         return ret_conv;
40886 }
40887
40888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40889         LDKInitFeatures this_arg_conv;
40890         this_arg_conv.inner = (void*)(this_arg & (~1));
40891         this_arg_conv.is_owned = false;
40892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40893         InitFeatures_set_wumbo_optional(&this_arg_conv);
40894 }
40895
40896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40897         LDKInitFeatures this_arg_conv;
40898         this_arg_conv.inner = (void*)(this_arg & (~1));
40899         this_arg_conv.is_owned = false;
40900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40901         InitFeatures_set_wumbo_required(&this_arg_conv);
40902 }
40903
40904 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
40905         LDKInitFeatures this_arg_conv;
40906         this_arg_conv.inner = (void*)(this_arg & (~1));
40907         this_arg_conv.is_owned = false;
40908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40909         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
40910         return ret_conv;
40911 }
40912
40913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40914         LDKNodeFeatures this_arg_conv;
40915         this_arg_conv.inner = (void*)(this_arg & (~1));
40916         this_arg_conv.is_owned = false;
40917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40918         NodeFeatures_set_wumbo_optional(&this_arg_conv);
40919 }
40920
40921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40922         LDKNodeFeatures this_arg_conv;
40923         this_arg_conv.inner = (void*)(this_arg & (~1));
40924         this_arg_conv.is_owned = false;
40925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40926         NodeFeatures_set_wumbo_required(&this_arg_conv);
40927 }
40928
40929 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
40930         LDKNodeFeatures this_arg_conv;
40931         this_arg_conv.inner = (void*)(this_arg & (~1));
40932         this_arg_conv.is_owned = false;
40933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40934         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
40935         return ret_conv;
40936 }
40937
40938 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
40939         LDKInitFeatures this_arg_conv;
40940         this_arg_conv.inner = (void*)(this_arg & (~1));
40941         this_arg_conv.is_owned = false;
40942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40943         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
40944         return ret_conv;
40945 }
40946
40947 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
40948         LDKNodeFeatures this_arg_conv;
40949         this_arg_conv.inner = (void*)(this_arg & (~1));
40950         this_arg_conv.is_owned = false;
40951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40952         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
40953         return ret_conv;
40954 }
40955
40956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40957         LDKInitFeatures this_arg_conv;
40958         this_arg_conv.inner = (void*)(this_arg & (~1));
40959         this_arg_conv.is_owned = false;
40960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40961         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
40962 }
40963
40964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40965         LDKInitFeatures this_arg_conv;
40966         this_arg_conv.inner = (void*)(this_arg & (~1));
40967         this_arg_conv.is_owned = false;
40968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40969         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
40970 }
40971
40972 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
40973         LDKInitFeatures this_arg_conv;
40974         this_arg_conv.inner = (void*)(this_arg & (~1));
40975         this_arg_conv.is_owned = false;
40976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40977         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
40978         return ret_conv;
40979 }
40980
40981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40982         LDKNodeFeatures this_arg_conv;
40983         this_arg_conv.inner = (void*)(this_arg & (~1));
40984         this_arg_conv.is_owned = false;
40985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40986         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
40987 }
40988
40989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40990         LDKNodeFeatures this_arg_conv;
40991         this_arg_conv.inner = (void*)(this_arg & (~1));
40992         this_arg_conv.is_owned = false;
40993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40994         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
40995 }
40996
40997 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
40998         LDKNodeFeatures this_arg_conv;
40999         this_arg_conv.inner = (void*)(this_arg & (~1));
41000         this_arg_conv.is_owned = false;
41001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41002         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
41003         return ret_conv;
41004 }
41005
41006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
41007         LDKInitFeatures this_arg_conv;
41008         this_arg_conv.inner = (void*)(this_arg & (~1));
41009         this_arg_conv.is_owned = false;
41010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41011         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
41012         return ret_conv;
41013 }
41014
41015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
41016         LDKNodeFeatures this_arg_conv;
41017         this_arg_conv.inner = (void*)(this_arg & (~1));
41018         this_arg_conv.is_owned = false;
41019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41020         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
41021         return ret_conv;
41022 }
41023
41024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41025         LDKInitFeatures this_arg_conv;
41026         this_arg_conv.inner = (void*)(this_arg & (~1));
41027         this_arg_conv.is_owned = false;
41028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41029         InitFeatures_set_channel_type_optional(&this_arg_conv);
41030 }
41031
41032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41033         LDKInitFeatures this_arg_conv;
41034         this_arg_conv.inner = (void*)(this_arg & (~1));
41035         this_arg_conv.is_owned = false;
41036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41037         InitFeatures_set_channel_type_required(&this_arg_conv);
41038 }
41039
41040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
41041         LDKInitFeatures this_arg_conv;
41042         this_arg_conv.inner = (void*)(this_arg & (~1));
41043         this_arg_conv.is_owned = false;
41044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41045         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
41046         return ret_conv;
41047 }
41048
41049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41050         LDKNodeFeatures this_arg_conv;
41051         this_arg_conv.inner = (void*)(this_arg & (~1));
41052         this_arg_conv.is_owned = false;
41053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41054         NodeFeatures_set_channel_type_optional(&this_arg_conv);
41055 }
41056
41057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41058         LDKNodeFeatures this_arg_conv;
41059         this_arg_conv.inner = (void*)(this_arg & (~1));
41060         this_arg_conv.is_owned = false;
41061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41062         NodeFeatures_set_channel_type_required(&this_arg_conv);
41063 }
41064
41065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
41066         LDKNodeFeatures this_arg_conv;
41067         this_arg_conv.inner = (void*)(this_arg & (~1));
41068         this_arg_conv.is_owned = false;
41069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41070         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
41071         return ret_conv;
41072 }
41073
41074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
41075         LDKInitFeatures this_arg_conv;
41076         this_arg_conv.inner = (void*)(this_arg & (~1));
41077         this_arg_conv.is_owned = false;
41078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41079         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
41080         return ret_conv;
41081 }
41082
41083 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
41084         LDKNodeFeatures this_arg_conv;
41085         this_arg_conv.inner = (void*)(this_arg & (~1));
41086         this_arg_conv.is_owned = false;
41087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41088         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
41089         return ret_conv;
41090 }
41091
41092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41093         LDKInitFeatures this_arg_conv;
41094         this_arg_conv.inner = (void*)(this_arg & (~1));
41095         this_arg_conv.is_owned = false;
41096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41097         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
41098 }
41099
41100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41101         LDKInitFeatures this_arg_conv;
41102         this_arg_conv.inner = (void*)(this_arg & (~1));
41103         this_arg_conv.is_owned = false;
41104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41105         InitFeatures_set_scid_privacy_required(&this_arg_conv);
41106 }
41107
41108 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41109         LDKInitFeatures this_arg_conv;
41110         this_arg_conv.inner = (void*)(this_arg & (~1));
41111         this_arg_conv.is_owned = false;
41112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41113         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
41114         return ret_conv;
41115 }
41116
41117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41118         LDKNodeFeatures this_arg_conv;
41119         this_arg_conv.inner = (void*)(this_arg & (~1));
41120         this_arg_conv.is_owned = false;
41121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41122         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
41123 }
41124
41125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41126         LDKNodeFeatures this_arg_conv;
41127         this_arg_conv.inner = (void*)(this_arg & (~1));
41128         this_arg_conv.is_owned = false;
41129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41130         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
41131 }
41132
41133 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41134         LDKNodeFeatures this_arg_conv;
41135         this_arg_conv.inner = (void*)(this_arg & (~1));
41136         this_arg_conv.is_owned = false;
41137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41138         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
41139         return ret_conv;
41140 }
41141
41142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41143         LDKChannelTypeFeatures this_arg_conv;
41144         this_arg_conv.inner = (void*)(this_arg & (~1));
41145         this_arg_conv.is_owned = false;
41146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41147         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
41148 }
41149
41150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41151         LDKChannelTypeFeatures this_arg_conv;
41152         this_arg_conv.inner = (void*)(this_arg & (~1));
41153         this_arg_conv.is_owned = false;
41154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41155         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
41156 }
41157
41158 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41159         LDKChannelTypeFeatures this_arg_conv;
41160         this_arg_conv.inner = (void*)(this_arg & (~1));
41161         this_arg_conv.is_owned = false;
41162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41163         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
41164         return ret_conv;
41165 }
41166
41167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41168         LDKInitFeatures this_arg_conv;
41169         this_arg_conv.inner = (void*)(this_arg & (~1));
41170         this_arg_conv.is_owned = false;
41171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41172         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
41173         return ret_conv;
41174 }
41175
41176 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41177         LDKNodeFeatures this_arg_conv;
41178         this_arg_conv.inner = (void*)(this_arg & (~1));
41179         this_arg_conv.is_owned = false;
41180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41181         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
41182         return ret_conv;
41183 }
41184
41185 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41186         LDKChannelTypeFeatures this_arg_conv;
41187         this_arg_conv.inner = (void*)(this_arg & (~1));
41188         this_arg_conv.is_owned = false;
41189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41190         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
41191         return ret_conv;
41192 }
41193
41194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41195         LDKInitFeatures this_arg_conv;
41196         this_arg_conv.inner = (void*)(this_arg & (~1));
41197         this_arg_conv.is_owned = false;
41198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41199         InitFeatures_set_zero_conf_optional(&this_arg_conv);
41200 }
41201
41202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41203         LDKInitFeatures this_arg_conv;
41204         this_arg_conv.inner = (void*)(this_arg & (~1));
41205         this_arg_conv.is_owned = false;
41206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41207         InitFeatures_set_zero_conf_required(&this_arg_conv);
41208 }
41209
41210 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41211         LDKInitFeatures this_arg_conv;
41212         this_arg_conv.inner = (void*)(this_arg & (~1));
41213         this_arg_conv.is_owned = false;
41214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41215         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
41216         return ret_conv;
41217 }
41218
41219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41220         LDKNodeFeatures this_arg_conv;
41221         this_arg_conv.inner = (void*)(this_arg & (~1));
41222         this_arg_conv.is_owned = false;
41223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41224         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
41225 }
41226
41227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41228         LDKNodeFeatures this_arg_conv;
41229         this_arg_conv.inner = (void*)(this_arg & (~1));
41230         this_arg_conv.is_owned = false;
41231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41232         NodeFeatures_set_zero_conf_required(&this_arg_conv);
41233 }
41234
41235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41236         LDKNodeFeatures this_arg_conv;
41237         this_arg_conv.inner = (void*)(this_arg & (~1));
41238         this_arg_conv.is_owned = false;
41239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41240         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
41241         return ret_conv;
41242 }
41243
41244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41245         LDKChannelTypeFeatures this_arg_conv;
41246         this_arg_conv.inner = (void*)(this_arg & (~1));
41247         this_arg_conv.is_owned = false;
41248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41249         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
41250 }
41251
41252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41253         LDKChannelTypeFeatures this_arg_conv;
41254         this_arg_conv.inner = (void*)(this_arg & (~1));
41255         this_arg_conv.is_owned = false;
41256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41257         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
41258 }
41259
41260 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41261         LDKChannelTypeFeatures this_arg_conv;
41262         this_arg_conv.inner = (void*)(this_arg & (~1));
41263         this_arg_conv.is_owned = false;
41264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41265         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
41266         return ret_conv;
41267 }
41268
41269 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41270         LDKInitFeatures this_arg_conv;
41271         this_arg_conv.inner = (void*)(this_arg & (~1));
41272         this_arg_conv.is_owned = false;
41273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41274         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
41275         return ret_conv;
41276 }
41277
41278 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41279         LDKNodeFeatures this_arg_conv;
41280         this_arg_conv.inner = (void*)(this_arg & (~1));
41281         this_arg_conv.is_owned = false;
41282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41283         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
41284         return ret_conv;
41285 }
41286
41287 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41288         LDKChannelTypeFeatures this_arg_conv;
41289         this_arg_conv.inner = (void*)(this_arg & (~1));
41290         this_arg_conv.is_owned = false;
41291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41292         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
41293         return ret_conv;
41294 }
41295
41296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41297         LDKNodeFeatures this_arg_conv;
41298         this_arg_conv.inner = (void*)(this_arg & (~1));
41299         this_arg_conv.is_owned = false;
41300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41301         NodeFeatures_set_keysend_optional(&this_arg_conv);
41302 }
41303
41304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41305         LDKNodeFeatures this_arg_conv;
41306         this_arg_conv.inner = (void*)(this_arg & (~1));
41307         this_arg_conv.is_owned = false;
41308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41309         NodeFeatures_set_keysend_required(&this_arg_conv);
41310 }
41311
41312 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
41313         LDKNodeFeatures this_arg_conv;
41314         this_arg_conv.inner = (void*)(this_arg & (~1));
41315         this_arg_conv.is_owned = false;
41316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41317         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
41318         return ret_conv;
41319 }
41320
41321 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
41322         LDKNodeFeatures this_arg_conv;
41323         this_arg_conv.inner = (void*)(this_arg & (~1));
41324         this_arg_conv.is_owned = false;
41325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41326         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
41327         return ret_conv;
41328 }
41329
41330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41331         LDKShutdownScript this_obj_conv;
41332         this_obj_conv.inner = (void*)(this_obj & (~1));
41333         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41335         ShutdownScript_free(this_obj_conv);
41336 }
41337
41338 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
41339         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
41340 int64_t ret_ref = 0;
41341 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41342 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41343 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41344 ret_ref = (uintptr_t)ret_var.inner;
41345 if (ret_var.is_owned) {
41346         ret_ref |= 1;
41347 }
41348         return ret_ref;
41349 }
41350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41351         LDKShutdownScript arg_conv;
41352         arg_conv.inner = (void*)(arg & (~1));
41353         arg_conv.is_owned = false;
41354         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41355         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
41356         return ret_conv;
41357 }
41358
41359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41360         LDKShutdownScript orig_conv;
41361         orig_conv.inner = (void*)(orig & (~1));
41362         orig_conv.is_owned = false;
41363         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41364         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
41365         int64_t ret_ref = 0;
41366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41369         ret_ref = (uintptr_t)ret_var.inner;
41370         if (ret_var.is_owned) {
41371                 ret_ref |= 1;
41372         }
41373         return ret_ref;
41374 }
41375
41376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41377         LDKInvalidShutdownScript this_obj_conv;
41378         this_obj_conv.inner = (void*)(this_obj & (~1));
41379         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41381         InvalidShutdownScript_free(this_obj_conv);
41382 }
41383
41384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
41385         LDKInvalidShutdownScript this_ptr_conv;
41386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41387         this_ptr_conv.is_owned = false;
41388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41389         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
41390         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41391         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41392         return ret_arr;
41393 }
41394
41395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41396         LDKInvalidShutdownScript this_ptr_conv;
41397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41398         this_ptr_conv.is_owned = false;
41399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41400         LDKCVec_u8Z val_ref;
41401         val_ref.datalen = (*env)->GetArrayLength(env, val);
41402         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
41403         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
41404         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
41405 }
41406
41407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
41408         LDKCVec_u8Z script_arg_ref;
41409         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
41410         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
41411         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
41412         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
41413         int64_t ret_ref = 0;
41414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41417         ret_ref = (uintptr_t)ret_var.inner;
41418         if (ret_var.is_owned) {
41419                 ret_ref |= 1;
41420         }
41421         return ret_ref;
41422 }
41423
41424 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
41425         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
41426 int64_t ret_ref = 0;
41427 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41428 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41429 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41430 ret_ref = (uintptr_t)ret_var.inner;
41431 if (ret_var.is_owned) {
41432         ret_ref |= 1;
41433 }
41434         return ret_ref;
41435 }
41436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41437         LDKInvalidShutdownScript arg_conv;
41438         arg_conv.inner = (void*)(arg & (~1));
41439         arg_conv.is_owned = false;
41440         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41441         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
41442         return ret_conv;
41443 }
41444
41445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41446         LDKInvalidShutdownScript orig_conv;
41447         orig_conv.inner = (void*)(orig & (~1));
41448         orig_conv.is_owned = false;
41449         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41450         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
41451         int64_t ret_ref = 0;
41452         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41453         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41455         ret_ref = (uintptr_t)ret_var.inner;
41456         if (ret_var.is_owned) {
41457                 ret_ref |= 1;
41458         }
41459         return ret_ref;
41460 }
41461
41462 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
41463         LDKShutdownScript obj_conv;
41464         obj_conv.inner = (void*)(obj & (~1));
41465         obj_conv.is_owned = false;
41466         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41467         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
41468         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41469         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41470         CVec_u8Z_free(ret_var);
41471         return ret_arr;
41472 }
41473
41474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41475         LDKu8slice ser_ref;
41476         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41477         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41478         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
41479         *ret_conv = ShutdownScript_read(ser_ref);
41480         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41481         return (int64_t)ret_conv;
41482 }
41483
41484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
41485         unsigned char pubkey_hash_arr[20];
41486         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
41487         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
41488         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
41489         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
41490         int64_t ret_ref = 0;
41491         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41492         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41494         ret_ref = (uintptr_t)ret_var.inner;
41495         if (ret_var.is_owned) {
41496                 ret_ref |= 1;
41497         }
41498         return ret_ref;
41499 }
41500
41501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
41502         unsigned char script_hash_arr[32];
41503         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
41504         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
41505         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
41506         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
41507         int64_t ret_ref = 0;
41508         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41509         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41511         ret_ref = (uintptr_t)ret_var.inner;
41512         if (ret_var.is_owned) {
41513                 ret_ref |= 1;
41514         }
41515         return ret_ref;
41516 }
41517
41518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
41519         
41520         LDKu8slice program_ref;
41521         program_ref.datalen = (*env)->GetArrayLength(env, program);
41522         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
41523         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
41524         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
41525         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
41526         return (int64_t)ret_conv;
41527 }
41528
41529 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
41530         LDKShutdownScript this_arg_conv;
41531         this_arg_conv.inner = (void*)(this_arg & (~1));
41532         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41534         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
41535         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
41536         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41537         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41538         CVec_u8Z_free(ret_var);
41539         return ret_arr;
41540 }
41541
41542 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
41543         LDKShutdownScript this_arg_conv;
41544         this_arg_conv.inner = (void*)(this_arg & (~1));
41545         this_arg_conv.is_owned = false;
41546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41547         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41548         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
41549         return ret_arr;
41550 }
41551
41552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
41553         LDKShutdownScript this_arg_conv;
41554         this_arg_conv.inner = (void*)(this_arg & (~1));
41555         this_arg_conv.is_owned = false;
41556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41557         LDKInitFeatures features_conv;
41558         features_conv.inner = (void*)(features & (~1));
41559         features_conv.is_owned = false;
41560         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
41561         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
41562         return ret_conv;
41563 }
41564
41565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41566         if ((this_ptr & 1) != 0) return;
41567         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41568         CHECK_ACCESS(this_ptr_ptr);
41569         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
41570         FREE((void*)this_ptr);
41571         CustomMessageReader_free(this_ptr_conv);
41572 }
41573
41574 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
41575         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
41576         *ret_ret = Type_clone(arg);
41577         return (int64_t)ret_ret;
41578 }
41579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41580         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
41581         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
41582         LDKType* arg_conv = (LDKType*)arg_ptr;
41583         int64_t ret_conv = Type_clone_ptr(arg_conv);
41584         return ret_conv;
41585 }
41586
41587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41588         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
41589         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
41590         LDKType* orig_conv = (LDKType*)orig_ptr;
41591         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
41592         *ret_ret = Type_clone(orig_conv);
41593         return (int64_t)ret_ret;
41594 }
41595
41596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41597         if ((this_ptr & 1) != 0) return;
41598         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41599         CHECK_ACCESS(this_ptr_ptr);
41600         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
41601         FREE((void*)this_ptr);
41602         Type_free(this_ptr_conv);
41603 }
41604
41605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41606         LDKNodeId this_obj_conv;
41607         this_obj_conv.inner = (void*)(this_obj & (~1));
41608         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41610         NodeId_free(this_obj_conv);
41611 }
41612
41613 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
41614         LDKNodeId ret_var = NodeId_clone(arg);
41615 int64_t ret_ref = 0;
41616 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41617 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41618 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41619 ret_ref = (uintptr_t)ret_var.inner;
41620 if (ret_var.is_owned) {
41621         ret_ref |= 1;
41622 }
41623         return ret_ref;
41624 }
41625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41626         LDKNodeId arg_conv;
41627         arg_conv.inner = (void*)(arg & (~1));
41628         arg_conv.is_owned = false;
41629         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41630         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
41631         return ret_conv;
41632 }
41633
41634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41635         LDKNodeId orig_conv;
41636         orig_conv.inner = (void*)(orig & (~1));
41637         orig_conv.is_owned = false;
41638         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41639         LDKNodeId ret_var = NodeId_clone(&orig_conv);
41640         int64_t ret_ref = 0;
41641         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41642         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41644         ret_ref = (uintptr_t)ret_var.inner;
41645         if (ret_var.is_owned) {
41646                 ret_ref |= 1;
41647         }
41648         return ret_ref;
41649 }
41650
41651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
41652         LDKPublicKey pubkey_ref;
41653         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
41654         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
41655         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
41656         int64_t ret_ref = 0;
41657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41660         ret_ref = (uintptr_t)ret_var.inner;
41661         if (ret_var.is_owned) {
41662                 ret_ref |= 1;
41663         }
41664         return ret_ref;
41665 }
41666
41667 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
41668         LDKNodeId this_arg_conv;
41669         this_arg_conv.inner = (void*)(this_arg & (~1));
41670         this_arg_conv.is_owned = false;
41671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41672         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
41673         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41674         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41675         return ret_arr;
41676 }
41677
41678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
41679         LDKNodeId o_conv;
41680         o_conv.inner = (void*)(o & (~1));
41681         o_conv.is_owned = false;
41682         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41683         int64_t ret_conv = NodeId_hash(&o_conv);
41684         return ret_conv;
41685 }
41686
41687 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
41688         LDKNodeId obj_conv;
41689         obj_conv.inner = (void*)(obj & (~1));
41690         obj_conv.is_owned = false;
41691         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41692         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
41693         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41694         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41695         CVec_u8Z_free(ret_var);
41696         return ret_arr;
41697 }
41698
41699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41700         LDKu8slice ser_ref;
41701         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41702         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41703         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
41704         *ret_conv = NodeId_read(ser_ref);
41705         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41706         return (int64_t)ret_conv;
41707 }
41708
41709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41710         LDKNetworkGraph this_obj_conv;
41711         this_obj_conv.inner = (void*)(this_obj & (~1));
41712         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41714         NetworkGraph_free(this_obj_conv);
41715 }
41716
41717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41718         LDKReadOnlyNetworkGraph this_obj_conv;
41719         this_obj_conv.inner = (void*)(this_obj & (~1));
41720         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41722         ReadOnlyNetworkGraph_free(this_obj_conv);
41723 }
41724
41725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41726         if ((this_ptr & 1) != 0) return;
41727         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41728         CHECK_ACCESS(this_ptr_ptr);
41729         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
41730         FREE((void*)this_ptr);
41731         NetworkUpdate_free(this_ptr_conv);
41732 }
41733
41734 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
41735         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
41736         *ret_copy = NetworkUpdate_clone(arg);
41737 int64_t ret_ref = (uintptr_t)ret_copy;
41738         return ret_ref;
41739 }
41740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41741         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
41742         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
41743         return ret_conv;
41744 }
41745
41746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41747         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
41748         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
41749         *ret_copy = NetworkUpdate_clone(orig_conv);
41750         int64_t ret_ref = (uintptr_t)ret_copy;
41751         return ret_ref;
41752 }
41753
41754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
41755         LDKChannelUpdate msg_conv;
41756         msg_conv.inner = (void*)(msg & (~1));
41757         msg_conv.is_owned = (msg & 1) || (msg == 0);
41758         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41759         msg_conv = ChannelUpdate_clone(&msg_conv);
41760         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
41761         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
41762         int64_t ret_ref = (uintptr_t)ret_copy;
41763         return ret_ref;
41764 }
41765
41766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
41767         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
41768         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
41769         int64_t ret_ref = (uintptr_t)ret_copy;
41770         return ret_ref;
41771 }
41772
41773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
41774         LDKPublicKey node_id_ref;
41775         CHECK((*env)->GetArrayLength(env, node_id) == 33);
41776         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
41777         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
41778         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
41779         int64_t ret_ref = (uintptr_t)ret_copy;
41780         return ret_ref;
41781 }
41782
41783 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
41784         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
41785         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
41786         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41787         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41788         CVec_u8Z_free(ret_var);
41789         return ret_arr;
41790 }
41791
41792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41793         LDKu8slice ser_ref;
41794         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41795         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41796         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
41797         *ret_conv = NetworkUpdate_read(ser_ref);
41798         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41799         return (int64_t)ret_conv;
41800 }
41801
41802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41803         LDKP2PGossipSync this_obj_conv;
41804         this_obj_conv.inner = (void*)(this_obj & (~1));
41805         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41807         P2PGossipSync_free(this_obj_conv);
41808 }
41809
41810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
41811         LDKNetworkGraph network_graph_conv;
41812         network_graph_conv.inner = (void*)(network_graph & (~1));
41813         network_graph_conv.is_owned = false;
41814         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
41815         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
41816         CHECK_ACCESS(chain_access_ptr);
41817         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41818         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41819         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41820                 // Manually implement clone for Java trait instances
41821                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41822                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41823                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41824                 }
41825         }
41826         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41827         CHECK_ACCESS(logger_ptr);
41828         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41829         if (logger_conv.free == LDKLogger_JCalls_free) {
41830                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41831                 LDKLogger_JCalls_cloned(&logger_conv);
41832         }
41833         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
41834         int64_t ret_ref = 0;
41835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41838         ret_ref = (uintptr_t)ret_var.inner;
41839         if (ret_var.is_owned) {
41840                 ret_ref |= 1;
41841         }
41842         return ret_ref;
41843 }
41844
41845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
41846         LDKP2PGossipSync this_arg_conv;
41847         this_arg_conv.inner = (void*)(this_arg & (~1));
41848         this_arg_conv.is_owned = false;
41849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41850         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
41851         CHECK_ACCESS(chain_access_ptr);
41852         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41853         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41854         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41855                 // Manually implement clone for Java trait instances
41856                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41857                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41858                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41859                 }
41860         }
41861         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
41862 }
41863
41864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41865         LDKNetworkGraph this_arg_conv;
41866         this_arg_conv.inner = (void*)(this_arg & (~1));
41867         this_arg_conv.is_owned = false;
41868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41869         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
41870         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
41871         return (int64_t)ret_ret;
41872 }
41873
41874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
41875         LDKP2PGossipSync this_arg_conv;
41876         this_arg_conv.inner = (void*)(this_arg & (~1));
41877         this_arg_conv.is_owned = false;
41878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41879         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
41880         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
41881         return (int64_t)ret_ret;
41882 }
41883
41884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
41885         LDKP2PGossipSync this_arg_conv;
41886         this_arg_conv.inner = (void*)(this_arg & (~1));
41887         this_arg_conv.is_owned = false;
41888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41889         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
41890         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
41891         return (int64_t)ret_ret;
41892 }
41893
41894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41895         LDKChannelUpdateInfo this_obj_conv;
41896         this_obj_conv.inner = (void*)(this_obj & (~1));
41897         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41899         ChannelUpdateInfo_free(this_obj_conv);
41900 }
41901
41902 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
41903         LDKChannelUpdateInfo this_ptr_conv;
41904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41905         this_ptr_conv.is_owned = false;
41906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41907         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
41908         return ret_conv;
41909 }
41910
41911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
41912         LDKChannelUpdateInfo this_ptr_conv;
41913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41914         this_ptr_conv.is_owned = false;
41915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41916         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
41917 }
41918
41919 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
41920         LDKChannelUpdateInfo this_ptr_conv;
41921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41922         this_ptr_conv.is_owned = false;
41923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41924         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
41925         return ret_conv;
41926 }
41927
41928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
41929         LDKChannelUpdateInfo this_ptr_conv;
41930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41931         this_ptr_conv.is_owned = false;
41932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41933         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
41934 }
41935
41936 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
41937         LDKChannelUpdateInfo this_ptr_conv;
41938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41939         this_ptr_conv.is_owned = false;
41940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41941         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
41942         return ret_conv;
41943 }
41944
41945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
41946         LDKChannelUpdateInfo this_ptr_conv;
41947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41948         this_ptr_conv.is_owned = false;
41949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41950         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
41951 }
41952
41953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
41954         LDKChannelUpdateInfo this_ptr_conv;
41955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41956         this_ptr_conv.is_owned = false;
41957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41958         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
41959         return ret_conv;
41960 }
41961
41962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41963         LDKChannelUpdateInfo this_ptr_conv;
41964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41965         this_ptr_conv.is_owned = false;
41966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41967         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
41968 }
41969
41970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
41971         LDKChannelUpdateInfo this_ptr_conv;
41972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41973         this_ptr_conv.is_owned = false;
41974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41975         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41976         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
41977         int64_t ret_ref = (uintptr_t)ret_copy;
41978         return ret_ref;
41979 }
41980
41981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41982         LDKChannelUpdateInfo this_ptr_conv;
41983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41984         this_ptr_conv.is_owned = false;
41985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41986         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41987         CHECK_ACCESS(val_ptr);
41988         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41989         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
41990         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
41991 }
41992
41993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
41994         LDKChannelUpdateInfo this_ptr_conv;
41995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41996         this_ptr_conv.is_owned = false;
41997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41998         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
41999         int64_t ret_ref = 0;
42000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42003         ret_ref = (uintptr_t)ret_var.inner;
42004         if (ret_var.is_owned) {
42005                 ret_ref |= 1;
42006         }
42007         return ret_ref;
42008 }
42009
42010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42011         LDKChannelUpdateInfo this_ptr_conv;
42012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42013         this_ptr_conv.is_owned = false;
42014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42015         LDKRoutingFees val_conv;
42016         val_conv.inner = (void*)(val & (~1));
42017         val_conv.is_owned = (val & 1) || (val == 0);
42018         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42019         val_conv = RoutingFees_clone(&val_conv);
42020         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
42021 }
42022
42023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
42024         LDKChannelUpdateInfo this_ptr_conv;
42025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42026         this_ptr_conv.is_owned = false;
42027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42028         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
42029         int64_t ret_ref = 0;
42030         if ((uintptr_t)ret_var.inner > 4096) {
42031                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42032                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42034                 ret_ref = (uintptr_t)ret_var.inner;
42035                 if (ret_var.is_owned) {
42036                         ret_ref |= 1;
42037                 }
42038         }
42039         return ret_ref;
42040 }
42041
42042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42043         LDKChannelUpdateInfo this_ptr_conv;
42044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42045         this_ptr_conv.is_owned = false;
42046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42047         LDKChannelUpdate val_conv;
42048         val_conv.inner = (void*)(val & (~1));
42049         val_conv.is_owned = (val & 1) || (val == 0);
42050         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42051         val_conv = ChannelUpdate_clone(&val_conv);
42052         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
42053 }
42054
42055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_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) {
42056         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
42057         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
42058         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
42059         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
42060         LDKRoutingFees fees_arg_conv;
42061         fees_arg_conv.inner = (void*)(fees_arg & (~1));
42062         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
42063         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
42064         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
42065         LDKChannelUpdate last_update_message_arg_conv;
42066         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
42067         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
42068         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
42069         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
42070         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_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);
42071         int64_t ret_ref = 0;
42072         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42073         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42075         ret_ref = (uintptr_t)ret_var.inner;
42076         if (ret_var.is_owned) {
42077                 ret_ref |= 1;
42078         }
42079         return ret_ref;
42080 }
42081
42082 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
42083         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
42084 int64_t ret_ref = 0;
42085 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42086 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42087 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42088 ret_ref = (uintptr_t)ret_var.inner;
42089 if (ret_var.is_owned) {
42090         ret_ref |= 1;
42091 }
42092         return ret_ref;
42093 }
42094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42095         LDKChannelUpdateInfo arg_conv;
42096         arg_conv.inner = (void*)(arg & (~1));
42097         arg_conv.is_owned = false;
42098         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42099         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
42100         return ret_conv;
42101 }
42102
42103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42104         LDKChannelUpdateInfo orig_conv;
42105         orig_conv.inner = (void*)(orig & (~1));
42106         orig_conv.is_owned = false;
42107         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42108         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
42109         int64_t ret_ref = 0;
42110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42113         ret_ref = (uintptr_t)ret_var.inner;
42114         if (ret_var.is_owned) {
42115                 ret_ref |= 1;
42116         }
42117         return ret_ref;
42118 }
42119
42120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
42121         LDKChannelUpdateInfo obj_conv;
42122         obj_conv.inner = (void*)(obj & (~1));
42123         obj_conv.is_owned = false;
42124         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42125         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
42126         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42127         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42128         CVec_u8Z_free(ret_var);
42129         return ret_arr;
42130 }
42131
42132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42133         LDKu8slice ser_ref;
42134         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42135         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42136         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
42137         *ret_conv = ChannelUpdateInfo_read(ser_ref);
42138         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42139         return (int64_t)ret_conv;
42140 }
42141
42142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42143         LDKChannelInfo this_obj_conv;
42144         this_obj_conv.inner = (void*)(this_obj & (~1));
42145         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42147         ChannelInfo_free(this_obj_conv);
42148 }
42149
42150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
42151         LDKChannelInfo this_ptr_conv;
42152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42153         this_ptr_conv.is_owned = false;
42154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42155         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
42156         int64_t ret_ref = 0;
42157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42160         ret_ref = (uintptr_t)ret_var.inner;
42161         if (ret_var.is_owned) {
42162                 ret_ref |= 1;
42163         }
42164         return ret_ref;
42165 }
42166
42167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42168         LDKChannelInfo this_ptr_conv;
42169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42170         this_ptr_conv.is_owned = false;
42171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42172         LDKChannelFeatures val_conv;
42173         val_conv.inner = (void*)(val & (~1));
42174         val_conv.is_owned = (val & 1) || (val == 0);
42175         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42176         val_conv = ChannelFeatures_clone(&val_conv);
42177         ChannelInfo_set_features(&this_ptr_conv, val_conv);
42178 }
42179
42180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
42181         LDKChannelInfo this_ptr_conv;
42182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42183         this_ptr_conv.is_owned = false;
42184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42185         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
42186         int64_t ret_ref = 0;
42187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42190         ret_ref = (uintptr_t)ret_var.inner;
42191         if (ret_var.is_owned) {
42192                 ret_ref |= 1;
42193         }
42194         return ret_ref;
42195 }
42196
42197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42198         LDKChannelInfo this_ptr_conv;
42199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42200         this_ptr_conv.is_owned = false;
42201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42202         LDKNodeId val_conv;
42203         val_conv.inner = (void*)(val & (~1));
42204         val_conv.is_owned = (val & 1) || (val == 0);
42205         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42206         val_conv = NodeId_clone(&val_conv);
42207         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
42208 }
42209
42210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
42211         LDKChannelInfo this_ptr_conv;
42212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42213         this_ptr_conv.is_owned = false;
42214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42215         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
42216         int64_t ret_ref = 0;
42217         if ((uintptr_t)ret_var.inner > 4096) {
42218                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42219                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42221                 ret_ref = (uintptr_t)ret_var.inner;
42222                 if (ret_var.is_owned) {
42223                         ret_ref |= 1;
42224                 }
42225         }
42226         return ret_ref;
42227 }
42228
42229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42230         LDKChannelInfo this_ptr_conv;
42231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42232         this_ptr_conv.is_owned = false;
42233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42234         LDKChannelUpdateInfo val_conv;
42235         val_conv.inner = (void*)(val & (~1));
42236         val_conv.is_owned = (val & 1) || (val == 0);
42237         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42238         val_conv = ChannelUpdateInfo_clone(&val_conv);
42239         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
42240 }
42241
42242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
42243         LDKChannelInfo this_ptr_conv;
42244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42245         this_ptr_conv.is_owned = false;
42246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42247         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
42248         int64_t ret_ref = 0;
42249         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42250         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42252         ret_ref = (uintptr_t)ret_var.inner;
42253         if (ret_var.is_owned) {
42254                 ret_ref |= 1;
42255         }
42256         return ret_ref;
42257 }
42258
42259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42260         LDKChannelInfo this_ptr_conv;
42261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42262         this_ptr_conv.is_owned = false;
42263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42264         LDKNodeId val_conv;
42265         val_conv.inner = (void*)(val & (~1));
42266         val_conv.is_owned = (val & 1) || (val == 0);
42267         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42268         val_conv = NodeId_clone(&val_conv);
42269         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
42270 }
42271
42272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
42273         LDKChannelInfo this_ptr_conv;
42274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42275         this_ptr_conv.is_owned = false;
42276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42277         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
42278         int64_t ret_ref = 0;
42279         if ((uintptr_t)ret_var.inner > 4096) {
42280                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42281                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42283                 ret_ref = (uintptr_t)ret_var.inner;
42284                 if (ret_var.is_owned) {
42285                         ret_ref |= 1;
42286                 }
42287         }
42288         return ret_ref;
42289 }
42290
42291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42292         LDKChannelInfo this_ptr_conv;
42293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42294         this_ptr_conv.is_owned = false;
42295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42296         LDKChannelUpdateInfo val_conv;
42297         val_conv.inner = (void*)(val & (~1));
42298         val_conv.is_owned = (val & 1) || (val == 0);
42299         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42300         val_conv = ChannelUpdateInfo_clone(&val_conv);
42301         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
42302 }
42303
42304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
42305         LDKChannelInfo this_ptr_conv;
42306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42307         this_ptr_conv.is_owned = false;
42308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42309         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42310         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
42311         int64_t ret_ref = (uintptr_t)ret_copy;
42312         return ret_ref;
42313 }
42314
42315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42316         LDKChannelInfo this_ptr_conv;
42317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42318         this_ptr_conv.is_owned = false;
42319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42320         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42321         CHECK_ACCESS(val_ptr);
42322         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42323         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42324         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
42325 }
42326
42327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
42328         LDKChannelInfo this_ptr_conv;
42329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42330         this_ptr_conv.is_owned = false;
42331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42332         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
42333         int64_t ret_ref = 0;
42334         if ((uintptr_t)ret_var.inner > 4096) {
42335                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42336                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42338                 ret_ref = (uintptr_t)ret_var.inner;
42339                 if (ret_var.is_owned) {
42340                         ret_ref |= 1;
42341                 }
42342         }
42343         return ret_ref;
42344 }
42345
42346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42347         LDKChannelInfo this_ptr_conv;
42348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42349         this_ptr_conv.is_owned = false;
42350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42351         LDKChannelAnnouncement val_conv;
42352         val_conv.inner = (void*)(val & (~1));
42353         val_conv.is_owned = (val & 1) || (val == 0);
42354         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42355         val_conv = ChannelAnnouncement_clone(&val_conv);
42356         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
42357 }
42358
42359 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
42360         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
42361 int64_t ret_ref = 0;
42362 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42363 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42364 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42365 ret_ref = (uintptr_t)ret_var.inner;
42366 if (ret_var.is_owned) {
42367         ret_ref |= 1;
42368 }
42369         return ret_ref;
42370 }
42371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42372         LDKChannelInfo arg_conv;
42373         arg_conv.inner = (void*)(arg & (~1));
42374         arg_conv.is_owned = false;
42375         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42376         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
42377         return ret_conv;
42378 }
42379
42380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42381         LDKChannelInfo orig_conv;
42382         orig_conv.inner = (void*)(orig & (~1));
42383         orig_conv.is_owned = false;
42384         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42385         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
42386         int64_t ret_ref = 0;
42387         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42388         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42390         ret_ref = (uintptr_t)ret_var.inner;
42391         if (ret_var.is_owned) {
42392                 ret_ref |= 1;
42393         }
42394         return ret_ref;
42395 }
42396
42397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1directional_1info(JNIEnv *env, jclass clz, int64_t this_arg, int8_t channel_flags) {
42398         LDKChannelInfo this_arg_conv;
42399         this_arg_conv.inner = (void*)(this_arg & (~1));
42400         this_arg_conv.is_owned = false;
42401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42402         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
42403         int64_t ret_ref = 0;
42404         if ((uintptr_t)ret_var.inner > 4096) {
42405                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42406                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42408                 ret_ref = (uintptr_t)ret_var.inner;
42409                 if (ret_var.is_owned) {
42410                         ret_ref |= 1;
42411                 }
42412         }
42413         return ret_ref;
42414 }
42415
42416 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
42417         LDKChannelInfo obj_conv;
42418         obj_conv.inner = (void*)(obj & (~1));
42419         obj_conv.is_owned = false;
42420         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42421         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
42422         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42423         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42424         CVec_u8Z_free(ret_var);
42425         return ret_arr;
42426 }
42427
42428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42429         LDKu8slice ser_ref;
42430         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42431         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42432         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
42433         *ret_conv = ChannelInfo_read(ser_ref);
42434         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42435         return (int64_t)ret_conv;
42436 }
42437
42438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42439         LDKDirectedChannelInfo this_obj_conv;
42440         this_obj_conv.inner = (void*)(this_obj & (~1));
42441         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42443         DirectedChannelInfo_free(this_obj_conv);
42444 }
42445
42446 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
42447         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
42448 int64_t ret_ref = 0;
42449 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42450 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42451 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42452 ret_ref = (uintptr_t)ret_var.inner;
42453 if (ret_var.is_owned) {
42454         ret_ref |= 1;
42455 }
42456         return ret_ref;
42457 }
42458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42459         LDKDirectedChannelInfo arg_conv;
42460         arg_conv.inner = (void*)(arg & (~1));
42461         arg_conv.is_owned = false;
42462         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42463         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
42464         return ret_conv;
42465 }
42466
42467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42468         LDKDirectedChannelInfo orig_conv;
42469         orig_conv.inner = (void*)(orig & (~1));
42470         orig_conv.is_owned = false;
42471         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42472         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
42473         int64_t ret_ref = 0;
42474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42477         ret_ref = (uintptr_t)ret_var.inner;
42478         if (ret_var.is_owned) {
42479                 ret_ref |= 1;
42480         }
42481         return ret_ref;
42482 }
42483
42484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
42485         LDKDirectedChannelInfo this_arg_conv;
42486         this_arg_conv.inner = (void*)(this_arg & (~1));
42487         this_arg_conv.is_owned = false;
42488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42489         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
42490         int64_t ret_ref = 0;
42491         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42492         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42494         ret_ref = (uintptr_t)ret_var.inner;
42495         if (ret_var.is_owned) {
42496                 ret_ref |= 1;
42497         }
42498         return ret_ref;
42499 }
42500
42501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
42502         LDKDirectedChannelInfo this_arg_conv;
42503         this_arg_conv.inner = (void*)(this_arg & (~1));
42504         this_arg_conv.is_owned = false;
42505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42506         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
42507         int64_t ret_ref = 0;
42508         if ((uintptr_t)ret_var.inner > 4096) {
42509                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42510                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42512                 ret_ref = (uintptr_t)ret_var.inner;
42513                 if (ret_var.is_owned) {
42514                         ret_ref |= 1;
42515                 }
42516         }
42517         return ret_ref;
42518 }
42519
42520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
42521         LDKDirectedChannelInfo this_arg_conv;
42522         this_arg_conv.inner = (void*)(this_arg & (~1));
42523         this_arg_conv.is_owned = false;
42524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42525         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
42526         return ret_conv;
42527 }
42528
42529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
42530         LDKDirectedChannelInfo this_arg_conv;
42531         this_arg_conv.inner = (void*)(this_arg & (~1));
42532         this_arg_conv.is_owned = false;
42533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42534         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42535         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
42536         int64_t ret_ref = (uintptr_t)ret_copy;
42537         return ret_ref;
42538 }
42539
42540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42541         if ((this_ptr & 1) != 0) return;
42542         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42543         CHECK_ACCESS(this_ptr_ptr);
42544         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
42545         FREE((void*)this_ptr);
42546         EffectiveCapacity_free(this_ptr_conv);
42547 }
42548
42549 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
42550         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42551         *ret_copy = EffectiveCapacity_clone(arg);
42552 int64_t ret_ref = (uintptr_t)ret_copy;
42553         return ret_ref;
42554 }
42555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42556         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
42557         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
42558         return ret_conv;
42559 }
42560
42561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42562         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
42563         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42564         *ret_copy = EffectiveCapacity_clone(orig_conv);
42565         int64_t ret_ref = (uintptr_t)ret_copy;
42566         return ret_ref;
42567 }
42568
42569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
42570         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42571         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
42572         int64_t ret_ref = (uintptr_t)ret_copy;
42573         return ret_ref;
42574 }
42575
42576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
42577         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42578         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
42579         int64_t ret_ref = (uintptr_t)ret_copy;
42580         return ret_ref;
42581 }
42582
42583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat) {
42584         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42585         *ret_copy = EffectiveCapacity_total(capacity_msat);
42586         int64_t ret_ref = (uintptr_t)ret_copy;
42587         return ret_ref;
42588 }
42589
42590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
42591         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42592         *ret_copy = EffectiveCapacity_infinite();
42593         int64_t ret_ref = (uintptr_t)ret_copy;
42594         return ret_ref;
42595 }
42596
42597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
42598         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42599         *ret_copy = EffectiveCapacity_unknown();
42600         int64_t ret_ref = (uintptr_t)ret_copy;
42601         return ret_ref;
42602 }
42603
42604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
42605         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
42606         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
42607         return ret_conv;
42608 }
42609
42610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42611         LDKRoutingFees this_obj_conv;
42612         this_obj_conv.inner = (void*)(this_obj & (~1));
42613         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42615         RoutingFees_free(this_obj_conv);
42616 }
42617
42618 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42619         LDKRoutingFees this_ptr_conv;
42620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42621         this_ptr_conv.is_owned = false;
42622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42623         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
42624         return ret_conv;
42625 }
42626
42627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42628         LDKRoutingFees this_ptr_conv;
42629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42630         this_ptr_conv.is_owned = false;
42631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42632         RoutingFees_set_base_msat(&this_ptr_conv, val);
42633 }
42634
42635 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
42636         LDKRoutingFees this_ptr_conv;
42637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42638         this_ptr_conv.is_owned = false;
42639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42640         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
42641         return ret_conv;
42642 }
42643
42644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42645         LDKRoutingFees this_ptr_conv;
42646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42647         this_ptr_conv.is_owned = false;
42648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42649         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
42650 }
42651
42652 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) {
42653         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
42654         int64_t ret_ref = 0;
42655         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42656         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42658         ret_ref = (uintptr_t)ret_var.inner;
42659         if (ret_var.is_owned) {
42660                 ret_ref |= 1;
42661         }
42662         return ret_ref;
42663 }
42664
42665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42666         LDKRoutingFees a_conv;
42667         a_conv.inner = (void*)(a & (~1));
42668         a_conv.is_owned = false;
42669         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42670         LDKRoutingFees b_conv;
42671         b_conv.inner = (void*)(b & (~1));
42672         b_conv.is_owned = false;
42673         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42674         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
42675         return ret_conv;
42676 }
42677
42678 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
42679         LDKRoutingFees ret_var = RoutingFees_clone(arg);
42680 int64_t ret_ref = 0;
42681 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42682 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42683 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42684 ret_ref = (uintptr_t)ret_var.inner;
42685 if (ret_var.is_owned) {
42686         ret_ref |= 1;
42687 }
42688         return ret_ref;
42689 }
42690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42691         LDKRoutingFees arg_conv;
42692         arg_conv.inner = (void*)(arg & (~1));
42693         arg_conv.is_owned = false;
42694         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42695         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
42696         return ret_conv;
42697 }
42698
42699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42700         LDKRoutingFees orig_conv;
42701         orig_conv.inner = (void*)(orig & (~1));
42702         orig_conv.is_owned = false;
42703         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42704         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
42705         int64_t ret_ref = 0;
42706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42709         ret_ref = (uintptr_t)ret_var.inner;
42710         if (ret_var.is_owned) {
42711                 ret_ref |= 1;
42712         }
42713         return ret_ref;
42714 }
42715
42716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
42717         LDKRoutingFees o_conv;
42718         o_conv.inner = (void*)(o & (~1));
42719         o_conv.is_owned = false;
42720         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42721         int64_t ret_conv = RoutingFees_hash(&o_conv);
42722         return ret_conv;
42723 }
42724
42725 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
42726         LDKRoutingFees obj_conv;
42727         obj_conv.inner = (void*)(obj & (~1));
42728         obj_conv.is_owned = false;
42729         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42730         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
42731         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42732         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42733         CVec_u8Z_free(ret_var);
42734         return ret_arr;
42735 }
42736
42737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42738         LDKu8slice ser_ref;
42739         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42740         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42741         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
42742         *ret_conv = RoutingFees_read(ser_ref);
42743         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42744         return (int64_t)ret_conv;
42745 }
42746
42747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42748         LDKNodeAnnouncementInfo this_obj_conv;
42749         this_obj_conv.inner = (void*)(this_obj & (~1));
42750         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42752         NodeAnnouncementInfo_free(this_obj_conv);
42753 }
42754
42755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
42756         LDKNodeAnnouncementInfo this_ptr_conv;
42757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42758         this_ptr_conv.is_owned = false;
42759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42760         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
42761         int64_t ret_ref = 0;
42762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42765         ret_ref = (uintptr_t)ret_var.inner;
42766         if (ret_var.is_owned) {
42767                 ret_ref |= 1;
42768         }
42769         return ret_ref;
42770 }
42771
42772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42773         LDKNodeAnnouncementInfo this_ptr_conv;
42774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42775         this_ptr_conv.is_owned = false;
42776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42777         LDKNodeFeatures val_conv;
42778         val_conv.inner = (void*)(val & (~1));
42779         val_conv.is_owned = (val & 1) || (val == 0);
42780         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42781         val_conv = NodeFeatures_clone(&val_conv);
42782         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
42783 }
42784
42785 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
42786         LDKNodeAnnouncementInfo this_ptr_conv;
42787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42788         this_ptr_conv.is_owned = false;
42789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42790         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
42791         return ret_conv;
42792 }
42793
42794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42795         LDKNodeAnnouncementInfo this_ptr_conv;
42796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42797         this_ptr_conv.is_owned = false;
42798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42799         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
42800 }
42801
42802 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
42803         LDKNodeAnnouncementInfo this_ptr_conv;
42804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42805         this_ptr_conv.is_owned = false;
42806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42807         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
42808         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
42809         return ret_arr;
42810 }
42811
42812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42813         LDKNodeAnnouncementInfo this_ptr_conv;
42814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42815         this_ptr_conv.is_owned = false;
42816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42817         LDKThreeBytes val_ref;
42818         CHECK((*env)->GetArrayLength(env, val) == 3);
42819         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
42820         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
42821 }
42822
42823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
42824         LDKNodeAnnouncementInfo this_ptr_conv;
42825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42826         this_ptr_conv.is_owned = false;
42827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42828         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42829         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
42830         return ret_arr;
42831 }
42832
42833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42834         LDKNodeAnnouncementInfo this_ptr_conv;
42835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42836         this_ptr_conv.is_owned = false;
42837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42838         LDKThirtyTwoBytes val_ref;
42839         CHECK((*env)->GetArrayLength(env, val) == 32);
42840         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
42841         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
42842 }
42843
42844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
42845         LDKNodeAnnouncementInfo this_ptr_conv;
42846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42847         this_ptr_conv.is_owned = false;
42848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42849         LDKCVec_NetAddressZ val_constr;
42850         val_constr.datalen = (*env)->GetArrayLength(env, val);
42851         if (val_constr.datalen > 0)
42852                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
42853         else
42854                 val_constr.data = NULL;
42855         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
42856         for (size_t m = 0; m < val_constr.datalen; m++) {
42857                 int64_t val_conv_12 = val_vals[m];
42858                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
42859                 CHECK_ACCESS(val_conv_12_ptr);
42860                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
42861                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
42862                 val_constr.data[m] = val_conv_12_conv;
42863         }
42864         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
42865         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
42866 }
42867
42868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
42869         LDKNodeAnnouncementInfo this_ptr_conv;
42870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42871         this_ptr_conv.is_owned = false;
42872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42873         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
42874         int64_t ret_ref = 0;
42875         if ((uintptr_t)ret_var.inner > 4096) {
42876                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42877                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42879                 ret_ref = (uintptr_t)ret_var.inner;
42880                 if (ret_var.is_owned) {
42881                         ret_ref |= 1;
42882                 }
42883         }
42884         return ret_ref;
42885 }
42886
42887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42888         LDKNodeAnnouncementInfo this_ptr_conv;
42889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42890         this_ptr_conv.is_owned = false;
42891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42892         LDKNodeAnnouncement val_conv;
42893         val_conv.inner = (void*)(val & (~1));
42894         val_conv.is_owned = (val & 1) || (val == 0);
42895         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42896         val_conv = NodeAnnouncement_clone(&val_conv);
42897         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
42898 }
42899
42900 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) {
42901         LDKNodeFeatures features_arg_conv;
42902         features_arg_conv.inner = (void*)(features_arg & (~1));
42903         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
42904         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
42905         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
42906         LDKThreeBytes rgb_arg_ref;
42907         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
42908         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
42909         LDKThirtyTwoBytes alias_arg_ref;
42910         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
42911         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
42912         LDKCVec_NetAddressZ addresses_arg_constr;
42913         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
42914         if (addresses_arg_constr.datalen > 0)
42915                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
42916         else
42917                 addresses_arg_constr.data = NULL;
42918         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
42919         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
42920                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
42921                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
42922                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
42923                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
42924                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
42925         }
42926         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
42927         LDKNodeAnnouncement announcement_message_arg_conv;
42928         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
42929         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
42930         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
42931         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
42932         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
42933         int64_t ret_ref = 0;
42934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42937         ret_ref = (uintptr_t)ret_var.inner;
42938         if (ret_var.is_owned) {
42939                 ret_ref |= 1;
42940         }
42941         return ret_ref;
42942 }
42943
42944 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
42945         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
42946 int64_t ret_ref = 0;
42947 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42948 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42949 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42950 ret_ref = (uintptr_t)ret_var.inner;
42951 if (ret_var.is_owned) {
42952         ret_ref |= 1;
42953 }
42954         return ret_ref;
42955 }
42956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42957         LDKNodeAnnouncementInfo arg_conv;
42958         arg_conv.inner = (void*)(arg & (~1));
42959         arg_conv.is_owned = false;
42960         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42961         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
42962         return ret_conv;
42963 }
42964
42965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42966         LDKNodeAnnouncementInfo orig_conv;
42967         orig_conv.inner = (void*)(orig & (~1));
42968         orig_conv.is_owned = false;
42969         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42970         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
42971         int64_t ret_ref = 0;
42972         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42973         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42975         ret_ref = (uintptr_t)ret_var.inner;
42976         if (ret_var.is_owned) {
42977                 ret_ref |= 1;
42978         }
42979         return ret_ref;
42980 }
42981
42982 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
42983         LDKNodeAnnouncementInfo obj_conv;
42984         obj_conv.inner = (void*)(obj & (~1));
42985         obj_conv.is_owned = false;
42986         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42987         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
42988         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42989         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42990         CVec_u8Z_free(ret_var);
42991         return ret_arr;
42992 }
42993
42994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42995         LDKu8slice ser_ref;
42996         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42997         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42998         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
42999         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
43000         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43001         return (int64_t)ret_conv;
43002 }
43003
43004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43005         LDKNodeInfo this_obj_conv;
43006         this_obj_conv.inner = (void*)(this_obj & (~1));
43007         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43009         NodeInfo_free(this_obj_conv);
43010 }
43011
43012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
43013         LDKNodeInfo this_ptr_conv;
43014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43015         this_ptr_conv.is_owned = false;
43016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43017         LDKCVec_u64Z val_constr;
43018         val_constr.datalen = (*env)->GetArrayLength(env, val);
43019         if (val_constr.datalen > 0)
43020                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
43021         else
43022                 val_constr.data = NULL;
43023         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
43024         for (size_t g = 0; g < val_constr.datalen; g++) {
43025                 int64_t val_conv_6 = val_vals[g];
43026                 val_constr.data[g] = val_conv_6;
43027         }
43028         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
43029         NodeInfo_set_channels(&this_ptr_conv, val_constr);
43030 }
43031
43032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
43033         LDKNodeInfo this_ptr_conv;
43034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43035         this_ptr_conv.is_owned = false;
43036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43037         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
43038         int64_t ret_ref = 0;
43039         if ((uintptr_t)ret_var.inner > 4096) {
43040                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43041                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43043                 ret_ref = (uintptr_t)ret_var.inner;
43044                 if (ret_var.is_owned) {
43045                         ret_ref |= 1;
43046                 }
43047         }
43048         return ret_ref;
43049 }
43050
43051 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) {
43052         LDKNodeInfo this_ptr_conv;
43053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43054         this_ptr_conv.is_owned = false;
43055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43056         LDKRoutingFees val_conv;
43057         val_conv.inner = (void*)(val & (~1));
43058         val_conv.is_owned = (val & 1) || (val == 0);
43059         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43060         val_conv = RoutingFees_clone(&val_conv);
43061         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
43062 }
43063
43064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
43065         LDKNodeInfo this_ptr_conv;
43066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43067         this_ptr_conv.is_owned = false;
43068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43069         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
43070         int64_t ret_ref = 0;
43071         if ((uintptr_t)ret_var.inner > 4096) {
43072                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43073                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43075                 ret_ref = (uintptr_t)ret_var.inner;
43076                 if (ret_var.is_owned) {
43077                         ret_ref |= 1;
43078                 }
43079         }
43080         return ret_ref;
43081 }
43082
43083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43084         LDKNodeInfo this_ptr_conv;
43085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43086         this_ptr_conv.is_owned = false;
43087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43088         LDKNodeAnnouncementInfo val_conv;
43089         val_conv.inner = (void*)(val & (~1));
43090         val_conv.is_owned = (val & 1) || (val == 0);
43091         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43092         val_conv = NodeAnnouncementInfo_clone(&val_conv);
43093         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
43094 }
43095
43096 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) {
43097         LDKCVec_u64Z channels_arg_constr;
43098         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
43099         if (channels_arg_constr.datalen > 0)
43100                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
43101         else
43102                 channels_arg_constr.data = NULL;
43103         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
43104         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
43105                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
43106                 channels_arg_constr.data[g] = channels_arg_conv_6;
43107         }
43108         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
43109         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
43110         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
43111         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
43112         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
43113         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
43114         LDKNodeAnnouncementInfo announcement_info_arg_conv;
43115         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
43116         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
43117         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
43118         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
43119         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
43120         int64_t ret_ref = 0;
43121         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43122         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43124         ret_ref = (uintptr_t)ret_var.inner;
43125         if (ret_var.is_owned) {
43126                 ret_ref |= 1;
43127         }
43128         return ret_ref;
43129 }
43130
43131 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
43132         LDKNodeInfo ret_var = NodeInfo_clone(arg);
43133 int64_t ret_ref = 0;
43134 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43135 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43136 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43137 ret_ref = (uintptr_t)ret_var.inner;
43138 if (ret_var.is_owned) {
43139         ret_ref |= 1;
43140 }
43141         return ret_ref;
43142 }
43143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43144         LDKNodeInfo arg_conv;
43145         arg_conv.inner = (void*)(arg & (~1));
43146         arg_conv.is_owned = false;
43147         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43148         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
43149         return ret_conv;
43150 }
43151
43152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43153         LDKNodeInfo orig_conv;
43154         orig_conv.inner = (void*)(orig & (~1));
43155         orig_conv.is_owned = false;
43156         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43157         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
43158         int64_t ret_ref = 0;
43159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43162         ret_ref = (uintptr_t)ret_var.inner;
43163         if (ret_var.is_owned) {
43164                 ret_ref |= 1;
43165         }
43166         return ret_ref;
43167 }
43168
43169 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43170         LDKNodeInfo obj_conv;
43171         obj_conv.inner = (void*)(obj & (~1));
43172         obj_conv.is_owned = false;
43173         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43174         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
43175         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43176         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43177         CVec_u8Z_free(ret_var);
43178         return ret_arr;
43179 }
43180
43181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43182         LDKu8slice ser_ref;
43183         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43184         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43185         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
43186         *ret_conv = NodeInfo_read(ser_ref);
43187         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43188         return (int64_t)ret_conv;
43189 }
43190
43191 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
43192         LDKNetworkGraph obj_conv;
43193         obj_conv.inner = (void*)(obj & (~1));
43194         obj_conv.is_owned = false;
43195         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43196         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
43197         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43198         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43199         CVec_u8Z_free(ret_var);
43200         return ret_arr;
43201 }
43202
43203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
43204         LDKu8slice ser_ref;
43205         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43206         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43207         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
43208         CHECK_ACCESS(arg_ptr);
43209         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
43210         if (arg_conv.free == LDKLogger_JCalls_free) {
43211                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43212                 LDKLogger_JCalls_cloned(&arg_conv);
43213         }
43214         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
43215         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
43216         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43217         return (int64_t)ret_conv;
43218 }
43219
43220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t logger) {
43221         LDKThirtyTwoBytes genesis_hash_ref;
43222         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
43223         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
43224         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43225         CHECK_ACCESS(logger_ptr);
43226         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43227         if (logger_conv.free == LDKLogger_JCalls_free) {
43228                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43229                 LDKLogger_JCalls_cloned(&logger_conv);
43230         }
43231         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
43232         int64_t ret_ref = 0;
43233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43236         ret_ref = (uintptr_t)ret_var.inner;
43237         if (ret_var.is_owned) {
43238                 ret_ref |= 1;
43239         }
43240         return ret_ref;
43241 }
43242
43243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
43244         LDKNetworkGraph this_arg_conv;
43245         this_arg_conv.inner = (void*)(this_arg & (~1));
43246         this_arg_conv.is_owned = false;
43247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43248         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
43249         int64_t ret_ref = 0;
43250         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43251         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43253         ret_ref = (uintptr_t)ret_var.inner;
43254         if (ret_var.is_owned) {
43255                 ret_ref |= 1;
43256         }
43257         return ret_ref;
43258 }
43259
43260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
43261         LDKNetworkGraph this_arg_conv;
43262         this_arg_conv.inner = (void*)(this_arg & (~1));
43263         this_arg_conv.is_owned = false;
43264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43265         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
43266         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
43267         int64_t ret_ref = (uintptr_t)ret_copy;
43268         return ret_ref;
43269 }
43270
43271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1set_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg, int32_t last_rapid_gossip_sync_timestamp) {
43272         LDKNetworkGraph this_arg_conv;
43273         this_arg_conv.inner = (void*)(this_arg & (~1));
43274         this_arg_conv.is_owned = false;
43275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43276         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
43277 }
43278
43279 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) {
43280         LDKNetworkGraph this_arg_conv;
43281         this_arg_conv.inner = (void*)(this_arg & (~1));
43282         this_arg_conv.is_owned = false;
43283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43284         LDKNodeAnnouncement msg_conv;
43285         msg_conv.inner = (void*)(msg & (~1));
43286         msg_conv.is_owned = false;
43287         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43288         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43289         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
43290         return (int64_t)ret_conv;
43291 }
43292
43293 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) {
43294         LDKNetworkGraph this_arg_conv;
43295         this_arg_conv.inner = (void*)(this_arg & (~1));
43296         this_arg_conv.is_owned = false;
43297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43298         LDKUnsignedNodeAnnouncement msg_conv;
43299         msg_conv.inner = (void*)(msg & (~1));
43300         msg_conv.is_owned = false;
43301         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43302         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43303         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
43304         return (int64_t)ret_conv;
43305 }
43306
43307 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) {
43308         LDKNetworkGraph this_arg_conv;
43309         this_arg_conv.inner = (void*)(this_arg & (~1));
43310         this_arg_conv.is_owned = false;
43311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43312         LDKChannelAnnouncement msg_conv;
43313         msg_conv.inner = (void*)(msg & (~1));
43314         msg_conv.is_owned = false;
43315         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43316         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
43317         CHECK_ACCESS(chain_access_ptr);
43318         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
43319         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
43320         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
43321                 // Manually implement clone for Java trait instances
43322                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
43323                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43324                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
43325                 }
43326         }
43327         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43328         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
43329         return (int64_t)ret_conv;
43330 }
43331
43332 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) {
43333         LDKNetworkGraph this_arg_conv;
43334         this_arg_conv.inner = (void*)(this_arg & (~1));
43335         this_arg_conv.is_owned = false;
43336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43337         LDKUnsignedChannelAnnouncement msg_conv;
43338         msg_conv.inner = (void*)(msg & (~1));
43339         msg_conv.is_owned = false;
43340         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43341         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
43342         CHECK_ACCESS(chain_access_ptr);
43343         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
43344         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
43345         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
43346                 // Manually implement clone for Java trait instances
43347                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
43348                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43349                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
43350                 }
43351         }
43352         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43353         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
43354         return (int64_t)ret_conv;
43355 }
43356
43357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1add_1channel_1from_1partial_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t timestamp, int64_t features, int8_tArray node_id_1, int8_tArray node_id_2) {
43358         LDKNetworkGraph this_arg_conv;
43359         this_arg_conv.inner = (void*)(this_arg & (~1));
43360         this_arg_conv.is_owned = false;
43361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43362         LDKChannelFeatures features_conv;
43363         features_conv.inner = (void*)(features & (~1));
43364         features_conv.is_owned = (features & 1) || (features == 0);
43365         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
43366         features_conv = ChannelFeatures_clone(&features_conv);
43367         LDKPublicKey node_id_1_ref;
43368         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
43369         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
43370         LDKPublicKey node_id_2_ref;
43371         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
43372         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
43373         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43374         *ret_conv = NetworkGraph_add_channel_from_partial_announcement(&this_arg_conv, short_channel_id, timestamp, features_conv, node_id_1_ref, node_id_2_ref);
43375         return (int64_t)ret_conv;
43376 }
43377
43378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1channel_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
43379         LDKNetworkGraph this_arg_conv;
43380         this_arg_conv.inner = (void*)(this_arg & (~1));
43381         this_arg_conv.is_owned = false;
43382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43383         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
43384 }
43385
43386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
43387         LDKNetworkGraph this_arg_conv;
43388         this_arg_conv.inner = (void*)(this_arg & (~1));
43389         this_arg_conv.is_owned = false;
43390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43391         LDKPublicKey _node_id_ref;
43392         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
43393         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
43394         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
43395 }
43396
43397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
43398         LDKNetworkGraph this_arg_conv;
43399         this_arg_conv.inner = (void*)(this_arg & (~1));
43400         this_arg_conv.is_owned = false;
43401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43402         NetworkGraph_remove_stale_channels(&this_arg_conv);
43403 }
43404
43405 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) {
43406         LDKNetworkGraph this_arg_conv;
43407         this_arg_conv.inner = (void*)(this_arg & (~1));
43408         this_arg_conv.is_owned = false;
43409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43410         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
43411 }
43412
43413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
43414         LDKNetworkGraph this_arg_conv;
43415         this_arg_conv.inner = (void*)(this_arg & (~1));
43416         this_arg_conv.is_owned = false;
43417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43418         LDKChannelUpdate msg_conv;
43419         msg_conv.inner = (void*)(msg & (~1));
43420         msg_conv.is_owned = false;
43421         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43422         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43423         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
43424         return (int64_t)ret_conv;
43425 }
43426
43427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
43428         LDKNetworkGraph this_arg_conv;
43429         this_arg_conv.inner = (void*)(this_arg & (~1));
43430         this_arg_conv.is_owned = false;
43431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43432         LDKUnsignedChannelUpdate msg_conv;
43433         msg_conv.inner = (void*)(msg & (~1));
43434         msg_conv.is_owned = false;
43435         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43436         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43437         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
43438         return (int64_t)ret_conv;
43439 }
43440
43441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
43442         LDKReadOnlyNetworkGraph this_arg_conv;
43443         this_arg_conv.inner = (void*)(this_arg & (~1));
43444         this_arg_conv.is_owned = false;
43445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43446         LDKPublicKey pubkey_ref;
43447         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
43448         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
43449         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
43450         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
43451         int64_t ret_ref = (uintptr_t)ret_copy;
43452         return ret_ref;
43453 }
43454
43455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43456         LDKRouteHop this_obj_conv;
43457         this_obj_conv.inner = (void*)(this_obj & (~1));
43458         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43460         RouteHop_free(this_obj_conv);
43461 }
43462
43463 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
43464         LDKRouteHop this_ptr_conv;
43465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43466         this_ptr_conv.is_owned = false;
43467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43468         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
43469         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
43470         return ret_arr;
43471 }
43472
43473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43474         LDKRouteHop this_ptr_conv;
43475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43476         this_ptr_conv.is_owned = false;
43477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43478         LDKPublicKey val_ref;
43479         CHECK((*env)->GetArrayLength(env, val) == 33);
43480         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
43481         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
43482 }
43483
43484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43485         LDKRouteHop this_ptr_conv;
43486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43487         this_ptr_conv.is_owned = false;
43488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43489         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
43490         int64_t ret_ref = 0;
43491         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43492         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43494         ret_ref = (uintptr_t)ret_var.inner;
43495         if (ret_var.is_owned) {
43496                 ret_ref |= 1;
43497         }
43498         return ret_ref;
43499 }
43500
43501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43502         LDKRouteHop this_ptr_conv;
43503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43504         this_ptr_conv.is_owned = false;
43505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43506         LDKNodeFeatures val_conv;
43507         val_conv.inner = (void*)(val & (~1));
43508         val_conv.is_owned = (val & 1) || (val == 0);
43509         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43510         val_conv = NodeFeatures_clone(&val_conv);
43511         RouteHop_set_node_features(&this_ptr_conv, val_conv);
43512 }
43513
43514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
43515         LDKRouteHop this_ptr_conv;
43516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43517         this_ptr_conv.is_owned = false;
43518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43519         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
43520         return ret_conv;
43521 }
43522
43523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43524         LDKRouteHop this_ptr_conv;
43525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43526         this_ptr_conv.is_owned = false;
43527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43528         RouteHop_set_short_channel_id(&this_ptr_conv, val);
43529 }
43530
43531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43532         LDKRouteHop this_ptr_conv;
43533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43534         this_ptr_conv.is_owned = false;
43535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43536         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
43537         int64_t ret_ref = 0;
43538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43541         ret_ref = (uintptr_t)ret_var.inner;
43542         if (ret_var.is_owned) {
43543                 ret_ref |= 1;
43544         }
43545         return ret_ref;
43546 }
43547
43548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43549         LDKRouteHop this_ptr_conv;
43550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43551         this_ptr_conv.is_owned = false;
43552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43553         LDKChannelFeatures val_conv;
43554         val_conv.inner = (void*)(val & (~1));
43555         val_conv.is_owned = (val & 1) || (val == 0);
43556         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43557         val_conv = ChannelFeatures_clone(&val_conv);
43558         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
43559 }
43560
43561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43562         LDKRouteHop this_ptr_conv;
43563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43564         this_ptr_conv.is_owned = false;
43565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43566         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
43567         return ret_conv;
43568 }
43569
43570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43571         LDKRouteHop this_ptr_conv;
43572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43573         this_ptr_conv.is_owned = false;
43574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43575         RouteHop_set_fee_msat(&this_ptr_conv, val);
43576 }
43577
43578 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
43579         LDKRouteHop this_ptr_conv;
43580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43581         this_ptr_conv.is_owned = false;
43582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43583         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
43584         return ret_conv;
43585 }
43586
43587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43588         LDKRouteHop this_ptr_conv;
43589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43590         this_ptr_conv.is_owned = false;
43591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43592         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
43593 }
43594
43595 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) {
43596         LDKPublicKey pubkey_arg_ref;
43597         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
43598         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
43599         LDKNodeFeatures node_features_arg_conv;
43600         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
43601         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
43602         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
43603         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
43604         LDKChannelFeatures channel_features_arg_conv;
43605         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
43606         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
43607         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
43608         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
43609         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);
43610         int64_t ret_ref = 0;
43611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43614         ret_ref = (uintptr_t)ret_var.inner;
43615         if (ret_var.is_owned) {
43616                 ret_ref |= 1;
43617         }
43618         return ret_ref;
43619 }
43620
43621 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
43622         LDKRouteHop ret_var = RouteHop_clone(arg);
43623 int64_t ret_ref = 0;
43624 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43625 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43626 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43627 ret_ref = (uintptr_t)ret_var.inner;
43628 if (ret_var.is_owned) {
43629         ret_ref |= 1;
43630 }
43631         return ret_ref;
43632 }
43633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43634         LDKRouteHop arg_conv;
43635         arg_conv.inner = (void*)(arg & (~1));
43636         arg_conv.is_owned = false;
43637         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43638         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
43639         return ret_conv;
43640 }
43641
43642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43643         LDKRouteHop orig_conv;
43644         orig_conv.inner = (void*)(orig & (~1));
43645         orig_conv.is_owned = false;
43646         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43647         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
43648         int64_t ret_ref = 0;
43649         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43650         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43652         ret_ref = (uintptr_t)ret_var.inner;
43653         if (ret_var.is_owned) {
43654                 ret_ref |= 1;
43655         }
43656         return ret_ref;
43657 }
43658
43659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
43660         LDKRouteHop o_conv;
43661         o_conv.inner = (void*)(o & (~1));
43662         o_conv.is_owned = false;
43663         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43664         int64_t ret_conv = RouteHop_hash(&o_conv);
43665         return ret_conv;
43666 }
43667
43668 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43669         LDKRouteHop a_conv;
43670         a_conv.inner = (void*)(a & (~1));
43671         a_conv.is_owned = false;
43672         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43673         LDKRouteHop b_conv;
43674         b_conv.inner = (void*)(b & (~1));
43675         b_conv.is_owned = false;
43676         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43677         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
43678         return ret_conv;
43679 }
43680
43681 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
43682         LDKRouteHop obj_conv;
43683         obj_conv.inner = (void*)(obj & (~1));
43684         obj_conv.is_owned = false;
43685         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43686         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
43687         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43688         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43689         CVec_u8Z_free(ret_var);
43690         return ret_arr;
43691 }
43692
43693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43694         LDKu8slice ser_ref;
43695         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43696         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43697         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
43698         *ret_conv = RouteHop_read(ser_ref);
43699         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43700         return (int64_t)ret_conv;
43701 }
43702
43703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43704         LDKRoute this_obj_conv;
43705         this_obj_conv.inner = (void*)(this_obj & (~1));
43706         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43708         Route_free(this_obj_conv);
43709 }
43710
43711 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
43712         LDKRoute this_ptr_conv;
43713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43714         this_ptr_conv.is_owned = false;
43715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43716         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
43717         jobjectArray ret_arr = NULL;
43718         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
43719         ;
43720         for (size_t m = 0; m < ret_var.datalen; m++) {
43721                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
43722                 int64_tArray ret_conv_12_arr = NULL;
43723                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
43724                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
43725                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
43726                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
43727                         int64_t ret_conv_12_conv_10_ref = 0;
43728                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43729                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43730                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
43731                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
43732                         if (ret_conv_12_conv_10_var.is_owned) {
43733                                 ret_conv_12_conv_10_ref |= 1;
43734                         }
43735                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
43736                 }
43737                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
43738                 FREE(ret_conv_12_var.data);
43739                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
43740         }
43741         
43742         FREE(ret_var.data);
43743         return ret_arr;
43744 }
43745
43746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
43747         LDKRoute this_ptr_conv;
43748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43749         this_ptr_conv.is_owned = false;
43750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43751         LDKCVec_CVec_RouteHopZZ val_constr;
43752         val_constr.datalen = (*env)->GetArrayLength(env, val);
43753         if (val_constr.datalen > 0)
43754                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
43755         else
43756                 val_constr.data = NULL;
43757         for (size_t m = 0; m < val_constr.datalen; m++) {
43758                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
43759                 LDKCVec_RouteHopZ val_conv_12_constr;
43760                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
43761                 if (val_conv_12_constr.datalen > 0)
43762                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
43763                 else
43764                         val_conv_12_constr.data = NULL;
43765                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
43766                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
43767                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
43768                         LDKRouteHop val_conv_12_conv_10_conv;
43769                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
43770                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
43771                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
43772                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
43773                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
43774                 }
43775                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
43776                 val_constr.data[m] = val_conv_12_constr;
43777         }
43778         Route_set_paths(&this_ptr_conv, val_constr);
43779 }
43780
43781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
43782         LDKRoute this_ptr_conv;
43783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43784         this_ptr_conv.is_owned = false;
43785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43786         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
43787         int64_t ret_ref = 0;
43788         if ((uintptr_t)ret_var.inner > 4096) {
43789                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43790                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43792                 ret_ref = (uintptr_t)ret_var.inner;
43793                 if (ret_var.is_owned) {
43794                         ret_ref |= 1;
43795                 }
43796         }
43797         return ret_ref;
43798 }
43799
43800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43801         LDKRoute this_ptr_conv;
43802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43803         this_ptr_conv.is_owned = false;
43804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43805         LDKPaymentParameters val_conv;
43806         val_conv.inner = (void*)(val & (~1));
43807         val_conv.is_owned = (val & 1) || (val == 0);
43808         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43809         val_conv = PaymentParameters_clone(&val_conv);
43810         Route_set_payment_params(&this_ptr_conv, val_conv);
43811 }
43812
43813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
43814         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
43815         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
43816         if (paths_arg_constr.datalen > 0)
43817                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
43818         else
43819                 paths_arg_constr.data = NULL;
43820         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
43821                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
43822                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
43823                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
43824                 if (paths_arg_conv_12_constr.datalen > 0)
43825                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
43826                 else
43827                         paths_arg_conv_12_constr.data = NULL;
43828                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
43829                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
43830                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
43831                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
43832                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
43833                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
43834                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
43835                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
43836                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
43837                 }
43838                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
43839                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
43840         }
43841         LDKPaymentParameters payment_params_arg_conv;
43842         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
43843         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
43844         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
43845         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
43846         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
43847         int64_t ret_ref = 0;
43848         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43849         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43851         ret_ref = (uintptr_t)ret_var.inner;
43852         if (ret_var.is_owned) {
43853                 ret_ref |= 1;
43854         }
43855         return ret_ref;
43856 }
43857
43858 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
43859         LDKRoute ret_var = Route_clone(arg);
43860 int64_t ret_ref = 0;
43861 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43862 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43863 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43864 ret_ref = (uintptr_t)ret_var.inner;
43865 if (ret_var.is_owned) {
43866         ret_ref |= 1;
43867 }
43868         return ret_ref;
43869 }
43870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43871         LDKRoute arg_conv;
43872         arg_conv.inner = (void*)(arg & (~1));
43873         arg_conv.is_owned = false;
43874         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43875         int64_t ret_conv = Route_clone_ptr(&arg_conv);
43876         return ret_conv;
43877 }
43878
43879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43880         LDKRoute orig_conv;
43881         orig_conv.inner = (void*)(orig & (~1));
43882         orig_conv.is_owned = false;
43883         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43884         LDKRoute ret_var = Route_clone(&orig_conv);
43885         int64_t ret_ref = 0;
43886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43889         ret_ref = (uintptr_t)ret_var.inner;
43890         if (ret_var.is_owned) {
43891                 ret_ref |= 1;
43892         }
43893         return ret_ref;
43894 }
43895
43896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
43897         LDKRoute o_conv;
43898         o_conv.inner = (void*)(o & (~1));
43899         o_conv.is_owned = false;
43900         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43901         int64_t ret_conv = Route_hash(&o_conv);
43902         return ret_conv;
43903 }
43904
43905 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43906         LDKRoute a_conv;
43907         a_conv.inner = (void*)(a & (~1));
43908         a_conv.is_owned = false;
43909         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43910         LDKRoute b_conv;
43911         b_conv.inner = (void*)(b & (~1));
43912         b_conv.is_owned = false;
43913         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43914         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
43915         return ret_conv;
43916 }
43917
43918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
43919         LDKRoute this_arg_conv;
43920         this_arg_conv.inner = (void*)(this_arg & (~1));
43921         this_arg_conv.is_owned = false;
43922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43923         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
43924         return ret_conv;
43925 }
43926
43927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
43928         LDKRoute this_arg_conv;
43929         this_arg_conv.inner = (void*)(this_arg & (~1));
43930         this_arg_conv.is_owned = false;
43931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43932         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
43933         return ret_conv;
43934 }
43935
43936 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
43937         LDKRoute obj_conv;
43938         obj_conv.inner = (void*)(obj & (~1));
43939         obj_conv.is_owned = false;
43940         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43941         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
43942         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43943         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43944         CVec_u8Z_free(ret_var);
43945         return ret_arr;
43946 }
43947
43948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43949         LDKu8slice ser_ref;
43950         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43951         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43952         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
43953         *ret_conv = Route_read(ser_ref);
43954         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43955         return (int64_t)ret_conv;
43956 }
43957
43958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43959         LDKRouteParameters this_obj_conv;
43960         this_obj_conv.inner = (void*)(this_obj & (~1));
43961         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43963         RouteParameters_free(this_obj_conv);
43964 }
43965
43966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
43967         LDKRouteParameters this_ptr_conv;
43968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43969         this_ptr_conv.is_owned = false;
43970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43971         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
43972         int64_t ret_ref = 0;
43973         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43974         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43976         ret_ref = (uintptr_t)ret_var.inner;
43977         if (ret_var.is_owned) {
43978                 ret_ref |= 1;
43979         }
43980         return ret_ref;
43981 }
43982
43983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43984         LDKRouteParameters this_ptr_conv;
43985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43986         this_ptr_conv.is_owned = false;
43987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43988         LDKPaymentParameters val_conv;
43989         val_conv.inner = (void*)(val & (~1));
43990         val_conv.is_owned = (val & 1) || (val == 0);
43991         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43992         val_conv = PaymentParameters_clone(&val_conv);
43993         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
43994 }
43995
43996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43997         LDKRouteParameters this_ptr_conv;
43998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43999         this_ptr_conv.is_owned = false;
44000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44001         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
44002         return ret_conv;
44003 }
44004
44005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44006         LDKRouteParameters this_ptr_conv;
44007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44008         this_ptr_conv.is_owned = false;
44009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44010         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
44011 }
44012
44013 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44014         LDKRouteParameters this_ptr_conv;
44015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44016         this_ptr_conv.is_owned = false;
44017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44018         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
44019         return ret_conv;
44020 }
44021
44022 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) {
44023         LDKRouteParameters this_ptr_conv;
44024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44025         this_ptr_conv.is_owned = false;
44026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44027         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
44028 }
44029
44030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1new(JNIEnv *env, jclass clz, int64_t payment_params_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
44031         LDKPaymentParameters payment_params_arg_conv;
44032         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
44033         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
44034         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
44035         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
44036         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
44037         int64_t ret_ref = 0;
44038         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44039         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44041         ret_ref = (uintptr_t)ret_var.inner;
44042         if (ret_var.is_owned) {
44043                 ret_ref |= 1;
44044         }
44045         return ret_ref;
44046 }
44047
44048 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
44049         LDKRouteParameters ret_var = RouteParameters_clone(arg);
44050 int64_t ret_ref = 0;
44051 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44052 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44053 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44054 ret_ref = (uintptr_t)ret_var.inner;
44055 if (ret_var.is_owned) {
44056         ret_ref |= 1;
44057 }
44058         return ret_ref;
44059 }
44060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44061         LDKRouteParameters arg_conv;
44062         arg_conv.inner = (void*)(arg & (~1));
44063         arg_conv.is_owned = false;
44064         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44065         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
44066         return ret_conv;
44067 }
44068
44069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44070         LDKRouteParameters orig_conv;
44071         orig_conv.inner = (void*)(orig & (~1));
44072         orig_conv.is_owned = false;
44073         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44074         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
44075         int64_t ret_ref = 0;
44076         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44077         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44079         ret_ref = (uintptr_t)ret_var.inner;
44080         if (ret_var.is_owned) {
44081                 ret_ref |= 1;
44082         }
44083         return ret_ref;
44084 }
44085
44086 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
44087         LDKRouteParameters obj_conv;
44088         obj_conv.inner = (void*)(obj & (~1));
44089         obj_conv.is_owned = false;
44090         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44091         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
44092         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44093         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44094         CVec_u8Z_free(ret_var);
44095         return ret_arr;
44096 }
44097
44098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44099         LDKu8slice ser_ref;
44100         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44101         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44102         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
44103         *ret_conv = RouteParameters_read(ser_ref);
44104         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44105         return (int64_t)ret_conv;
44106 }
44107
44108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44109         LDKPaymentParameters this_obj_conv;
44110         this_obj_conv.inner = (void*)(this_obj & (~1));
44111         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44113         PaymentParameters_free(this_obj_conv);
44114 }
44115
44116 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
44117         LDKPaymentParameters this_ptr_conv;
44118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44119         this_ptr_conv.is_owned = false;
44120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44121         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44122         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
44123         return ret_arr;
44124 }
44125
44126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44127         LDKPaymentParameters this_ptr_conv;
44128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44129         this_ptr_conv.is_owned = false;
44130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44131         LDKPublicKey val_ref;
44132         CHECK((*env)->GetArrayLength(env, val) == 33);
44133         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
44134         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
44135 }
44136
44137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44138         LDKPaymentParameters this_ptr_conv;
44139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44140         this_ptr_conv.is_owned = false;
44141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44142         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
44143         int64_t ret_ref = 0;
44144         if ((uintptr_t)ret_var.inner > 4096) {
44145                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44146                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44148                 ret_ref = (uintptr_t)ret_var.inner;
44149                 if (ret_var.is_owned) {
44150                         ret_ref |= 1;
44151                 }
44152         }
44153         return ret_ref;
44154 }
44155
44156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44157         LDKPaymentParameters this_ptr_conv;
44158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44159         this_ptr_conv.is_owned = false;
44160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44161         LDKInvoiceFeatures val_conv;
44162         val_conv.inner = (void*)(val & (~1));
44163         val_conv.is_owned = (val & 1) || (val == 0);
44164         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44165         val_conv = InvoiceFeatures_clone(&val_conv);
44166         PaymentParameters_set_features(&this_ptr_conv, val_conv);
44167 }
44168
44169 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
44170         LDKPaymentParameters this_ptr_conv;
44171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44172         this_ptr_conv.is_owned = false;
44173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44174         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
44175         int64_tArray ret_arr = NULL;
44176         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44177         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44178         for (size_t l = 0; l < ret_var.datalen; l++) {
44179                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
44180                 int64_t ret_conv_11_ref = 0;
44181                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44182                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44183                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
44184                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
44185                 if (ret_conv_11_var.is_owned) {
44186                         ret_conv_11_ref |= 1;
44187                 }
44188                 ret_arr_ptr[l] = ret_conv_11_ref;
44189         }
44190         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44191         FREE(ret_var.data);
44192         return ret_arr;
44193 }
44194
44195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44196         LDKPaymentParameters this_ptr_conv;
44197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44198         this_ptr_conv.is_owned = false;
44199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44200         LDKCVec_RouteHintZ val_constr;
44201         val_constr.datalen = (*env)->GetArrayLength(env, val);
44202         if (val_constr.datalen > 0)
44203                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
44204         else
44205                 val_constr.data = NULL;
44206         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44207         for (size_t l = 0; l < val_constr.datalen; l++) {
44208                 int64_t val_conv_11 = val_vals[l];
44209                 LDKRouteHint val_conv_11_conv;
44210                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
44211                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
44212                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
44213                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
44214                 val_constr.data[l] = val_conv_11_conv;
44215         }
44216         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44217         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
44218 }
44219
44220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
44221         LDKPaymentParameters this_ptr_conv;
44222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44223         this_ptr_conv.is_owned = false;
44224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44225         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44226         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
44227         int64_t ret_ref = (uintptr_t)ret_copy;
44228         return ret_ref;
44229 }
44230
44231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44232         LDKPaymentParameters this_ptr_conv;
44233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44234         this_ptr_conv.is_owned = false;
44235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44236         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
44237         CHECK_ACCESS(val_ptr);
44238         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
44239         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
44240         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
44241 }
44242
44243 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44244         LDKPaymentParameters this_ptr_conv;
44245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44246         this_ptr_conv.is_owned = false;
44247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44248         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
44249         return ret_conv;
44250 }
44251
44252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
44253         LDKPaymentParameters this_ptr_conv;
44254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44255         this_ptr_conv.is_owned = false;
44256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44257         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
44258 }
44259
44260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1new(JNIEnv *env, jclass clz, int8_tArray payee_pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg, int32_t max_total_cltv_expiry_delta_arg) {
44261         LDKPublicKey payee_pubkey_arg_ref;
44262         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
44263         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
44264         LDKInvoiceFeatures features_arg_conv;
44265         features_arg_conv.inner = (void*)(features_arg & (~1));
44266         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
44267         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
44268         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
44269         LDKCVec_RouteHintZ route_hints_arg_constr;
44270         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
44271         if (route_hints_arg_constr.datalen > 0)
44272                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
44273         else
44274                 route_hints_arg_constr.data = NULL;
44275         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
44276         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
44277                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
44278                 LDKRouteHint route_hints_arg_conv_11_conv;
44279                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
44280                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
44281                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
44282                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
44283                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
44284         }
44285         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
44286         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
44287         CHECK_ACCESS(expiry_time_arg_ptr);
44288         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
44289         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
44290         LDKPaymentParameters ret_var = PaymentParameters_new(payee_pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv, max_total_cltv_expiry_delta_arg);
44291         int64_t ret_ref = 0;
44292         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44293         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44295         ret_ref = (uintptr_t)ret_var.inner;
44296         if (ret_var.is_owned) {
44297                 ret_ref |= 1;
44298         }
44299         return ret_ref;
44300 }
44301
44302 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
44303         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
44304 int64_t ret_ref = 0;
44305 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44306 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44307 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44308 ret_ref = (uintptr_t)ret_var.inner;
44309 if (ret_var.is_owned) {
44310         ret_ref |= 1;
44311 }
44312         return ret_ref;
44313 }
44314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44315         LDKPaymentParameters arg_conv;
44316         arg_conv.inner = (void*)(arg & (~1));
44317         arg_conv.is_owned = false;
44318         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44319         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
44320         return ret_conv;
44321 }
44322
44323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44324         LDKPaymentParameters orig_conv;
44325         orig_conv.inner = (void*)(orig & (~1));
44326         orig_conv.is_owned = false;
44327         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44328         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
44329         int64_t ret_ref = 0;
44330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44333         ret_ref = (uintptr_t)ret_var.inner;
44334         if (ret_var.is_owned) {
44335                 ret_ref |= 1;
44336         }
44337         return ret_ref;
44338 }
44339
44340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
44341         LDKPaymentParameters o_conv;
44342         o_conv.inner = (void*)(o & (~1));
44343         o_conv.is_owned = false;
44344         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44345         int64_t ret_conv = PaymentParameters_hash(&o_conv);
44346         return ret_conv;
44347 }
44348
44349 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44350         LDKPaymentParameters a_conv;
44351         a_conv.inner = (void*)(a & (~1));
44352         a_conv.is_owned = false;
44353         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44354         LDKPaymentParameters b_conv;
44355         b_conv.inner = (void*)(b & (~1));
44356         b_conv.is_owned = false;
44357         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44358         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
44359         return ret_conv;
44360 }
44361
44362 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
44363         LDKPaymentParameters obj_conv;
44364         obj_conv.inner = (void*)(obj & (~1));
44365         obj_conv.is_owned = false;
44366         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44367         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
44368         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44369         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44370         CVec_u8Z_free(ret_var);
44371         return ret_arr;
44372 }
44373
44374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44375         LDKu8slice ser_ref;
44376         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44377         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44378         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
44379         *ret_conv = PaymentParameters_read(ser_ref);
44380         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44381         return (int64_t)ret_conv;
44382 }
44383
44384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
44385         LDKPublicKey payee_pubkey_ref;
44386         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
44387         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
44388         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
44389         int64_t ret_ref = 0;
44390         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44391         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44393         ret_ref = (uintptr_t)ret_var.inner;
44394         if (ret_var.is_owned) {
44395                 ret_ref |= 1;
44396         }
44397         return ret_ref;
44398 }
44399
44400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
44401         LDKPublicKey payee_pubkey_ref;
44402         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
44403         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
44404         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
44405         int64_t ret_ref = 0;
44406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44409         ret_ref = (uintptr_t)ret_var.inner;
44410         if (ret_var.is_owned) {
44411                 ret_ref |= 1;
44412         }
44413         return ret_ref;
44414 }
44415
44416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44417         LDKRouteHint this_obj_conv;
44418         this_obj_conv.inner = (void*)(this_obj & (~1));
44419         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44421         RouteHint_free(this_obj_conv);
44422 }
44423
44424 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44425         LDKRouteHint this_ptr_conv;
44426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44427         this_ptr_conv.is_owned = false;
44428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44429         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
44430         int64_tArray ret_arr = NULL;
44431         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44432         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44433         for (size_t o = 0; o < ret_var.datalen; o++) {
44434                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
44435                 int64_t ret_conv_14_ref = 0;
44436                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44437                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44438                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44439                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
44440                 if (ret_conv_14_var.is_owned) {
44441                         ret_conv_14_ref |= 1;
44442                 }
44443                 ret_arr_ptr[o] = ret_conv_14_ref;
44444         }
44445         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44446         FREE(ret_var.data);
44447         return ret_arr;
44448 }
44449
44450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44451         LDKRouteHint this_ptr_conv;
44452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44453         this_ptr_conv.is_owned = false;
44454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44455         LDKCVec_RouteHintHopZ val_constr;
44456         val_constr.datalen = (*env)->GetArrayLength(env, val);
44457         if (val_constr.datalen > 0)
44458                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
44459         else
44460                 val_constr.data = NULL;
44461         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44462         for (size_t o = 0; o < val_constr.datalen; o++) {
44463                 int64_t val_conv_14 = val_vals[o];
44464                 LDKRouteHintHop val_conv_14_conv;
44465                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
44466                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
44467                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
44468                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
44469                 val_constr.data[o] = val_conv_14_conv;
44470         }
44471         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44472         RouteHint_set_a(&this_ptr_conv, val_constr);
44473 }
44474
44475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
44476         LDKCVec_RouteHintHopZ a_arg_constr;
44477         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
44478         if (a_arg_constr.datalen > 0)
44479                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
44480         else
44481                 a_arg_constr.data = NULL;
44482         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
44483         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
44484                 int64_t a_arg_conv_14 = a_arg_vals[o];
44485                 LDKRouteHintHop a_arg_conv_14_conv;
44486                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
44487                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
44488                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
44489                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
44490                 a_arg_constr.data[o] = a_arg_conv_14_conv;
44491         }
44492         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
44493         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
44494         int64_t ret_ref = 0;
44495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44498         ret_ref = (uintptr_t)ret_var.inner;
44499         if (ret_var.is_owned) {
44500                 ret_ref |= 1;
44501         }
44502         return ret_ref;
44503 }
44504
44505 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
44506         LDKRouteHint ret_var = RouteHint_clone(arg);
44507 int64_t ret_ref = 0;
44508 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44509 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44510 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44511 ret_ref = (uintptr_t)ret_var.inner;
44512 if (ret_var.is_owned) {
44513         ret_ref |= 1;
44514 }
44515         return ret_ref;
44516 }
44517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44518         LDKRouteHint arg_conv;
44519         arg_conv.inner = (void*)(arg & (~1));
44520         arg_conv.is_owned = false;
44521         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44522         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
44523         return ret_conv;
44524 }
44525
44526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44527         LDKRouteHint orig_conv;
44528         orig_conv.inner = (void*)(orig & (~1));
44529         orig_conv.is_owned = false;
44530         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44531         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
44532         int64_t ret_ref = 0;
44533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44536         ret_ref = (uintptr_t)ret_var.inner;
44537         if (ret_var.is_owned) {
44538                 ret_ref |= 1;
44539         }
44540         return ret_ref;
44541 }
44542
44543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
44544         LDKRouteHint o_conv;
44545         o_conv.inner = (void*)(o & (~1));
44546         o_conv.is_owned = false;
44547         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44548         int64_t ret_conv = RouteHint_hash(&o_conv);
44549         return ret_conv;
44550 }
44551
44552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44553         LDKRouteHint a_conv;
44554         a_conv.inner = (void*)(a & (~1));
44555         a_conv.is_owned = false;
44556         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44557         LDKRouteHint b_conv;
44558         b_conv.inner = (void*)(b & (~1));
44559         b_conv.is_owned = false;
44560         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44561         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
44562         return ret_conv;
44563 }
44564
44565 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
44566         LDKRouteHint obj_conv;
44567         obj_conv.inner = (void*)(obj & (~1));
44568         obj_conv.is_owned = false;
44569         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44570         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
44571         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44572         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44573         CVec_u8Z_free(ret_var);
44574         return ret_arr;
44575 }
44576
44577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44578         LDKu8slice ser_ref;
44579         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44580         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44581         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
44582         *ret_conv = RouteHint_read(ser_ref);
44583         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44584         return (int64_t)ret_conv;
44585 }
44586
44587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44588         LDKRouteHintHop this_obj_conv;
44589         this_obj_conv.inner = (void*)(this_obj & (~1));
44590         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44592         RouteHintHop_free(this_obj_conv);
44593 }
44594
44595 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
44596         LDKRouteHintHop this_ptr_conv;
44597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44598         this_ptr_conv.is_owned = false;
44599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44600         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44601         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
44602         return ret_arr;
44603 }
44604
44605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44606         LDKRouteHintHop this_ptr_conv;
44607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44608         this_ptr_conv.is_owned = false;
44609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44610         LDKPublicKey val_ref;
44611         CHECK((*env)->GetArrayLength(env, val) == 33);
44612         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
44613         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
44614 }
44615
44616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
44617         LDKRouteHintHop this_ptr_conv;
44618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44619         this_ptr_conv.is_owned = false;
44620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44621         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
44622         return ret_conv;
44623 }
44624
44625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44626         LDKRouteHintHop this_ptr_conv;
44627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44628         this_ptr_conv.is_owned = false;
44629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44630         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
44631 }
44632
44633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
44634         LDKRouteHintHop this_ptr_conv;
44635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44636         this_ptr_conv.is_owned = false;
44637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44638         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
44639         int64_t ret_ref = 0;
44640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44643         ret_ref = (uintptr_t)ret_var.inner;
44644         if (ret_var.is_owned) {
44645                 ret_ref |= 1;
44646         }
44647         return ret_ref;
44648 }
44649
44650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44651         LDKRouteHintHop this_ptr_conv;
44652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44653         this_ptr_conv.is_owned = false;
44654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44655         LDKRoutingFees val_conv;
44656         val_conv.inner = (void*)(val & (~1));
44657         val_conv.is_owned = (val & 1) || (val == 0);
44658         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44659         val_conv = RoutingFees_clone(&val_conv);
44660         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
44661 }
44662
44663 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44664         LDKRouteHintHop this_ptr_conv;
44665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44666         this_ptr_conv.is_owned = false;
44667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44668         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
44669         return ret_conv;
44670 }
44671
44672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
44673         LDKRouteHintHop this_ptr_conv;
44674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44675         this_ptr_conv.is_owned = false;
44676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44677         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
44678 }
44679
44680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44681         LDKRouteHintHop this_ptr_conv;
44682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44683         this_ptr_conv.is_owned = false;
44684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44685         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44686         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
44687         int64_t ret_ref = (uintptr_t)ret_copy;
44688         return ret_ref;
44689 }
44690
44691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44692         LDKRouteHintHop this_ptr_conv;
44693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44694         this_ptr_conv.is_owned = false;
44695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44696         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
44697         CHECK_ACCESS(val_ptr);
44698         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
44699         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
44700         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
44701 }
44702
44703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44704         LDKRouteHintHop this_ptr_conv;
44705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44706         this_ptr_conv.is_owned = false;
44707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44708         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44709         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
44710         int64_t ret_ref = (uintptr_t)ret_copy;
44711         return ret_ref;
44712 }
44713
44714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44715         LDKRouteHintHop this_ptr_conv;
44716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44717         this_ptr_conv.is_owned = false;
44718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44719         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
44720         CHECK_ACCESS(val_ptr);
44721         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
44722         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
44723         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
44724 }
44725
44726 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) {
44727         LDKPublicKey src_node_id_arg_ref;
44728         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
44729         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
44730         LDKRoutingFees fees_arg_conv;
44731         fees_arg_conv.inner = (void*)(fees_arg & (~1));
44732         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
44733         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
44734         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
44735         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
44736         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
44737         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
44738         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
44739         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
44740         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
44741         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
44742         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
44743         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);
44744         int64_t ret_ref = 0;
44745         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44746         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44748         ret_ref = (uintptr_t)ret_var.inner;
44749         if (ret_var.is_owned) {
44750                 ret_ref |= 1;
44751         }
44752         return ret_ref;
44753 }
44754
44755 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
44756         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
44757 int64_t ret_ref = 0;
44758 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44759 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44760 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44761 ret_ref = (uintptr_t)ret_var.inner;
44762 if (ret_var.is_owned) {
44763         ret_ref |= 1;
44764 }
44765         return ret_ref;
44766 }
44767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44768         LDKRouteHintHop arg_conv;
44769         arg_conv.inner = (void*)(arg & (~1));
44770         arg_conv.is_owned = false;
44771         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44772         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
44773         return ret_conv;
44774 }
44775
44776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44777         LDKRouteHintHop orig_conv;
44778         orig_conv.inner = (void*)(orig & (~1));
44779         orig_conv.is_owned = false;
44780         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44781         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
44782         int64_t ret_ref = 0;
44783         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44784         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44786         ret_ref = (uintptr_t)ret_var.inner;
44787         if (ret_var.is_owned) {
44788                 ret_ref |= 1;
44789         }
44790         return ret_ref;
44791 }
44792
44793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
44794         LDKRouteHintHop o_conv;
44795         o_conv.inner = (void*)(o & (~1));
44796         o_conv.is_owned = false;
44797         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44798         int64_t ret_conv = RouteHintHop_hash(&o_conv);
44799         return ret_conv;
44800 }
44801
44802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44803         LDKRouteHintHop a_conv;
44804         a_conv.inner = (void*)(a & (~1));
44805         a_conv.is_owned = false;
44806         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44807         LDKRouteHintHop b_conv;
44808         b_conv.inner = (void*)(b & (~1));
44809         b_conv.is_owned = false;
44810         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44811         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
44812         return ret_conv;
44813 }
44814
44815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
44816         LDKRouteHintHop obj_conv;
44817         obj_conv.inner = (void*)(obj & (~1));
44818         obj_conv.is_owned = false;
44819         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44820         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
44821         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44822         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44823         CVec_u8Z_free(ret_var);
44824         return ret_arr;
44825 }
44826
44827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44828         LDKu8slice ser_ref;
44829         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44830         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44831         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
44832         *ret_conv = RouteHintHop_read(ser_ref);
44833         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44834         return (int64_t)ret_conv;
44835 }
44836
44837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t route_params, int64_t network_graph, int64_tArray first_hops, int64_t logger, int64_t scorer, int8_tArray random_seed_bytes) {
44838         LDKPublicKey our_node_pubkey_ref;
44839         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
44840         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
44841         LDKRouteParameters route_params_conv;
44842         route_params_conv.inner = (void*)(route_params & (~1));
44843         route_params_conv.is_owned = false;
44844         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
44845         LDKNetworkGraph network_graph_conv;
44846         network_graph_conv.inner = (void*)(network_graph & (~1));
44847         network_graph_conv.is_owned = false;
44848         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
44849         LDKCVec_ChannelDetailsZ first_hops_constr;
44850         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
44851         if (first_hops != NULL) {
44852                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
44853                 if (first_hops_constr.datalen > 0)
44854                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
44855                 else
44856                         first_hops_constr.data = NULL;
44857                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
44858                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
44859                         int64_t first_hops_conv_16 = first_hops_vals[q];
44860                         LDKChannelDetails first_hops_conv_16_conv;
44861                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
44862                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
44863                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
44864                         first_hops_constr.data[q] = first_hops_conv_16_conv;
44865                 }
44866                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
44867                 first_hops_ptr = &first_hops_constr;
44868         }
44869         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
44870         CHECK_ACCESS(logger_ptr);
44871         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44872         if (logger_conv.free == LDKLogger_JCalls_free) {
44873                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44874                 LDKLogger_JCalls_cloned(&logger_conv);
44875         }
44876         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
44877         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
44878         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
44879         unsigned char random_seed_bytes_arr[32];
44880         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
44881         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
44882         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
44883         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
44884         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_graph_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
44885         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
44886         return (int64_t)ret_conv;
44887 }
44888
44889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_build_1route_1from_1hops(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, jobjectArray hops, int64_t route_params, int64_t network_graph, int64_t logger, int8_tArray random_seed_bytes) {
44890         LDKPublicKey our_node_pubkey_ref;
44891         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
44892         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
44893         LDKCVec_PublicKeyZ hops_constr;
44894         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
44895         if (hops_constr.datalen > 0)
44896                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
44897         else
44898                 hops_constr.data = NULL;
44899         for (size_t i = 0; i < hops_constr.datalen; i++) {
44900                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
44901                 LDKPublicKey hops_conv_8_ref;
44902                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
44903                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
44904                 hops_constr.data[i] = hops_conv_8_ref;
44905         }
44906         LDKRouteParameters route_params_conv;
44907         route_params_conv.inner = (void*)(route_params & (~1));
44908         route_params_conv.is_owned = false;
44909         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
44910         LDKNetworkGraph network_graph_conv;
44911         network_graph_conv.inner = (void*)(network_graph & (~1));
44912         network_graph_conv.is_owned = false;
44913         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
44914         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
44915         CHECK_ACCESS(logger_ptr);
44916         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44917         if (logger_conv.free == LDKLogger_JCalls_free) {
44918                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44919                 LDKLogger_JCalls_cloned(&logger_conv);
44920         }
44921         unsigned char random_seed_bytes_arr[32];
44922         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
44923         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
44924         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
44925         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
44926         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
44927         return (int64_t)ret_conv;
44928 }
44929
44930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44931         if ((this_ptr & 1) != 0) return;
44932         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44933         CHECK_ACCESS(this_ptr_ptr);
44934         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
44935         FREE((void*)this_ptr);
44936         Score_free(this_ptr_conv);
44937 }
44938
44939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44940         if ((this_ptr & 1) != 0) return;
44941         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44942         CHECK_ACCESS(this_ptr_ptr);
44943         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
44944         FREE((void*)this_ptr);
44945         LockableScore_free(this_ptr_conv);
44946 }
44947
44948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44949         LDKMultiThreadedLockableScore this_obj_conv;
44950         this_obj_conv.inner = (void*)(this_obj & (~1));
44951         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44953         MultiThreadedLockableScore_free(this_obj_conv);
44954 }
44955
44956 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
44957         LDKMultiThreadedLockableScore obj_conv;
44958         obj_conv.inner = (void*)(obj & (~1));
44959         obj_conv.is_owned = false;
44960         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44961         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
44962         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44963         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44964         CVec_u8Z_free(ret_var);
44965         return ret_arr;
44966 }
44967
44968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
44969         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
44970         CHECK_ACCESS(score_ptr);
44971         LDKScore score_conv = *(LDKScore*)(score_ptr);
44972         if (score_conv.free == LDKScore_JCalls_free) {
44973                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44974                 LDKScore_JCalls_cloned(&score_conv);
44975         }
44976         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
44977         int64_t ret_ref = 0;
44978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44981         ret_ref = (uintptr_t)ret_var.inner;
44982         if (ret_var.is_owned) {
44983                 ret_ref |= 1;
44984         }
44985         return ret_ref;
44986 }
44987
44988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44989         LDKChannelUsage this_obj_conv;
44990         this_obj_conv.inner = (void*)(this_obj & (~1));
44991         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44993         ChannelUsage_free(this_obj_conv);
44994 }
44995
44996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44997         LDKChannelUsage this_ptr_conv;
44998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44999         this_ptr_conv.is_owned = false;
45000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45001         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
45002         return ret_conv;
45003 }
45004
45005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45006         LDKChannelUsage this_ptr_conv;
45007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45008         this_ptr_conv.is_owned = false;
45009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45010         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
45011 }
45012
45013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45014         LDKChannelUsage this_ptr_conv;
45015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45016         this_ptr_conv.is_owned = false;
45017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45018         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
45019         return ret_conv;
45020 }
45021
45022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45023         LDKChannelUsage this_ptr_conv;
45024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45025         this_ptr_conv.is_owned = false;
45026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45027         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
45028 }
45029
45030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
45031         LDKChannelUsage this_ptr_conv;
45032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45033         this_ptr_conv.is_owned = false;
45034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45035         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45036         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
45037         int64_t ret_ref = (uintptr_t)ret_copy;
45038         return ret_ref;
45039 }
45040
45041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45042         LDKChannelUsage this_ptr_conv;
45043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45044         this_ptr_conv.is_owned = false;
45045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45046         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
45047         CHECK_ACCESS(val_ptr);
45048         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
45049         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)val) & ~1));
45050         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
45051 }
45052
45053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1new(JNIEnv *env, jclass clz, int64_t amount_msat_arg, int64_t inflight_htlc_msat_arg, int64_t effective_capacity_arg) {
45054         void* effective_capacity_arg_ptr = (void*)(((uintptr_t)effective_capacity_arg) & ~1);
45055         CHECK_ACCESS(effective_capacity_arg_ptr);
45056         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
45057         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)effective_capacity_arg) & ~1));
45058         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
45059         int64_t ret_ref = 0;
45060         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45061         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45063         ret_ref = (uintptr_t)ret_var.inner;
45064         if (ret_var.is_owned) {
45065                 ret_ref |= 1;
45066         }
45067         return ret_ref;
45068 }
45069
45070 static inline uintptr_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
45071         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
45072 int64_t ret_ref = 0;
45073 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45074 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45075 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45076 ret_ref = (uintptr_t)ret_var.inner;
45077 if (ret_var.is_owned) {
45078         ret_ref |= 1;
45079 }
45080         return ret_ref;
45081 }
45082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45083         LDKChannelUsage arg_conv;
45084         arg_conv.inner = (void*)(arg & (~1));
45085         arg_conv.is_owned = false;
45086         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45087         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
45088         return ret_conv;
45089 }
45090
45091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45092         LDKChannelUsage orig_conv;
45093         orig_conv.inner = (void*)(orig & (~1));
45094         orig_conv.is_owned = false;
45095         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45096         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
45097         int64_t ret_ref = 0;
45098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45101         ret_ref = (uintptr_t)ret_var.inner;
45102         if (ret_var.is_owned) {
45103                 ret_ref |= 1;
45104         }
45105         return ret_ref;
45106 }
45107
45108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45109         LDKFixedPenaltyScorer this_obj_conv;
45110         this_obj_conv.inner = (void*)(this_obj & (~1));
45111         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45113         FixedPenaltyScorer_free(this_obj_conv);
45114 }
45115
45116 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
45117         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
45118 int64_t ret_ref = 0;
45119 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45120 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45121 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45122 ret_ref = (uintptr_t)ret_var.inner;
45123 if (ret_var.is_owned) {
45124         ret_ref |= 1;
45125 }
45126         return ret_ref;
45127 }
45128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45129         LDKFixedPenaltyScorer arg_conv;
45130         arg_conv.inner = (void*)(arg & (~1));
45131         arg_conv.is_owned = false;
45132         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45133         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
45134         return ret_conv;
45135 }
45136
45137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45138         LDKFixedPenaltyScorer orig_conv;
45139         orig_conv.inner = (void*)(orig & (~1));
45140         orig_conv.is_owned = false;
45141         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45142         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
45143         int64_t ret_ref = 0;
45144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45147         ret_ref = (uintptr_t)ret_var.inner;
45148         if (ret_var.is_owned) {
45149                 ret_ref |= 1;
45150         }
45151         return ret_ref;
45152 }
45153
45154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
45155         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
45156         int64_t ret_ref = 0;
45157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45160         ret_ref = (uintptr_t)ret_var.inner;
45161         if (ret_var.is_owned) {
45162                 ret_ref |= 1;
45163         }
45164         return ret_ref;
45165 }
45166
45167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
45168         LDKFixedPenaltyScorer this_arg_conv;
45169         this_arg_conv.inner = (void*)(this_arg & (~1));
45170         this_arg_conv.is_owned = false;
45171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45172         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
45173         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
45174         return (int64_t)ret_ret;
45175 }
45176
45177 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
45178         LDKFixedPenaltyScorer obj_conv;
45179         obj_conv.inner = (void*)(obj & (~1));
45180         obj_conv.is_owned = false;
45181         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45182         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
45183         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45184         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45185         CVec_u8Z_free(ret_var);
45186         return ret_arr;
45187 }
45188
45189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
45190         LDKu8slice ser_ref;
45191         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45192         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45193         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
45194         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
45195         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45196         return (int64_t)ret_conv;
45197 }
45198
45199 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45200         LDKProbabilisticScorer this_obj_conv;
45201         this_obj_conv.inner = (void*)(this_obj & (~1));
45202         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45204         ProbabilisticScorer_free(this_obj_conv);
45205 }
45206
45207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45208         LDKProbabilisticScoringParameters this_obj_conv;
45209         this_obj_conv.inner = (void*)(this_obj & (~1));
45210         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45212         ProbabilisticScoringParameters_free(this_obj_conv);
45213 }
45214
45215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45216         LDKProbabilisticScoringParameters this_ptr_conv;
45217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45218         this_ptr_conv.is_owned = false;
45219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45220         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
45221         return ret_conv;
45222 }
45223
45224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45225         LDKProbabilisticScoringParameters this_ptr_conv;
45226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45227         this_ptr_conv.is_owned = false;
45228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45229         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
45230 }
45231
45232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45233         LDKProbabilisticScoringParameters this_ptr_conv;
45234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45235         this_ptr_conv.is_owned = false;
45236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45237         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
45238         return ret_conv;
45239 }
45240
45241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45242         LDKProbabilisticScoringParameters this_ptr_conv;
45243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45244         this_ptr_conv.is_owned = false;
45245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45246         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
45247 }
45248
45249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
45250         LDKProbabilisticScoringParameters this_ptr_conv;
45251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45252         this_ptr_conv.is_owned = false;
45253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45254         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
45255         return ret_conv;
45256 }
45257
45258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45259         LDKProbabilisticScoringParameters this_ptr_conv;
45260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45261         this_ptr_conv.is_owned = false;
45262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45263         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
45264 }
45265
45266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1amount_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45267         LDKProbabilisticScoringParameters this_ptr_conv;
45268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45269         this_ptr_conv.is_owned = false;
45270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45271         int64_t ret_conv = ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(&this_ptr_conv);
45272         return ret_conv;
45273 }
45274
45275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1amount_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45276         LDKProbabilisticScoringParameters this_ptr_conv;
45277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45278         this_ptr_conv.is_owned = false;
45279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45280         ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(&this_ptr_conv, val);
45281 }
45282
45283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat_arg, int64_t liquidity_penalty_multiplier_msat_arg, int64_t liquidity_offset_half_life_arg, int64_t amount_penalty_multiplier_msat_arg) {
45284         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(base_penalty_msat_arg, liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg, amount_penalty_multiplier_msat_arg);
45285         int64_t ret_ref = 0;
45286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45289         ret_ref = (uintptr_t)ret_var.inner;
45290         if (ret_var.is_owned) {
45291                 ret_ref |= 1;
45292         }
45293         return ret_ref;
45294 }
45295
45296 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
45297         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
45298 int64_t ret_ref = 0;
45299 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45300 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45301 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45302 ret_ref = (uintptr_t)ret_var.inner;
45303 if (ret_var.is_owned) {
45304         ret_ref |= 1;
45305 }
45306         return ret_ref;
45307 }
45308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45309         LDKProbabilisticScoringParameters arg_conv;
45310         arg_conv.inner = (void*)(arg & (~1));
45311         arg_conv.is_owned = false;
45312         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45313         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
45314         return ret_conv;
45315 }
45316
45317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45318         LDKProbabilisticScoringParameters orig_conv;
45319         orig_conv.inner = (void*)(orig & (~1));
45320         orig_conv.is_owned = false;
45321         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45322         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
45323         int64_t ret_ref = 0;
45324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45327         ret_ref = (uintptr_t)ret_var.inner;
45328         if (ret_var.is_owned) {
45329                 ret_ref |= 1;
45330         }
45331         return ret_ref;
45332 }
45333
45334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1new(JNIEnv *env, jclass clz, int64_t params, int64_t network_graph, int64_t logger) {
45335         LDKProbabilisticScoringParameters params_conv;
45336         params_conv.inner = (void*)(params & (~1));
45337         params_conv.is_owned = (params & 1) || (params == 0);
45338         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
45339         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
45340         LDKNetworkGraph network_graph_conv;
45341         network_graph_conv.inner = (void*)(network_graph & (~1));
45342         network_graph_conv.is_owned = false;
45343         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45344         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45345         CHECK_ACCESS(logger_ptr);
45346         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45347         if (logger_conv.free == LDKLogger_JCalls_free) {
45348                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45349                 LDKLogger_JCalls_cloned(&logger_conv);
45350         }
45351         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
45352         int64_t ret_ref = 0;
45353         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45354         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45356         ret_ref = (uintptr_t)ret_var.inner;
45357         if (ret_var.is_owned) {
45358                 ret_ref |= 1;
45359         }
45360         return ret_ref;
45361 }
45362
45363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
45364         LDKProbabilisticScorer this_arg_conv;
45365         this_arg_conv.inner = (void*)(this_arg & (~1));
45366         this_arg_conv.is_owned = false;
45367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45368         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
45369 }
45370
45371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
45372         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
45373         int64_t ret_ref = 0;
45374         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45375         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45377         ret_ref = (uintptr_t)ret_var.inner;
45378         if (ret_var.is_owned) {
45379                 ret_ref |= 1;
45380         }
45381         return ret_ref;
45382 }
45383
45384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
45385         LDKProbabilisticScorer this_arg_conv;
45386         this_arg_conv.inner = (void*)(this_arg & (~1));
45387         this_arg_conv.is_owned = false;
45388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45389         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
45390         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
45391         return (int64_t)ret_ret;
45392 }
45393
45394 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
45395         LDKProbabilisticScorer obj_conv;
45396         obj_conv.inner = (void*)(obj & (~1));
45397         obj_conv.is_owned = false;
45398         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45399         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
45400         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45401         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45402         CVec_u8Z_free(ret_var);
45403         return ret_arr;
45404 }
45405
45406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg_a, int64_t arg_b, int64_t arg_c) {
45407         LDKu8slice ser_ref;
45408         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45409         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45410         LDKProbabilisticScoringParameters arg_a_conv;
45411         arg_a_conv.inner = (void*)(arg_a & (~1));
45412         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
45413         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
45414         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
45415         LDKNetworkGraph arg_b_conv;
45416         arg_b_conv.inner = (void*)(arg_b & (~1));
45417         arg_b_conv.is_owned = false;
45418         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
45419         void* arg_c_ptr = (void*)(((uintptr_t)arg_c) & ~1);
45420         CHECK_ACCESS(arg_c_ptr);
45421         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
45422         if (arg_c_conv.free == LDKLogger_JCalls_free) {
45423                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45424                 LDKLogger_JCalls_cloned(&arg_c_conv);
45425         }
45426         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
45427         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
45428         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45429         return (int64_t)ret_conv;
45430 }
45431
45432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45433         LDKFilesystemPersister this_obj_conv;
45434         this_obj_conv.inner = (void*)(this_obj & (~1));
45435         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45437         FilesystemPersister_free(this_obj_conv);
45438 }
45439
45440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
45441         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
45442         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
45443         int64_t ret_ref = 0;
45444         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45445         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45447         ret_ref = (uintptr_t)ret_var.inner;
45448         if (ret_var.is_owned) {
45449                 ret_ref |= 1;
45450         }
45451         return ret_ref;
45452 }
45453
45454 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
45455         LDKFilesystemPersister this_arg_conv;
45456         this_arg_conv.inner = (void*)(this_arg & (~1));
45457         this_arg_conv.is_owned = false;
45458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45459         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
45460         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45461         Str_free(ret_str);
45462         return ret_conv;
45463 }
45464
45465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
45466         LDKFilesystemPersister this_arg_conv;
45467         this_arg_conv.inner = (void*)(this_arg & (~1));
45468         this_arg_conv.is_owned = false;
45469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45470         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
45471         CHECK_ACCESS(keys_manager_ptr);
45472         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45473         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45474                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45475                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45476         }
45477         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
45478         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
45479         return (int64_t)ret_conv;
45480 }
45481
45482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45483         LDKBackgroundProcessor this_obj_conv;
45484         this_obj_conv.inner = (void*)(this_obj & (~1));
45485         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45487         BackgroundProcessor_free(this_obj_conv);
45488 }
45489
45490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45491         if ((this_ptr & 1) != 0) return;
45492         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45493         CHECK_ACCESS(this_ptr_ptr);
45494         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
45495         FREE((void*)this_ptr);
45496         GossipSync_free(this_ptr_conv);
45497 }
45498
45499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
45500         LDKP2PGossipSync a_conv;
45501         a_conv.inner = (void*)(a & (~1));
45502         a_conv.is_owned = false;
45503         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45504         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
45505         *ret_copy = GossipSync_p2_p(&a_conv);
45506         int64_t ret_ref = (uintptr_t)ret_copy;
45507         return ret_ref;
45508 }
45509
45510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
45511         LDKRapidGossipSync a_conv;
45512         a_conv.inner = (void*)(a & (~1));
45513         a_conv.is_owned = false;
45514         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45515         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
45516         *ret_copy = GossipSync_rapid(&a_conv);
45517         int64_t ret_ref = (uintptr_t)ret_copy;
45518         return ret_ref;
45519 }
45520
45521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
45522         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
45523         *ret_copy = GossipSync_none();
45524         int64_t ret_ref = (uintptr_t)ret_copy;
45525         return ret_ref;
45526 }
45527
45528 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 gossip_sync, int64_t peer_manager, int64_t logger, int64_t scorer) {
45529         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
45530         CHECK_ACCESS(persister_ptr);
45531         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
45532         if (persister_conv.free == LDKPersister_JCalls_free) {
45533                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45534                 LDKPersister_JCalls_cloned(&persister_conv);
45535         }
45536         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
45537         CHECK_ACCESS(event_handler_ptr);
45538         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
45539         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
45540                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45541                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
45542         }
45543         LDKChainMonitor chain_monitor_conv;
45544         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
45545         chain_monitor_conv.is_owned = false;
45546         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
45547         LDKChannelManager channel_manager_conv;
45548         channel_manager_conv.inner = (void*)(channel_manager & (~1));
45549         channel_manager_conv.is_owned = false;
45550         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
45551         void* gossip_sync_ptr = (void*)(((uintptr_t)gossip_sync) & ~1);
45552         CHECK_ACCESS(gossip_sync_ptr);
45553         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
45554         // WARNING: we may need a move here but no clone is available for LDKGossipSync
45555         LDKPeerManager peer_manager_conv;
45556         peer_manager_conv.inner = (void*)(peer_manager & (~1));
45557         peer_manager_conv.is_owned = false;
45558         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
45559         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45560         CHECK_ACCESS(logger_ptr);
45561         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45562         if (logger_conv.free == LDKLogger_JCalls_free) {
45563                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45564                 LDKLogger_JCalls_cloned(&logger_conv);
45565         }
45566         LDKMultiThreadedLockableScore scorer_conv;
45567         scorer_conv.inner = (void*)(scorer & (~1));
45568         scorer_conv.is_owned = (scorer & 1) || (scorer == 0);
45569         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
45570         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, gossip_sync_conv, &peer_manager_conv, logger_conv, scorer_conv);
45571         int64_t ret_ref = 0;
45572         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45573         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45575         ret_ref = (uintptr_t)ret_var.inner;
45576         if (ret_var.is_owned) {
45577                 ret_ref |= 1;
45578         }
45579         return ret_ref;
45580 }
45581
45582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
45583         LDKBackgroundProcessor this_arg_conv;
45584         this_arg_conv.inner = (void*)(this_arg & (~1));
45585         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45587         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
45588         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
45589         *ret_conv = BackgroundProcessor_join(this_arg_conv);
45590         return (int64_t)ret_conv;
45591 }
45592
45593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
45594         LDKBackgroundProcessor this_arg_conv;
45595         this_arg_conv.inner = (void*)(this_arg & (~1));
45596         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45598         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
45599         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
45600         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
45601         return (int64_t)ret_conv;
45602 }
45603
45604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45605         if ((this_ptr & 1) != 0) return;
45606         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45607         CHECK_ACCESS(this_ptr_ptr);
45608         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
45609         FREE((void*)this_ptr);
45610         ParseError_free(this_ptr_conv);
45611 }
45612
45613 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
45614         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45615         *ret_copy = ParseError_clone(arg);
45616 int64_t ret_ref = (uintptr_t)ret_copy;
45617         return ret_ref;
45618 }
45619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45620         LDKParseError* arg_conv = (LDKParseError*)arg;
45621         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
45622         return ret_conv;
45623 }
45624
45625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45626         LDKParseError* orig_conv = (LDKParseError*)orig;
45627         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45628         *ret_copy = ParseError_clone(orig_conv);
45629         int64_t ret_ref = (uintptr_t)ret_copy;
45630         return ret_ref;
45631 }
45632
45633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
45634         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
45635         CHECK_ACCESS(a_ptr);
45636         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
45637         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
45638         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45639         *ret_copy = ParseError_bech32_error(a_conv);
45640         int64_t ret_ref = (uintptr_t)ret_copy;
45641         return ret_ref;
45642 }
45643
45644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
45645         
45646         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45647         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
45648         int64_t ret_ref = (uintptr_t)ret_copy;
45649         return ret_ref;
45650 }
45651
45652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
45653         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
45654         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45655         *ret_copy = ParseError_malformed_signature(a_conv);
45656         int64_t ret_ref = (uintptr_t)ret_copy;
45657         return ret_ref;
45658 }
45659
45660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
45661         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45662         *ret_copy = ParseError_bad_prefix();
45663         int64_t ret_ref = (uintptr_t)ret_copy;
45664         return ret_ref;
45665 }
45666
45667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
45668         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45669         *ret_copy = ParseError_unknown_currency();
45670         int64_t ret_ref = (uintptr_t)ret_copy;
45671         return ret_ref;
45672 }
45673
45674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
45675         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45676         *ret_copy = ParseError_unknown_si_prefix();
45677         int64_t ret_ref = (uintptr_t)ret_copy;
45678         return ret_ref;
45679 }
45680
45681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
45682         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45683         *ret_copy = ParseError_malformed_hrp();
45684         int64_t ret_ref = (uintptr_t)ret_copy;
45685         return ret_ref;
45686 }
45687
45688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
45689         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45690         *ret_copy = ParseError_too_short_data_part();
45691         int64_t ret_ref = (uintptr_t)ret_copy;
45692         return ret_ref;
45693 }
45694
45695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
45696         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45697         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
45698         int64_t ret_ref = (uintptr_t)ret_copy;
45699         return ret_ref;
45700 }
45701
45702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
45703         
45704         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45705         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
45706         int64_t ret_ref = (uintptr_t)ret_copy;
45707         return ret_ref;
45708 }
45709
45710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
45711         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45712         *ret_copy = ParseError_padding_error();
45713         int64_t ret_ref = (uintptr_t)ret_copy;
45714         return ret_ref;
45715 }
45716
45717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
45718         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45719         *ret_copy = ParseError_integer_overflow_error();
45720         int64_t ret_ref = (uintptr_t)ret_copy;
45721         return ret_ref;
45722 }
45723
45724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
45725         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45726         *ret_copy = ParseError_invalid_seg_wit_program_length();
45727         int64_t ret_ref = (uintptr_t)ret_copy;
45728         return ret_ref;
45729 }
45730
45731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
45732         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45733         *ret_copy = ParseError_invalid_pub_key_hash_length();
45734         int64_t ret_ref = (uintptr_t)ret_copy;
45735         return ret_ref;
45736 }
45737
45738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
45739         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45740         *ret_copy = ParseError_invalid_script_hash_length();
45741         int64_t ret_ref = (uintptr_t)ret_copy;
45742         return ret_ref;
45743 }
45744
45745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
45746         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45747         *ret_copy = ParseError_invalid_recovery_id();
45748         int64_t ret_ref = (uintptr_t)ret_copy;
45749         return ret_ref;
45750 }
45751
45752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
45753         LDKStr a_conv = java_to_owned_str(env, a);
45754         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45755         *ret_copy = ParseError_invalid_slice_length(a_conv);
45756         int64_t ret_ref = (uintptr_t)ret_copy;
45757         return ret_ref;
45758 }
45759
45760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
45761         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
45762         *ret_copy = ParseError_skip();
45763         int64_t ret_ref = (uintptr_t)ret_copy;
45764         return ret_ref;
45765 }
45766
45767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45768         if ((this_ptr & 1) != 0) return;
45769         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45770         CHECK_ACCESS(this_ptr_ptr);
45771         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
45772         FREE((void*)this_ptr);
45773         ParseOrSemanticError_free(this_ptr_conv);
45774 }
45775
45776 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
45777         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
45778         *ret_copy = ParseOrSemanticError_clone(arg);
45779 int64_t ret_ref = (uintptr_t)ret_copy;
45780         return ret_ref;
45781 }
45782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45783         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
45784         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
45785         return ret_conv;
45786 }
45787
45788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45789         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
45790         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
45791         *ret_copy = ParseOrSemanticError_clone(orig_conv);
45792         int64_t ret_ref = (uintptr_t)ret_copy;
45793         return ret_ref;
45794 }
45795
45796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
45797         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
45798         CHECK_ACCESS(a_ptr);
45799         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
45800         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
45801         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
45802         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
45803         int64_t ret_ref = (uintptr_t)ret_copy;
45804         return ret_ref;
45805 }
45806
45807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
45808         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
45809         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
45810         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
45811         int64_t ret_ref = (uintptr_t)ret_copy;
45812         return ret_ref;
45813 }
45814
45815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45816         LDKInvoice this_obj_conv;
45817         this_obj_conv.inner = (void*)(this_obj & (~1));
45818         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45820         Invoice_free(this_obj_conv);
45821 }
45822
45823 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45824         LDKInvoice a_conv;
45825         a_conv.inner = (void*)(a & (~1));
45826         a_conv.is_owned = false;
45827         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45828         LDKInvoice b_conv;
45829         b_conv.inner = (void*)(b & (~1));
45830         b_conv.is_owned = false;
45831         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45832         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
45833         return ret_conv;
45834 }
45835
45836 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
45837         LDKInvoice ret_var = Invoice_clone(arg);
45838 int64_t ret_ref = 0;
45839 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45840 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45841 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45842 ret_ref = (uintptr_t)ret_var.inner;
45843 if (ret_var.is_owned) {
45844         ret_ref |= 1;
45845 }
45846         return ret_ref;
45847 }
45848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45849         LDKInvoice arg_conv;
45850         arg_conv.inner = (void*)(arg & (~1));
45851         arg_conv.is_owned = false;
45852         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45853         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
45854         return ret_conv;
45855 }
45856
45857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45858         LDKInvoice orig_conv;
45859         orig_conv.inner = (void*)(orig & (~1));
45860         orig_conv.is_owned = false;
45861         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45862         LDKInvoice ret_var = Invoice_clone(&orig_conv);
45863         int64_t ret_ref = 0;
45864         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45865         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45867         ret_ref = (uintptr_t)ret_var.inner;
45868         if (ret_var.is_owned) {
45869                 ret_ref |= 1;
45870         }
45871         return ret_ref;
45872 }
45873
45874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45875         LDKSignedRawInvoice this_obj_conv;
45876         this_obj_conv.inner = (void*)(this_obj & (~1));
45877         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45879         SignedRawInvoice_free(this_obj_conv);
45880 }
45881
45882 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45883         LDKSignedRawInvoice a_conv;
45884         a_conv.inner = (void*)(a & (~1));
45885         a_conv.is_owned = false;
45886         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45887         LDKSignedRawInvoice b_conv;
45888         b_conv.inner = (void*)(b & (~1));
45889         b_conv.is_owned = false;
45890         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45891         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
45892         return ret_conv;
45893 }
45894
45895 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
45896         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
45897 int64_t ret_ref = 0;
45898 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45899 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45900 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45901 ret_ref = (uintptr_t)ret_var.inner;
45902 if (ret_var.is_owned) {
45903         ret_ref |= 1;
45904 }
45905         return ret_ref;
45906 }
45907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45908         LDKSignedRawInvoice arg_conv;
45909         arg_conv.inner = (void*)(arg & (~1));
45910         arg_conv.is_owned = false;
45911         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45912         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
45913         return ret_conv;
45914 }
45915
45916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45917         LDKSignedRawInvoice orig_conv;
45918         orig_conv.inner = (void*)(orig & (~1));
45919         orig_conv.is_owned = false;
45920         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45921         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
45922         int64_t ret_ref = 0;
45923         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45924         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45926         ret_ref = (uintptr_t)ret_var.inner;
45927         if (ret_var.is_owned) {
45928                 ret_ref |= 1;
45929         }
45930         return ret_ref;
45931 }
45932
45933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45934         LDKRawInvoice this_obj_conv;
45935         this_obj_conv.inner = (void*)(this_obj & (~1));
45936         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45938         RawInvoice_free(this_obj_conv);
45939 }
45940
45941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
45942         LDKRawInvoice this_ptr_conv;
45943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45944         this_ptr_conv.is_owned = false;
45945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45946         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
45947         int64_t ret_ref = 0;
45948         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45949         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45951         ret_ref = (uintptr_t)ret_var.inner;
45952         if (ret_var.is_owned) {
45953                 ret_ref |= 1;
45954         }
45955         return ret_ref;
45956 }
45957
45958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45959         LDKRawInvoice this_ptr_conv;
45960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45961         this_ptr_conv.is_owned = false;
45962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45963         LDKRawDataPart val_conv;
45964         val_conv.inner = (void*)(val & (~1));
45965         val_conv.is_owned = (val & 1) || (val == 0);
45966         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45967         val_conv = RawDataPart_clone(&val_conv);
45968         RawInvoice_set_data(&this_ptr_conv, val_conv);
45969 }
45970
45971 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45972         LDKRawInvoice a_conv;
45973         a_conv.inner = (void*)(a & (~1));
45974         a_conv.is_owned = false;
45975         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45976         LDKRawInvoice b_conv;
45977         b_conv.inner = (void*)(b & (~1));
45978         b_conv.is_owned = false;
45979         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45980         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
45981         return ret_conv;
45982 }
45983
45984 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
45985         LDKRawInvoice ret_var = RawInvoice_clone(arg);
45986 int64_t ret_ref = 0;
45987 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45988 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45989 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45990 ret_ref = (uintptr_t)ret_var.inner;
45991 if (ret_var.is_owned) {
45992         ret_ref |= 1;
45993 }
45994         return ret_ref;
45995 }
45996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45997         LDKRawInvoice arg_conv;
45998         arg_conv.inner = (void*)(arg & (~1));
45999         arg_conv.is_owned = false;
46000         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46001         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
46002         return ret_conv;
46003 }
46004
46005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46006         LDKRawInvoice orig_conv;
46007         orig_conv.inner = (void*)(orig & (~1));
46008         orig_conv.is_owned = false;
46009         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46010         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
46011         int64_t ret_ref = 0;
46012         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46013         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46015         ret_ref = (uintptr_t)ret_var.inner;
46016         if (ret_var.is_owned) {
46017                 ret_ref |= 1;
46018         }
46019         return ret_ref;
46020 }
46021
46022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46023         LDKRawDataPart this_obj_conv;
46024         this_obj_conv.inner = (void*)(this_obj & (~1));
46025         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46027         RawDataPart_free(this_obj_conv);
46028 }
46029
46030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
46031         LDKRawDataPart this_ptr_conv;
46032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46033         this_ptr_conv.is_owned = false;
46034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46035         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
46036         int64_t ret_ref = 0;
46037         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46038         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46040         ret_ref = (uintptr_t)ret_var.inner;
46041         if (ret_var.is_owned) {
46042                 ret_ref |= 1;
46043         }
46044         return ret_ref;
46045 }
46046
46047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46048         LDKRawDataPart this_ptr_conv;
46049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46050         this_ptr_conv.is_owned = false;
46051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46052         LDKPositiveTimestamp val_conv;
46053         val_conv.inner = (void*)(val & (~1));
46054         val_conv.is_owned = (val & 1) || (val == 0);
46055         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46056         val_conv = PositiveTimestamp_clone(&val_conv);
46057         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
46058 }
46059
46060 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46061         LDKRawDataPart a_conv;
46062         a_conv.inner = (void*)(a & (~1));
46063         a_conv.is_owned = false;
46064         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46065         LDKRawDataPart b_conv;
46066         b_conv.inner = (void*)(b & (~1));
46067         b_conv.is_owned = false;
46068         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46069         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
46070         return ret_conv;
46071 }
46072
46073 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
46074         LDKRawDataPart ret_var = RawDataPart_clone(arg);
46075 int64_t ret_ref = 0;
46076 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46077 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46078 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46079 ret_ref = (uintptr_t)ret_var.inner;
46080 if (ret_var.is_owned) {
46081         ret_ref |= 1;
46082 }
46083         return ret_ref;
46084 }
46085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46086         LDKRawDataPart arg_conv;
46087         arg_conv.inner = (void*)(arg & (~1));
46088         arg_conv.is_owned = false;
46089         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46090         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
46091         return ret_conv;
46092 }
46093
46094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46095         LDKRawDataPart orig_conv;
46096         orig_conv.inner = (void*)(orig & (~1));
46097         orig_conv.is_owned = false;
46098         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46099         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
46100         int64_t ret_ref = 0;
46101         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46102         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46104         ret_ref = (uintptr_t)ret_var.inner;
46105         if (ret_var.is_owned) {
46106                 ret_ref |= 1;
46107         }
46108         return ret_ref;
46109 }
46110
46111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46112         LDKPositiveTimestamp this_obj_conv;
46113         this_obj_conv.inner = (void*)(this_obj & (~1));
46114         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46116         PositiveTimestamp_free(this_obj_conv);
46117 }
46118
46119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46120         LDKPositiveTimestamp a_conv;
46121         a_conv.inner = (void*)(a & (~1));
46122         a_conv.is_owned = false;
46123         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46124         LDKPositiveTimestamp b_conv;
46125         b_conv.inner = (void*)(b & (~1));
46126         b_conv.is_owned = false;
46127         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46128         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
46129         return ret_conv;
46130 }
46131
46132 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
46133         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
46134 int64_t ret_ref = 0;
46135 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46136 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46137 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46138 ret_ref = (uintptr_t)ret_var.inner;
46139 if (ret_var.is_owned) {
46140         ret_ref |= 1;
46141 }
46142         return ret_ref;
46143 }
46144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46145         LDKPositiveTimestamp arg_conv;
46146         arg_conv.inner = (void*)(arg & (~1));
46147         arg_conv.is_owned = false;
46148         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46149         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
46150         return ret_conv;
46151 }
46152
46153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46154         LDKPositiveTimestamp orig_conv;
46155         orig_conv.inner = (void*)(orig & (~1));
46156         orig_conv.is_owned = false;
46157         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46158         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
46159         int64_t ret_ref = 0;
46160         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46161         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46163         ret_ref = (uintptr_t)ret_var.inner;
46164         if (ret_var.is_owned) {
46165                 ret_ref |= 1;
46166         }
46167         return ret_ref;
46168 }
46169
46170 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46171         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
46172         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
46173         return ret_conv;
46174 }
46175
46176 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
46177         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
46178         return ret_conv;
46179 }
46180
46181 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
46182         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
46183         return ret_conv;
46184 }
46185
46186 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
46187         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
46188         return ret_conv;
46189 }
46190
46191 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
46192         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
46193         return ret_conv;
46194 }
46195
46196 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46197         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
46198         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
46199         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
46200         return ret_conv;
46201 }
46202
46203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
46204         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
46205         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
46206         return ret_conv;
46207 }
46208
46209 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46210         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
46211         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
46212         return ret_conv;
46213 }
46214
46215 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
46216         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
46217         return ret_conv;
46218 }
46219
46220 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
46221         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
46222         return ret_conv;
46223 }
46224
46225 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
46226         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
46227         return ret_conv;
46228 }
46229
46230 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
46231         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
46232         return ret_conv;
46233 }
46234
46235 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
46236         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
46237         return ret_conv;
46238 }
46239
46240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
46241         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
46242         int64_t ret_conv = Currency_hash(o_conv);
46243         return ret_conv;
46244 }
46245
46246 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46247         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
46248         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
46249         jboolean ret_conv = Currency_eq(a_conv, b_conv);
46250         return ret_conv;
46251 }
46252
46253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46254         LDKSha256 this_obj_conv;
46255         this_obj_conv.inner = (void*)(this_obj & (~1));
46256         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46258         Sha256_free(this_obj_conv);
46259 }
46260
46261 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
46262         LDKSha256 ret_var = Sha256_clone(arg);
46263 int64_t ret_ref = 0;
46264 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46265 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46266 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46267 ret_ref = (uintptr_t)ret_var.inner;
46268 if (ret_var.is_owned) {
46269         ret_ref |= 1;
46270 }
46271         return ret_ref;
46272 }
46273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46274         LDKSha256 arg_conv;
46275         arg_conv.inner = (void*)(arg & (~1));
46276         arg_conv.is_owned = false;
46277         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46278         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
46279         return ret_conv;
46280 }
46281
46282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46283         LDKSha256 orig_conv;
46284         orig_conv.inner = (void*)(orig & (~1));
46285         orig_conv.is_owned = false;
46286         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46287         LDKSha256 ret_var = Sha256_clone(&orig_conv);
46288         int64_t ret_ref = 0;
46289         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46290         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46292         ret_ref = (uintptr_t)ret_var.inner;
46293         if (ret_var.is_owned) {
46294                 ret_ref |= 1;
46295         }
46296         return ret_ref;
46297 }
46298
46299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
46300         LDKSha256 o_conv;
46301         o_conv.inner = (void*)(o & (~1));
46302         o_conv.is_owned = false;
46303         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46304         int64_t ret_conv = Sha256_hash(&o_conv);
46305         return ret_conv;
46306 }
46307
46308 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46309         LDKSha256 a_conv;
46310         a_conv.inner = (void*)(a & (~1));
46311         a_conv.is_owned = false;
46312         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46313         LDKSha256 b_conv;
46314         b_conv.inner = (void*)(b & (~1));
46315         b_conv.is_owned = false;
46316         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46317         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
46318         return ret_conv;
46319 }
46320
46321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46322         LDKDescription this_obj_conv;
46323         this_obj_conv.inner = (void*)(this_obj & (~1));
46324         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46326         Description_free(this_obj_conv);
46327 }
46328
46329 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
46330         LDKDescription ret_var = Description_clone(arg);
46331 int64_t ret_ref = 0;
46332 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46333 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46334 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46335 ret_ref = (uintptr_t)ret_var.inner;
46336 if (ret_var.is_owned) {
46337         ret_ref |= 1;
46338 }
46339         return ret_ref;
46340 }
46341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46342         LDKDescription arg_conv;
46343         arg_conv.inner = (void*)(arg & (~1));
46344         arg_conv.is_owned = false;
46345         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46346         int64_t ret_conv = Description_clone_ptr(&arg_conv);
46347         return ret_conv;
46348 }
46349
46350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46351         LDKDescription orig_conv;
46352         orig_conv.inner = (void*)(orig & (~1));
46353         orig_conv.is_owned = false;
46354         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46355         LDKDescription ret_var = Description_clone(&orig_conv);
46356         int64_t ret_ref = 0;
46357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46360         ret_ref = (uintptr_t)ret_var.inner;
46361         if (ret_var.is_owned) {
46362                 ret_ref |= 1;
46363         }
46364         return ret_ref;
46365 }
46366
46367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
46368         LDKDescription o_conv;
46369         o_conv.inner = (void*)(o & (~1));
46370         o_conv.is_owned = false;
46371         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46372         int64_t ret_conv = Description_hash(&o_conv);
46373         return ret_conv;
46374 }
46375
46376 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46377         LDKDescription a_conv;
46378         a_conv.inner = (void*)(a & (~1));
46379         a_conv.is_owned = false;
46380         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46381         LDKDescription b_conv;
46382         b_conv.inner = (void*)(b & (~1));
46383         b_conv.is_owned = false;
46384         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46385         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
46386         return ret_conv;
46387 }
46388
46389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46390         LDKPayeePubKey this_obj_conv;
46391         this_obj_conv.inner = (void*)(this_obj & (~1));
46392         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46394         PayeePubKey_free(this_obj_conv);
46395 }
46396
46397 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
46398         LDKPayeePubKey this_ptr_conv;
46399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46400         this_ptr_conv.is_owned = false;
46401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46402         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46403         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
46404         return ret_arr;
46405 }
46406
46407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46408         LDKPayeePubKey this_ptr_conv;
46409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46410         this_ptr_conv.is_owned = false;
46411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46412         LDKPublicKey val_ref;
46413         CHECK((*env)->GetArrayLength(env, val) == 33);
46414         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
46415         PayeePubKey_set_a(&this_ptr_conv, val_ref);
46416 }
46417
46418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
46419         LDKPublicKey a_arg_ref;
46420         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
46421         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
46422         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
46423         int64_t ret_ref = 0;
46424         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46425         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46427         ret_ref = (uintptr_t)ret_var.inner;
46428         if (ret_var.is_owned) {
46429                 ret_ref |= 1;
46430         }
46431         return ret_ref;
46432 }
46433
46434 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
46435         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
46436 int64_t ret_ref = 0;
46437 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46438 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46439 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46440 ret_ref = (uintptr_t)ret_var.inner;
46441 if (ret_var.is_owned) {
46442         ret_ref |= 1;
46443 }
46444         return ret_ref;
46445 }
46446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46447         LDKPayeePubKey arg_conv;
46448         arg_conv.inner = (void*)(arg & (~1));
46449         arg_conv.is_owned = false;
46450         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46451         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
46452         return ret_conv;
46453 }
46454
46455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46456         LDKPayeePubKey orig_conv;
46457         orig_conv.inner = (void*)(orig & (~1));
46458         orig_conv.is_owned = false;
46459         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46460         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
46461         int64_t ret_ref = 0;
46462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46465         ret_ref = (uintptr_t)ret_var.inner;
46466         if (ret_var.is_owned) {
46467                 ret_ref |= 1;
46468         }
46469         return ret_ref;
46470 }
46471
46472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
46473         LDKPayeePubKey o_conv;
46474         o_conv.inner = (void*)(o & (~1));
46475         o_conv.is_owned = false;
46476         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46477         int64_t ret_conv = PayeePubKey_hash(&o_conv);
46478         return ret_conv;
46479 }
46480
46481 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46482         LDKPayeePubKey a_conv;
46483         a_conv.inner = (void*)(a & (~1));
46484         a_conv.is_owned = false;
46485         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46486         LDKPayeePubKey b_conv;
46487         b_conv.inner = (void*)(b & (~1));
46488         b_conv.is_owned = false;
46489         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46490         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
46491         return ret_conv;
46492 }
46493
46494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46495         LDKExpiryTime this_obj_conv;
46496         this_obj_conv.inner = (void*)(this_obj & (~1));
46497         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46499         ExpiryTime_free(this_obj_conv);
46500 }
46501
46502 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
46503         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
46504 int64_t ret_ref = 0;
46505 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46506 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46507 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46508 ret_ref = (uintptr_t)ret_var.inner;
46509 if (ret_var.is_owned) {
46510         ret_ref |= 1;
46511 }
46512         return ret_ref;
46513 }
46514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46515         LDKExpiryTime arg_conv;
46516         arg_conv.inner = (void*)(arg & (~1));
46517         arg_conv.is_owned = false;
46518         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46519         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
46520         return ret_conv;
46521 }
46522
46523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46524         LDKExpiryTime orig_conv;
46525         orig_conv.inner = (void*)(orig & (~1));
46526         orig_conv.is_owned = false;
46527         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46528         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
46529         int64_t ret_ref = 0;
46530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46533         ret_ref = (uintptr_t)ret_var.inner;
46534         if (ret_var.is_owned) {
46535                 ret_ref |= 1;
46536         }
46537         return ret_ref;
46538 }
46539
46540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
46541         LDKExpiryTime o_conv;
46542         o_conv.inner = (void*)(o & (~1));
46543         o_conv.is_owned = false;
46544         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46545         int64_t ret_conv = ExpiryTime_hash(&o_conv);
46546         return ret_conv;
46547 }
46548
46549 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46550         LDKExpiryTime a_conv;
46551         a_conv.inner = (void*)(a & (~1));
46552         a_conv.is_owned = false;
46553         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46554         LDKExpiryTime b_conv;
46555         b_conv.inner = (void*)(b & (~1));
46556         b_conv.is_owned = false;
46557         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46558         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
46559         return ret_conv;
46560 }
46561
46562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46563         LDKMinFinalCltvExpiry this_obj_conv;
46564         this_obj_conv.inner = (void*)(this_obj & (~1));
46565         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46567         MinFinalCltvExpiry_free(this_obj_conv);
46568 }
46569
46570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
46571         LDKMinFinalCltvExpiry this_ptr_conv;
46572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46573         this_ptr_conv.is_owned = false;
46574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46575         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
46576         return ret_conv;
46577 }
46578
46579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46580         LDKMinFinalCltvExpiry this_ptr_conv;
46581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46582         this_ptr_conv.is_owned = false;
46583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46584         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
46585 }
46586
46587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
46588         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
46589         int64_t ret_ref = 0;
46590         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46591         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46593         ret_ref = (uintptr_t)ret_var.inner;
46594         if (ret_var.is_owned) {
46595                 ret_ref |= 1;
46596         }
46597         return ret_ref;
46598 }
46599
46600 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
46601         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
46602 int64_t ret_ref = 0;
46603 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46604 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46605 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46606 ret_ref = (uintptr_t)ret_var.inner;
46607 if (ret_var.is_owned) {
46608         ret_ref |= 1;
46609 }
46610         return ret_ref;
46611 }
46612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46613         LDKMinFinalCltvExpiry arg_conv;
46614         arg_conv.inner = (void*)(arg & (~1));
46615         arg_conv.is_owned = false;
46616         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46617         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
46618         return ret_conv;
46619 }
46620
46621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46622         LDKMinFinalCltvExpiry orig_conv;
46623         orig_conv.inner = (void*)(orig & (~1));
46624         orig_conv.is_owned = false;
46625         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46626         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
46627         int64_t ret_ref = 0;
46628         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46629         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46631         ret_ref = (uintptr_t)ret_var.inner;
46632         if (ret_var.is_owned) {
46633                 ret_ref |= 1;
46634         }
46635         return ret_ref;
46636 }
46637
46638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
46639         LDKMinFinalCltvExpiry o_conv;
46640         o_conv.inner = (void*)(o & (~1));
46641         o_conv.is_owned = false;
46642         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46643         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
46644         return ret_conv;
46645 }
46646
46647 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46648         LDKMinFinalCltvExpiry a_conv;
46649         a_conv.inner = (void*)(a & (~1));
46650         a_conv.is_owned = false;
46651         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46652         LDKMinFinalCltvExpiry b_conv;
46653         b_conv.inner = (void*)(b & (~1));
46654         b_conv.is_owned = false;
46655         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46656         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
46657         return ret_conv;
46658 }
46659
46660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46661         if ((this_ptr & 1) != 0) return;
46662         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46663         CHECK_ACCESS(this_ptr_ptr);
46664         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
46665         FREE((void*)this_ptr);
46666         Fallback_free(this_ptr_conv);
46667 }
46668
46669 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
46670         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
46671         *ret_copy = Fallback_clone(arg);
46672 int64_t ret_ref = (uintptr_t)ret_copy;
46673         return ret_ref;
46674 }
46675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46676         LDKFallback* arg_conv = (LDKFallback*)arg;
46677         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
46678         return ret_conv;
46679 }
46680
46681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46682         LDKFallback* orig_conv = (LDKFallback*)orig;
46683         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
46684         *ret_copy = Fallback_clone(orig_conv);
46685         int64_t ret_ref = (uintptr_t)ret_copy;
46686         return ret_ref;
46687 }
46688
46689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
46690         
46691         LDKCVec_u8Z program_ref;
46692         program_ref.datalen = (*env)->GetArrayLength(env, program);
46693         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
46694         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
46695         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
46696         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
46697         int64_t ret_ref = (uintptr_t)ret_copy;
46698         return ret_ref;
46699 }
46700
46701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
46702         LDKTwentyBytes a_ref;
46703         CHECK((*env)->GetArrayLength(env, a) == 20);
46704         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
46705         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
46706         *ret_copy = Fallback_pub_key_hash(a_ref);
46707         int64_t ret_ref = (uintptr_t)ret_copy;
46708         return ret_ref;
46709 }
46710
46711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
46712         LDKTwentyBytes a_ref;
46713         CHECK((*env)->GetArrayLength(env, a) == 20);
46714         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
46715         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
46716         *ret_copy = Fallback_script_hash(a_ref);
46717         int64_t ret_ref = (uintptr_t)ret_copy;
46718         return ret_ref;
46719 }
46720
46721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
46722         LDKFallback* o_conv = (LDKFallback*)o;
46723         int64_t ret_conv = Fallback_hash(o_conv);
46724         return ret_conv;
46725 }
46726
46727 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46728         LDKFallback* a_conv = (LDKFallback*)a;
46729         LDKFallback* b_conv = (LDKFallback*)b;
46730         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
46731         return ret_conv;
46732 }
46733
46734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46735         LDKInvoiceSignature this_obj_conv;
46736         this_obj_conv.inner = (void*)(this_obj & (~1));
46737         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46739         InvoiceSignature_free(this_obj_conv);
46740 }
46741
46742 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
46743         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
46744 int64_t ret_ref = 0;
46745 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46746 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46747 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46748 ret_ref = (uintptr_t)ret_var.inner;
46749 if (ret_var.is_owned) {
46750         ret_ref |= 1;
46751 }
46752         return ret_ref;
46753 }
46754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46755         LDKInvoiceSignature arg_conv;
46756         arg_conv.inner = (void*)(arg & (~1));
46757         arg_conv.is_owned = false;
46758         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46759         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
46760         return ret_conv;
46761 }
46762
46763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46764         LDKInvoiceSignature orig_conv;
46765         orig_conv.inner = (void*)(orig & (~1));
46766         orig_conv.is_owned = false;
46767         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46768         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
46769         int64_t ret_ref = 0;
46770         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46771         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46773         ret_ref = (uintptr_t)ret_var.inner;
46774         if (ret_var.is_owned) {
46775                 ret_ref |= 1;
46776         }
46777         return ret_ref;
46778 }
46779
46780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46781         LDKInvoiceSignature a_conv;
46782         a_conv.inner = (void*)(a & (~1));
46783         a_conv.is_owned = false;
46784         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46785         LDKInvoiceSignature b_conv;
46786         b_conv.inner = (void*)(b & (~1));
46787         b_conv.is_owned = false;
46788         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46789         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
46790         return ret_conv;
46791 }
46792
46793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46794         LDKPrivateRoute this_obj_conv;
46795         this_obj_conv.inner = (void*)(this_obj & (~1));
46796         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46798         PrivateRoute_free(this_obj_conv);
46799 }
46800
46801 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
46802         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
46803 int64_t ret_ref = 0;
46804 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46805 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46806 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46807 ret_ref = (uintptr_t)ret_var.inner;
46808 if (ret_var.is_owned) {
46809         ret_ref |= 1;
46810 }
46811         return ret_ref;
46812 }
46813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46814         LDKPrivateRoute arg_conv;
46815         arg_conv.inner = (void*)(arg & (~1));
46816         arg_conv.is_owned = false;
46817         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46818         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
46819         return ret_conv;
46820 }
46821
46822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46823         LDKPrivateRoute orig_conv;
46824         orig_conv.inner = (void*)(orig & (~1));
46825         orig_conv.is_owned = false;
46826         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46827         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
46828         int64_t ret_ref = 0;
46829         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46830         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46832         ret_ref = (uintptr_t)ret_var.inner;
46833         if (ret_var.is_owned) {
46834                 ret_ref |= 1;
46835         }
46836         return ret_ref;
46837 }
46838
46839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
46840         LDKPrivateRoute o_conv;
46841         o_conv.inner = (void*)(o & (~1));
46842         o_conv.is_owned = false;
46843         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46844         int64_t ret_conv = PrivateRoute_hash(&o_conv);
46845         return ret_conv;
46846 }
46847
46848 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46849         LDKPrivateRoute a_conv;
46850         a_conv.inner = (void*)(a & (~1));
46851         a_conv.is_owned = false;
46852         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46853         LDKPrivateRoute b_conv;
46854         b_conv.inner = (void*)(b & (~1));
46855         b_conv.is_owned = false;
46856         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46857         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
46858         return ret_conv;
46859 }
46860
46861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
46862         LDKSignedRawInvoice this_arg_conv;
46863         this_arg_conv.inner = (void*)(this_arg & (~1));
46864         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
46865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46866         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
46867         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
46868         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
46869         return ((int64_t)ret_conv);
46870 }
46871
46872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
46873         LDKSignedRawInvoice this_arg_conv;
46874         this_arg_conv.inner = (void*)(this_arg & (~1));
46875         this_arg_conv.is_owned = false;
46876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46877         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
46878         int64_t ret_ref = 0;
46879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46882         ret_ref = (uintptr_t)ret_var.inner;
46883         if (ret_var.is_owned) {
46884                 ret_ref |= 1;
46885         }
46886         return ret_ref;
46887 }
46888
46889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
46890         LDKSignedRawInvoice this_arg_conv;
46891         this_arg_conv.inner = (void*)(this_arg & (~1));
46892         this_arg_conv.is_owned = false;
46893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46894         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
46895         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
46896         return ret_arr;
46897 }
46898
46899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
46900         LDKSignedRawInvoice this_arg_conv;
46901         this_arg_conv.inner = (void*)(this_arg & (~1));
46902         this_arg_conv.is_owned = false;
46903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46904         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
46905         int64_t ret_ref = 0;
46906         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46907         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46909         ret_ref = (uintptr_t)ret_var.inner;
46910         if (ret_var.is_owned) {
46911                 ret_ref |= 1;
46912         }
46913         return ret_ref;
46914 }
46915
46916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
46917         LDKSignedRawInvoice this_arg_conv;
46918         this_arg_conv.inner = (void*)(this_arg & (~1));
46919         this_arg_conv.is_owned = false;
46920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46921         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
46922         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
46923         return (int64_t)ret_conv;
46924 }
46925
46926 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
46927         LDKSignedRawInvoice this_arg_conv;
46928         this_arg_conv.inner = (void*)(this_arg & (~1));
46929         this_arg_conv.is_owned = false;
46930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46931         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
46932         return ret_conv;
46933 }
46934
46935 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
46936         LDKRawInvoice this_arg_conv;
46937         this_arg_conv.inner = (void*)(this_arg & (~1));
46938         this_arg_conv.is_owned = false;
46939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46940         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
46941         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
46942         return ret_arr;
46943 }
46944
46945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
46946         LDKRawInvoice this_arg_conv;
46947         this_arg_conv.inner = (void*)(this_arg & (~1));
46948         this_arg_conv.is_owned = false;
46949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46950         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
46951         int64_t ret_ref = 0;
46952         if ((uintptr_t)ret_var.inner > 4096) {
46953                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46954                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46956                 ret_ref = (uintptr_t)ret_var.inner;
46957                 if (ret_var.is_owned) {
46958                         ret_ref |= 1;
46959                 }
46960         }
46961         return ret_ref;
46962 }
46963
46964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
46965         LDKRawInvoice this_arg_conv;
46966         this_arg_conv.inner = (void*)(this_arg & (~1));
46967         this_arg_conv.is_owned = false;
46968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46969         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
46970         int64_t ret_ref = 0;
46971         if ((uintptr_t)ret_var.inner > 4096) {
46972                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46973                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46975                 ret_ref = (uintptr_t)ret_var.inner;
46976                 if (ret_var.is_owned) {
46977                         ret_ref |= 1;
46978                 }
46979         }
46980         return ret_ref;
46981 }
46982
46983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
46984         LDKRawInvoice this_arg_conv;
46985         this_arg_conv.inner = (void*)(this_arg & (~1));
46986         this_arg_conv.is_owned = false;
46987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46988         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
46989         int64_t ret_ref = 0;
46990         if ((uintptr_t)ret_var.inner > 4096) {
46991                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46992                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46994                 ret_ref = (uintptr_t)ret_var.inner;
46995                 if (ret_var.is_owned) {
46996                         ret_ref |= 1;
46997                 }
46998         }
46999         return ret_ref;
47000 }
47001
47002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
47003         LDKRawInvoice this_arg_conv;
47004         this_arg_conv.inner = (void*)(this_arg & (~1));
47005         this_arg_conv.is_owned = false;
47006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47007         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
47008         int64_t ret_ref = 0;
47009         if ((uintptr_t)ret_var.inner > 4096) {
47010                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47011                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47013                 ret_ref = (uintptr_t)ret_var.inner;
47014                 if (ret_var.is_owned) {
47015                         ret_ref |= 1;
47016                 }
47017         }
47018         return ret_ref;
47019 }
47020
47021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
47022         LDKRawInvoice this_arg_conv;
47023         this_arg_conv.inner = (void*)(this_arg & (~1));
47024         this_arg_conv.is_owned = false;
47025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47026         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
47027         int64_t ret_ref = 0;
47028         if ((uintptr_t)ret_var.inner > 4096) {
47029                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47030                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47031         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47032                 ret_ref = (uintptr_t)ret_var.inner;
47033                 if (ret_var.is_owned) {
47034                         ret_ref |= 1;
47035                 }
47036         }
47037         return ret_ref;
47038 }
47039
47040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
47041         LDKRawInvoice this_arg_conv;
47042         this_arg_conv.inner = (void*)(this_arg & (~1));
47043         this_arg_conv.is_owned = false;
47044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47045         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
47046         int64_t ret_ref = 0;
47047         if ((uintptr_t)ret_var.inner > 4096) {
47048                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47049                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47051                 ret_ref = (uintptr_t)ret_var.inner;
47052                 if (ret_var.is_owned) {
47053                         ret_ref |= 1;
47054                 }
47055         }
47056         return ret_ref;
47057 }
47058
47059 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
47060         LDKRawInvoice this_arg_conv;
47061         this_arg_conv.inner = (void*)(this_arg & (~1));
47062         this_arg_conv.is_owned = false;
47063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47064         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47065         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
47066         return ret_arr;
47067 }
47068
47069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47070         LDKRawInvoice this_arg_conv;
47071         this_arg_conv.inner = (void*)(this_arg & (~1));
47072         this_arg_conv.is_owned = false;
47073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47074         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
47075         int64_t ret_ref = 0;
47076         if ((uintptr_t)ret_var.inner > 4096) {
47077                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47078                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47080                 ret_ref = (uintptr_t)ret_var.inner;
47081                 if (ret_var.is_owned) {
47082                         ret_ref |= 1;
47083                 }
47084         }
47085         return ret_ref;
47086 }
47087
47088 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
47089         LDKRawInvoice this_arg_conv;
47090         this_arg_conv.inner = (void*)(this_arg & (~1));
47091         this_arg_conv.is_owned = false;
47092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47093         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
47094         int64_tArray ret_arr = NULL;
47095         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47096         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47097         for (size_t o = 0; o < ret_var.datalen; o++) {
47098                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
47099                 int64_t ret_conv_14_ref = 0;
47100                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47101                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47102                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
47103                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
47104                 if (ret_conv_14_var.is_owned) {
47105                         ret_conv_14_ref |= 1;
47106                 }
47107                 ret_arr_ptr[o] = ret_conv_14_ref;
47108         }
47109         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47110         FREE(ret_var.data);
47111         return ret_arr;
47112 }
47113
47114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
47115         LDKRawInvoice this_arg_conv;
47116         this_arg_conv.inner = (void*)(this_arg & (~1));
47117         this_arg_conv.is_owned = false;
47118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47119         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47120         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
47121         int64_t ret_ref = (uintptr_t)ret_copy;
47122         return ret_ref;
47123 }
47124
47125 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
47126         LDKRawInvoice this_arg_conv;
47127         this_arg_conv.inner = (void*)(this_arg & (~1));
47128         this_arg_conv.is_owned = false;
47129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47130         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
47131         return ret_conv;
47132 }
47133
47134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
47135         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
47136         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
47137         return (int64_t)ret_conv;
47138 }
47139
47140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
47141         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
47142         *ret_conv = PositiveTimestamp_from_system_time(time);
47143         return (int64_t)ret_conv;
47144 }
47145
47146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
47147         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
47148         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
47149         return (int64_t)ret_conv;
47150 }
47151
47152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
47153         LDKPositiveTimestamp this_arg_conv;
47154         this_arg_conv.inner = (void*)(this_arg & (~1));
47155         this_arg_conv.is_owned = false;
47156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47157         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
47158         return ret_conv;
47159 }
47160
47161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
47162         LDKPositiveTimestamp this_arg_conv;
47163         this_arg_conv.inner = (void*)(this_arg & (~1));
47164         this_arg_conv.is_owned = false;
47165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47166         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
47167         return ret_conv;
47168 }
47169
47170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
47171         LDKPositiveTimestamp this_arg_conv;
47172         this_arg_conv.inner = (void*)(this_arg & (~1));
47173         this_arg_conv.is_owned = false;
47174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47175         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
47176         return ret_conv;
47177 }
47178
47179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
47180         LDKInvoice this_arg_conv;
47181         this_arg_conv.inner = (void*)(this_arg & (~1));
47182         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47184         this_arg_conv = Invoice_clone(&this_arg_conv);
47185         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
47186         int64_t ret_ref = 0;
47187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47190         ret_ref = (uintptr_t)ret_var.inner;
47191         if (ret_var.is_owned) {
47192                 ret_ref |= 1;
47193         }
47194         return ret_ref;
47195 }
47196
47197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
47198         LDKInvoice this_arg_conv;
47199         this_arg_conv.inner = (void*)(this_arg & (~1));
47200         this_arg_conv.is_owned = false;
47201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47202         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
47203         *ret_conv = Invoice_check_signature(&this_arg_conv);
47204         return (int64_t)ret_conv;
47205 }
47206
47207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
47208         LDKSignedRawInvoice signed_invoice_conv;
47209         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
47210         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
47211         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
47212         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
47213         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
47214         *ret_conv = Invoice_from_signed(signed_invoice_conv);
47215         return (int64_t)ret_conv;
47216 }
47217
47218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
47219         LDKInvoice this_arg_conv;
47220         this_arg_conv.inner = (void*)(this_arg & (~1));
47221         this_arg_conv.is_owned = false;
47222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47223         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
47224         return ret_conv;
47225 }
47226
47227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
47228         LDKInvoice this_arg_conv;
47229         this_arg_conv.inner = (void*)(this_arg & (~1));
47230         this_arg_conv.is_owned = false;
47231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47232         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
47233         return ret_conv;
47234 }
47235
47236 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
47237         LDKInvoice this_arg_conv;
47238         this_arg_conv.inner = (void*)(this_arg & (~1));
47239         this_arg_conv.is_owned = false;
47240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47241         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47242         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
47243         return ret_arr;
47244 }
47245
47246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
47247         LDKInvoice this_arg_conv;
47248         this_arg_conv.inner = (void*)(this_arg & (~1));
47249         this_arg_conv.is_owned = false;
47250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47251         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47252         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
47253         return ret_arr;
47254 }
47255
47256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
47257         LDKInvoice this_arg_conv;
47258         this_arg_conv.inner = (void*)(this_arg & (~1));
47259         this_arg_conv.is_owned = false;
47260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47261         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47262         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
47263         return ret_arr;
47264 }
47265
47266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47267         LDKInvoice this_arg_conv;
47268         this_arg_conv.inner = (void*)(this_arg & (~1));
47269         this_arg_conv.is_owned = false;
47270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47271         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
47272         int64_t ret_ref = 0;
47273         if ((uintptr_t)ret_var.inner > 4096) {
47274                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47275                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47277                 ret_ref = (uintptr_t)ret_var.inner;
47278                 if (ret_var.is_owned) {
47279                         ret_ref |= 1;
47280                 }
47281         }
47282         return ret_ref;
47283 }
47284
47285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
47286         LDKInvoice this_arg_conv;
47287         this_arg_conv.inner = (void*)(this_arg & (~1));
47288         this_arg_conv.is_owned = false;
47289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47290         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47291         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
47292         return ret_arr;
47293 }
47294
47295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
47296         LDKInvoice this_arg_conv;
47297         this_arg_conv.inner = (void*)(this_arg & (~1));
47298         this_arg_conv.is_owned = false;
47299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47300         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
47301         return ret_conv;
47302 }
47303
47304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
47305         LDKInvoice this_arg_conv;
47306         this_arg_conv.inner = (void*)(this_arg & (~1));
47307         this_arg_conv.is_owned = false;
47308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47309         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
47310         return ret_conv;
47311 }
47312
47313 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
47314         LDKInvoice this_arg_conv;
47315         this_arg_conv.inner = (void*)(this_arg & (~1));
47316         this_arg_conv.is_owned = false;
47317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47318         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
47319         return ret_conv;
47320 }
47321
47322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
47323         LDKInvoice this_arg_conv;
47324         this_arg_conv.inner = (void*)(this_arg & (~1));
47325         this_arg_conv.is_owned = false;
47326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47327         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
47328         return ret_conv;
47329 }
47330
47331 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
47332         LDKInvoice this_arg_conv;
47333         this_arg_conv.inner = (void*)(this_arg & (~1));
47334         this_arg_conv.is_owned = false;
47335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47336         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
47337         int64_tArray ret_arr = NULL;
47338         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47339         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47340         for (size_t o = 0; o < ret_var.datalen; o++) {
47341                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
47342                 int64_t ret_conv_14_ref = 0;
47343                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47344                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47345                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
47346                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
47347                 if (ret_conv_14_var.is_owned) {
47348                         ret_conv_14_ref |= 1;
47349                 }
47350                 ret_arr_ptr[o] = ret_conv_14_ref;
47351         }
47352         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47353         FREE(ret_var.data);
47354         return ret_arr;
47355 }
47356
47357 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
47358         LDKInvoice this_arg_conv;
47359         this_arg_conv.inner = (void*)(this_arg & (~1));
47360         this_arg_conv.is_owned = false;
47361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47362         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
47363         int64_tArray ret_arr = NULL;
47364         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47365         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47366         for (size_t l = 0; l < ret_var.datalen; l++) {
47367                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
47368                 int64_t ret_conv_11_ref = 0;
47369                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47370                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47371                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
47372                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
47373                 if (ret_conv_11_var.is_owned) {
47374                         ret_conv_11_ref |= 1;
47375                 }
47376                 ret_arr_ptr[l] = ret_conv_11_ref;
47377         }
47378         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47379         FREE(ret_var.data);
47380         return ret_arr;
47381 }
47382
47383 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
47384         LDKInvoice this_arg_conv;
47385         this_arg_conv.inner = (void*)(this_arg & (~1));
47386         this_arg_conv.is_owned = false;
47387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47388         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
47389         return ret_conv;
47390 }
47391
47392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
47393         LDKInvoice this_arg_conv;
47394         this_arg_conv.inner = (void*)(this_arg & (~1));
47395         this_arg_conv.is_owned = false;
47396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47397         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47398         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
47399         int64_t ret_ref = (uintptr_t)ret_copy;
47400         return ret_ref;
47401 }
47402
47403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
47404         LDKStr description_conv = java_to_owned_str(env, description);
47405         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
47406         *ret_conv = Description_new(description_conv);
47407         return (int64_t)ret_conv;
47408 }
47409
47410 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
47411         LDKDescription this_arg_conv;
47412         this_arg_conv.inner = (void*)(this_arg & (~1));
47413         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47415         this_arg_conv = Description_clone(&this_arg_conv);
47416         LDKStr ret_str = Description_into_inner(this_arg_conv);
47417         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47418         Str_free(ret_str);
47419         return ret_conv;
47420 }
47421
47422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
47423         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
47424         int64_t ret_ref = 0;
47425         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47426         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47428         ret_ref = (uintptr_t)ret_var.inner;
47429         if (ret_var.is_owned) {
47430                 ret_ref |= 1;
47431         }
47432         return ret_ref;
47433 }
47434
47435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
47436         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
47437         int64_t ret_ref = 0;
47438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47441         ret_ref = (uintptr_t)ret_var.inner;
47442         if (ret_var.is_owned) {
47443                 ret_ref |= 1;
47444         }
47445         return ret_ref;
47446 }
47447
47448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
47449         LDKExpiryTime this_arg_conv;
47450         this_arg_conv.inner = (void*)(this_arg & (~1));
47451         this_arg_conv.is_owned = false;
47452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47453         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
47454         return ret_conv;
47455 }
47456
47457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
47458         LDKExpiryTime this_arg_conv;
47459         this_arg_conv.inner = (void*)(this_arg & (~1));
47460         this_arg_conv.is_owned = false;
47461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47462         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
47463         return ret_conv;
47464 }
47465
47466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
47467         LDKRouteHint hops_conv;
47468         hops_conv.inner = (void*)(hops & (~1));
47469         hops_conv.is_owned = (hops & 1) || (hops == 0);
47470         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
47471         hops_conv = RouteHint_clone(&hops_conv);
47472         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
47473         *ret_conv = PrivateRoute_new(hops_conv);
47474         return (int64_t)ret_conv;
47475 }
47476
47477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
47478         LDKPrivateRoute this_arg_conv;
47479         this_arg_conv.inner = (void*)(this_arg & (~1));
47480         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47482         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
47483         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
47484         int64_t ret_ref = 0;
47485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47488         ret_ref = (uintptr_t)ret_var.inner;
47489         if (ret_var.is_owned) {
47490                 ret_ref |= 1;
47491         }
47492         return ret_ref;
47493 }
47494
47495 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47496         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
47497         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
47498         return ret_conv;
47499 }
47500
47501 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
47502         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
47503         return ret_conv;
47504 }
47505
47506 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
47507         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
47508         return ret_conv;
47509 }
47510
47511 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
47512         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
47513         return ret_conv;
47514 }
47515
47516 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
47517         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
47518         return ret_conv;
47519 }
47520
47521 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
47522         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
47523         return ret_conv;
47524 }
47525
47526 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47527         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
47528         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
47529         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
47530         return ret_conv;
47531 }
47532
47533 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
47534         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
47535         LDKStr ret_str = CreationError_to_str(o_conv);
47536         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47537         Str_free(ret_str);
47538         return ret_conv;
47539 }
47540
47541 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47542         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
47543         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
47544         return ret_conv;
47545 }
47546
47547 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
47548         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
47549         return ret_conv;
47550 }
47551
47552 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
47553         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
47554         return ret_conv;
47555 }
47556
47557 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
47558         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
47559         return ret_conv;
47560 }
47561
47562 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
47563         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
47564         return ret_conv;
47565 }
47566
47567 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
47568         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
47569         return ret_conv;
47570 }
47571
47572 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
47573         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
47574         return ret_conv;
47575 }
47576
47577 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
47578         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
47579         return ret_conv;
47580 }
47581
47582 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
47583         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
47584         return ret_conv;
47585 }
47586
47587 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
47588         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
47589         return ret_conv;
47590 }
47591
47592 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
47593         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
47594         return ret_conv;
47595 }
47596
47597 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47598         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
47599         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
47600         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
47601         return ret_conv;
47602 }
47603
47604 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
47605         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
47606         LDKStr ret_str = SemanticError_to_str(o_conv);
47607         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47608         Str_free(ret_str);
47609         return ret_conv;
47610 }
47611
47612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47613         if ((this_ptr & 1) != 0) return;
47614         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47615         CHECK_ACCESS(this_ptr_ptr);
47616         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
47617         FREE((void*)this_ptr);
47618         SignOrCreationError_free(this_ptr_conv);
47619 }
47620
47621 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
47622         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
47623         *ret_copy = SignOrCreationError_clone(arg);
47624 int64_t ret_ref = (uintptr_t)ret_copy;
47625         return ret_ref;
47626 }
47627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47628         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
47629         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
47630         return ret_conv;
47631 }
47632
47633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47634         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
47635         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
47636         *ret_copy = SignOrCreationError_clone(orig_conv);
47637         int64_t ret_ref = (uintptr_t)ret_copy;
47638         return ret_ref;
47639 }
47640
47641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
47642         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
47643         *ret_copy = SignOrCreationError_sign_error();
47644         int64_t ret_ref = (uintptr_t)ret_copy;
47645         return ret_ref;
47646 }
47647
47648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
47649         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
47650         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
47651         *ret_copy = SignOrCreationError_creation_error(a_conv);
47652         int64_t ret_ref = (uintptr_t)ret_copy;
47653         return ret_ref;
47654 }
47655
47656 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47657         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
47658         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
47659         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
47660         return ret_conv;
47661 }
47662
47663 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
47664         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
47665         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
47666         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47667         Str_free(ret_str);
47668         return ret_conv;
47669 }
47670
47671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47672         LDKInvoicePayer this_obj_conv;
47673         this_obj_conv.inner = (void*)(this_obj & (~1));
47674         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47676         InvoicePayer_free(this_obj_conv);
47677 }
47678
47679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47680         if ((this_ptr & 1) != 0) return;
47681         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47682         CHECK_ACCESS(this_ptr_ptr);
47683         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
47684         FREE((void*)this_ptr);
47685         Payer_free(this_ptr_conv);
47686 }
47687
47688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47689         if ((this_ptr & 1) != 0) return;
47690         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47691         CHECK_ACCESS(this_ptr_ptr);
47692         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
47693         FREE((void*)this_ptr);
47694         Router_free(this_ptr_conv);
47695 }
47696
47697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47698         if ((this_ptr & 1) != 0) return;
47699         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47700         CHECK_ACCESS(this_ptr_ptr);
47701         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
47702         FREE((void*)this_ptr);
47703         Retry_free(this_ptr_conv);
47704 }
47705
47706 static inline uintptr_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
47707         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
47708         *ret_copy = Retry_clone(arg);
47709 int64_t ret_ref = (uintptr_t)ret_copy;
47710         return ret_ref;
47711 }
47712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47713         LDKRetry* arg_conv = (LDKRetry*)arg;
47714         int64_t ret_conv = Retry_clone_ptr(arg_conv);
47715         return ret_conv;
47716 }
47717
47718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47719         LDKRetry* orig_conv = (LDKRetry*)orig;
47720         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
47721         *ret_copy = Retry_clone(orig_conv);
47722         int64_t ret_ref = (uintptr_t)ret_copy;
47723         return ret_ref;
47724 }
47725
47726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
47727         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
47728         *ret_copy = Retry_attempts(a);
47729         int64_t ret_ref = (uintptr_t)ret_copy;
47730         return ret_ref;
47731 }
47732
47733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
47734         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
47735         *ret_copy = Retry_timeout(a);
47736         int64_t ret_ref = (uintptr_t)ret_copy;
47737         return ret_ref;
47738 }
47739
47740 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47741         LDKRetry* a_conv = (LDKRetry*)a;
47742         LDKRetry* b_conv = (LDKRetry*)b;
47743         jboolean ret_conv = Retry_eq(a_conv, b_conv);
47744         return ret_conv;
47745 }
47746
47747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
47748         LDKRetry* o_conv = (LDKRetry*)o;
47749         int64_t ret_conv = Retry_hash(o_conv);
47750         return ret_conv;
47751 }
47752
47753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47754         if ((this_ptr & 1) != 0) return;
47755         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47756         CHECK_ACCESS(this_ptr_ptr);
47757         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
47758         FREE((void*)this_ptr);
47759         PaymentError_free(this_ptr_conv);
47760 }
47761
47762 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
47763         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
47764         *ret_copy = PaymentError_clone(arg);
47765 int64_t ret_ref = (uintptr_t)ret_copy;
47766         return ret_ref;
47767 }
47768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47769         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
47770         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
47771         return ret_conv;
47772 }
47773
47774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47775         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
47776         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
47777         *ret_copy = PaymentError_clone(orig_conv);
47778         int64_t ret_ref = (uintptr_t)ret_copy;
47779         return ret_ref;
47780 }
47781
47782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
47783         LDKStr a_conv = java_to_owned_str(env, a);
47784         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
47785         *ret_copy = PaymentError_invoice(a_conv);
47786         int64_t ret_ref = (uintptr_t)ret_copy;
47787         return ret_ref;
47788 }
47789
47790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
47791         LDKLightningError a_conv;
47792         a_conv.inner = (void*)(a & (~1));
47793         a_conv.is_owned = (a & 1) || (a == 0);
47794         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47795         a_conv = LightningError_clone(&a_conv);
47796         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
47797         *ret_copy = PaymentError_routing(a_conv);
47798         int64_t ret_ref = (uintptr_t)ret_copy;
47799         return ret_ref;
47800 }
47801
47802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
47803         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
47804         CHECK_ACCESS(a_ptr);
47805         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
47806         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
47807         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
47808         *ret_copy = PaymentError_sending(a_conv);
47809         int64_t ret_ref = (uintptr_t)ret_copy;
47810         return ret_ref;
47811 }
47812
47813 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) {
47814         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
47815         CHECK_ACCESS(payer_ptr);
47816         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
47817         if (payer_conv.free == LDKPayer_JCalls_free) {
47818                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47819                 LDKPayer_JCalls_cloned(&payer_conv);
47820         }
47821         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
47822         CHECK_ACCESS(router_ptr);
47823         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
47824         if (router_conv.free == LDKRouter_JCalls_free) {
47825                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47826                 LDKRouter_JCalls_cloned(&router_conv);
47827         }
47828         LDKMultiThreadedLockableScore scorer_conv;
47829         scorer_conv.inner = (void*)(scorer & (~1));
47830         scorer_conv.is_owned = false;
47831         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
47832         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
47833         CHECK_ACCESS(logger_ptr);
47834         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47835         if (logger_conv.free == LDKLogger_JCalls_free) {
47836                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47837                 LDKLogger_JCalls_cloned(&logger_conv);
47838         }
47839         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
47840         CHECK_ACCESS(event_handler_ptr);
47841         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
47842         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
47843                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47844                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
47845         }
47846         void* retry_ptr = (void*)(((uintptr_t)retry) & ~1);
47847         CHECK_ACCESS(retry_ptr);
47848         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
47849         retry_conv = Retry_clone((LDKRetry*)(((uintptr_t)retry) & ~1));
47850         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
47851         int64_t ret_ref = 0;
47852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47855         ret_ref = (uintptr_t)ret_var.inner;
47856         if (ret_var.is_owned) {
47857                 ret_ref |= 1;
47858         }
47859         return ret_ref;
47860 }
47861
47862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
47863         LDKInvoicePayer this_arg_conv;
47864         this_arg_conv.inner = (void*)(this_arg & (~1));
47865         this_arg_conv.is_owned = false;
47866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47867         LDKInvoice invoice_conv;
47868         invoice_conv.inner = (void*)(invoice & (~1));
47869         invoice_conv.is_owned = false;
47870         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
47871         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
47872         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
47873         return (int64_t)ret_conv;
47874 }
47875
47876 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) {
47877         LDKInvoicePayer this_arg_conv;
47878         this_arg_conv.inner = (void*)(this_arg & (~1));
47879         this_arg_conv.is_owned = false;
47880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47881         LDKInvoice invoice_conv;
47882         invoice_conv.inner = (void*)(invoice & (~1));
47883         invoice_conv.is_owned = false;
47884         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
47885         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
47886         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
47887         return (int64_t)ret_conv;
47888 }
47889
47890 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) {
47891         LDKInvoicePayer this_arg_conv;
47892         this_arg_conv.inner = (void*)(this_arg & (~1));
47893         this_arg_conv.is_owned = false;
47894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47895         LDKPublicKey pubkey_ref;
47896         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
47897         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
47898         LDKThirtyTwoBytes payment_preimage_ref;
47899         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
47900         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
47901         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
47902         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
47903         return (int64_t)ret_conv;
47904 }
47905
47906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
47907         LDKInvoicePayer this_arg_conv;
47908         this_arg_conv.inner = (void*)(this_arg & (~1));
47909         this_arg_conv.is_owned = false;
47910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47911         unsigned char payment_hash_arr[32];
47912         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
47913         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
47914         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
47915         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
47916 }
47917
47918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
47919         LDKInvoicePayer this_arg_conv;
47920         this_arg_conv.inner = (void*)(this_arg & (~1));
47921         this_arg_conv.is_owned = false;
47922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47923         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
47924         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
47925         return (int64_t)ret_ret;
47926 }
47927
47928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice(JNIEnv *env, jclass clz, int64_t amt_msat, int8_tArray payment_hash, jstring description, int32_t invoice_expiry_delta_secs, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
47929         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
47930         CHECK_ACCESS(amt_msat_ptr);
47931         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
47932         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
47933         LDKThirtyTwoBytes payment_hash_ref;
47934         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
47935         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
47936         LDKStr description_conv = java_to_owned_str(env, description);
47937         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
47938         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
47939         if (phantom_route_hints_constr.datalen > 0)
47940                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
47941         else
47942                 phantom_route_hints_constr.data = NULL;
47943         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
47944         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
47945                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
47946                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
47947                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
47948                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
47949                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
47950                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
47951                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
47952         }
47953         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
47954         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
47955         CHECK_ACCESS(keys_manager_ptr);
47956         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
47957         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
47958                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47959                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
47960         }
47961         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
47962         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
47963         *ret_conv = create_phantom_invoice(amt_msat_conv, payment_hash_ref, description_conv, invoice_expiry_delta_secs, phantom_route_hints_constr, keys_manager_conv, network_conv);
47964         return (int64_t)ret_conv;
47965 }
47966
47967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t amt_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t description_hash, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
47968         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
47969         CHECK_ACCESS(amt_msat_ptr);
47970         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
47971         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
47972         LDKThirtyTwoBytes payment_hash_ref;
47973         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
47974         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
47975         LDKSha256 description_hash_conv;
47976         description_hash_conv.inner = (void*)(description_hash & (~1));
47977         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
47978         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
47979         description_hash_conv = Sha256_clone(&description_hash_conv);
47980         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
47981         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
47982         if (phantom_route_hints_constr.datalen > 0)
47983                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
47984         else
47985                 phantom_route_hints_constr.data = NULL;
47986         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
47987         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
47988                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
47989                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
47990                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
47991                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
47992                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
47993                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
47994                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
47995         }
47996         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
47997         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
47998         CHECK_ACCESS(keys_manager_ptr);
47999         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48000         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48001                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48002                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48003         }
48004         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48005         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48006         *ret_conv = create_phantom_invoice_with_description_hash(amt_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, description_hash_conv, phantom_route_hints_constr, keys_manager_conv, network_conv);
48007         return (int64_t)ret_conv;
48008 }
48009
48010 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, int32_t invoice_expiry_delta_secs) {
48011         LDKChannelManager channelmanager_conv;
48012         channelmanager_conv.inner = (void*)(channelmanager & (~1));
48013         channelmanager_conv.is_owned = false;
48014         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
48015         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48016         CHECK_ACCESS(keys_manager_ptr);
48017         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48018         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48019                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48020                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48021         }
48022         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48023         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48024         CHECK_ACCESS(amt_msat_ptr);
48025         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48026         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48027         LDKStr description_conv = java_to_owned_str(env, description);
48028         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48029         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs);
48030         return (int64_t)ret_conv;
48031 }
48032
48033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, int64_t description_hash, int32_t invoice_expiry_delta_secs) {
48034         LDKChannelManager channelmanager_conv;
48035         channelmanager_conv.inner = (void*)(channelmanager & (~1));
48036         channelmanager_conv.is_owned = false;
48037         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
48038         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48039         CHECK_ACCESS(keys_manager_ptr);
48040         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48041         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48042                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48043                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48044         }
48045         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48046         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48047         CHECK_ACCESS(amt_msat_ptr);
48048         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48049         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48050         LDKSha256 description_hash_conv;
48051         description_hash_conv.inner = (void*)(description_hash & (~1));
48052         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
48053         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
48054         description_hash_conv = Sha256_clone(&description_hash_conv);
48055         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48056         *ret_conv = create_invoice_from_channelmanager_with_description_hash(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, invoice_expiry_delta_secs);
48057         return (int64_t)ret_conv;
48058 }
48059
48060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, int64_t description_hash, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
48061         LDKChannelManager channelmanager_conv;
48062         channelmanager_conv.inner = (void*)(channelmanager & (~1));
48063         channelmanager_conv.is_owned = false;
48064         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
48065         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48066         CHECK_ACCESS(keys_manager_ptr);
48067         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48068         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48069                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48070                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48071         }
48072         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48073         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48074         CHECK_ACCESS(amt_msat_ptr);
48075         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48076         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48077         LDKSha256 description_hash_conv;
48078         description_hash_conv.inner = (void*)(description_hash & (~1));
48079         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
48080         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
48081         description_hash_conv = Sha256_clone(&description_hash_conv);
48082         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48083         *ret_conv = create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, duration_since_epoch, invoice_expiry_delta_secs);
48084         return (int64_t)ret_conv;
48085 }
48086
48087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
48088         LDKChannelManager channelmanager_conv;
48089         channelmanager_conv.inner = (void*)(channelmanager & (~1));
48090         channelmanager_conv.is_owned = false;
48091         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
48092         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48093         CHECK_ACCESS(keys_manager_ptr);
48094         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48095         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48096                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48097                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48098         }
48099         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48100         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48101         CHECK_ACCESS(amt_msat_ptr);
48102         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48103         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48104         LDKStr description_conv = java_to_owned_str(env, description);
48105         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48106         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch, invoice_expiry_delta_secs);
48107         return (int64_t)ret_conv;
48108 }
48109
48110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48111         LDKDefaultRouter this_obj_conv;
48112         this_obj_conv.inner = (void*)(this_obj & (~1));
48113         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48115         DefaultRouter_free(this_obj_conv);
48116 }
48117
48118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger, int8_tArray random_seed_bytes) {
48119         LDKNetworkGraph network_graph_conv;
48120         network_graph_conv.inner = (void*)(network_graph & (~1));
48121         network_graph_conv.is_owned = false;
48122         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
48123         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
48124         CHECK_ACCESS(logger_ptr);
48125         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48126         if (logger_conv.free == LDKLogger_JCalls_free) {
48127                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48128                 LDKLogger_JCalls_cloned(&logger_conv);
48129         }
48130         LDKThirtyTwoBytes random_seed_bytes_ref;
48131         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
48132         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
48133         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
48134         int64_t ret_ref = 0;
48135         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48136         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48138         ret_ref = (uintptr_t)ret_var.inner;
48139         if (ret_var.is_owned) {
48140                 ret_ref |= 1;
48141         }
48142         return ret_ref;
48143 }
48144
48145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
48146         LDKDefaultRouter this_arg_conv;
48147         this_arg_conv.inner = (void*)(this_arg & (~1));
48148         this_arg_conv.is_owned = false;
48149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48150         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
48151         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
48152         return (int64_t)ret_ret;
48153 }
48154
48155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
48156         LDKChannelManager this_arg_conv;
48157         this_arg_conv.inner = (void*)(this_arg & (~1));
48158         this_arg_conv.is_owned = false;
48159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48160         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
48161         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
48162         return (int64_t)ret_ret;
48163 }
48164
48165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
48166         LDKStr s_conv = java_to_owned_str(env, s);
48167         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
48168         *ret_conv = SiPrefix_from_str(s_conv);
48169         return (int64_t)ret_conv;
48170 }
48171
48172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
48173         LDKStr s_conv = java_to_owned_str(env, s);
48174         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
48175         *ret_conv = Invoice_from_str(s_conv);
48176         return (int64_t)ret_conv;
48177 }
48178
48179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
48180         LDKStr s_conv = java_to_owned_str(env, s);
48181         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
48182         *ret_conv = SignedRawInvoice_from_str(s_conv);
48183         return (int64_t)ret_conv;
48184 }
48185
48186 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48187         LDKParseError* o_conv = (LDKParseError*)o;
48188         LDKStr ret_str = ParseError_to_str(o_conv);
48189         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48190         Str_free(ret_str);
48191         return ret_conv;
48192 }
48193
48194 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48195         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
48196         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
48197         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48198         Str_free(ret_str);
48199         return ret_conv;
48200 }
48201
48202 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48203         LDKInvoice o_conv;
48204         o_conv.inner = (void*)(o & (~1));
48205         o_conv.is_owned = false;
48206         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48207         LDKStr ret_str = Invoice_to_str(&o_conv);
48208         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48209         Str_free(ret_str);
48210         return ret_conv;
48211 }
48212
48213 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48214         LDKSignedRawInvoice o_conv;
48215         o_conv.inner = (void*)(o & (~1));
48216         o_conv.is_owned = false;
48217         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48218         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
48219         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48220         Str_free(ret_str);
48221         return ret_conv;
48222 }
48223
48224 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48225         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
48226         LDKStr ret_str = Currency_to_str(o_conv);
48227         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48228         Str_free(ret_str);
48229         return ret_conv;
48230 }
48231
48232 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48233         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
48234         LDKStr ret_str = SiPrefix_to_str(o_conv);
48235         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48236         Str_free(ret_str);
48237         return ret_conv;
48238 }
48239
48240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48241         LDKRapidGossipSync this_obj_conv;
48242         this_obj_conv.inner = (void*)(this_obj & (~1));
48243         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48245         RapidGossipSync_free(this_obj_conv);
48246 }
48247
48248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph) {
48249         LDKNetworkGraph network_graph_conv;
48250         network_graph_conv.inner = (void*)(network_graph & (~1));
48251         network_graph_conv.is_owned = false;
48252         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
48253         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv);
48254         int64_t ret_ref = 0;
48255         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48256         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48258         ret_ref = (uintptr_t)ret_var.inner;
48259         if (ret_var.is_owned) {
48260                 ret_ref |= 1;
48261         }
48262         return ret_ref;
48263 }
48264
48265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1sync_1network_1graph_1with_1file_1path(JNIEnv *env, jclass clz, int64_t this_arg, jstring sync_path) {
48266         LDKRapidGossipSync this_arg_conv;
48267         this_arg_conv.inner = (void*)(this_arg & (~1));
48268         this_arg_conv.is_owned = false;
48269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48270         LDKStr sync_path_conv = java_to_owned_str(env, sync_path);
48271         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
48272         *ret_conv = RapidGossipSync_sync_network_graph_with_file_path(&this_arg_conv, sync_path_conv);
48273         return (int64_t)ret_conv;
48274 }
48275
48276 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
48277         LDKRapidGossipSync this_arg_conv;
48278         this_arg_conv.inner = (void*)(this_arg & (~1));
48279         this_arg_conv.is_owned = false;
48280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48281         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
48282         return ret_conv;
48283 }
48284
48285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48286         if ((this_ptr & 1) != 0) return;
48287         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48288         CHECK_ACCESS(this_ptr_ptr);
48289         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
48290         FREE((void*)this_ptr);
48291         GraphSyncError_free(this_ptr_conv);
48292 }
48293
48294 static inline uintptr_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
48295         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48296         *ret_copy = GraphSyncError_clone(arg);
48297 int64_t ret_ref = (uintptr_t)ret_copy;
48298         return ret_ref;
48299 }
48300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48301         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)arg;
48302         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
48303         return ret_conv;
48304 }
48305
48306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48307         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)orig;
48308         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48309         *ret_copy = GraphSyncError_clone(orig_conv);
48310         int64_t ret_ref = (uintptr_t)ret_copy;
48311         return ret_ref;
48312 }
48313
48314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
48315         LDKDecodeError a_conv;
48316         a_conv.inner = (void*)(a & (~1));
48317         a_conv.is_owned = (a & 1) || (a == 0);
48318         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48319         a_conv = DecodeError_clone(&a_conv);
48320         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48321         *ret_copy = GraphSyncError_decode_error(a_conv);
48322         int64_t ret_ref = (uintptr_t)ret_copy;
48323         return ret_ref;
48324 }
48325
48326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
48327         LDKLightningError a_conv;
48328         a_conv.inner = (void*)(a & (~1));
48329         a_conv.is_owned = (a & 1) || (a == 0);
48330         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48331         a_conv = LightningError_clone(&a_conv);
48332         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48333         *ret_copy = GraphSyncError_lightning_error(a_conv);
48334         int64_t ret_ref = (uintptr_t)ret_copy;
48335         return ret_ref;
48336 }
48337
48338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1update_1network_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray update_data) {
48339         LDKRapidGossipSync this_arg_conv;
48340         this_arg_conv.inner = (void*)(this_arg & (~1));
48341         this_arg_conv.is_owned = false;
48342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48343         LDKu8slice update_data_ref;
48344         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
48345         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
48346         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
48347         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
48348         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
48349         return (int64_t)ret_conv;
48350 }
48351